Skip to content

Commit fd913ad

Browse files
committed
Add dns api & bugfixes, release 1.2.0
1 parent b3e44e6 commit fd913ad

File tree

12 files changed

+10851
-7461
lines changed

12 files changed

+10851
-7461
lines changed

.dev/getips_screenshot.png

21.7 KB
Loading

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ node_modules/
33
coverage/
44
.DS_Store
55
*.code-workspace
6-
*.env
6+
*.env
7+
.yarn

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

package.json

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
{
22
"name": "get-ips",
3-
"version": "1.0.0",
3+
"version": "1.2.0",
44
"description": "WebExtension to Get Server & Client IPs",
5+
"license": "MPL-2.0",
6+
"author": "Silbad",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/Silbad/getIPs"
10+
},
11+
"bugs": {
12+
"url": "https://github.com/Silbad/getIPs/issues"
13+
},
514
"scripts": {
615
"code:lint": "eslint '**/**/*.{ts,tsx,svelte}'",
716
"code:lint-fix": "eslint --fix '**/**/*.{ts,tsx,svelte}'",
@@ -19,7 +28,10 @@
1928
"test:unit": "jest",
2029
"test:unit-update-snapshot": "jest --updateSnapshot"
2130
},
22-
"author": "Silbad",
31+
"dependencies": {
32+
"axios": "^0.26.1",
33+
"ipaddr.js": "^2.0.1"
34+
},
2335
"devDependencies": {
2436
"@babel/core": "^7.14.2",
2537
"@babel/preset-env": "^7.14.2",
@@ -42,49 +54,26 @@
4254
"eslint-plugin-import": "^2.23.0",
4355
"eslint-plugin-svelte3": "^3.2.0",
4456
"git-hooks-plus": "^1.0.1",
45-
"jest": "^26.6.3",
46-
"mini-css-extract-plugin": "^1.6.0",
47-
"prettier": "^2.3.0",
48-
"prettier-plugin-svelte": "^2.3.0",
57+
"jest": "^27.5.1",
58+
"mini-css-extract-plugin": "^2.6.0",
59+
"prettier": "^2.6.2",
60+
"prettier-plugin-svelte": "^2.7.0",
4961
"rimraf": "^3.0.2",
5062
"sinon": "^10.0.0",
5163
"stylelint": "^13.13.1",
5264
"stylelint-config-standard": "^22.0.0",
53-
"svelte": "^3.31.2",
54-
"svelte-check": "^1.0.46",
55-
"svelte-jester": "^1.5.0",
56-
"svelte-loader": "^3.0.0",
57-
"svelte-preprocess": "^4.9.1",
65+
"svelte": "^3.47.0",
66+
"svelte-check": "^2.7.0",
67+
"svelte-jester": "^2.3.2",
68+
"svelte-loader": "^3.1.2",
69+
"svelte-preprocess": "^4.10.6",
5870
"ts-jest": "^26.5.6",
5971
"ts-loader": "^8.2.0",
6072
"tslib": "^2.0.1",
6173
"typescript": "^4.2.4",
6274
"web-ext-types": "^3.2.1",
63-
"webpack": "^5.16.0",
64-
"webpack-cli": "^4.4.0",
65-
"whatwg-fetch": "^3.0.0"
66-
},
67-
"keywords": [
68-
"chrome extension",
69-
"microsoft edge extension",
70-
"firefox addon",
71-
"web extension",
72-
"typescript",
73-
"ts",
74-
"jest",
75-
"sinon"
76-
],
77-
"repository": {
78-
"type": "git",
79-
"url": "https://github.com/davidnguyen179/web-extension-svelte-boilerplate.git"
80-
},
81-
"license": "MIT",
82-
"bugs": {
83-
"url": "https://github.com/davidnguyen179/web-extension-svelte-boilerplate/issues"
84-
},
85-
"homepage": "https://github.com/davidnguyen179/web-extension-svelte-boilerplate/blob/main/README.md",
86-
"dependencies": {
87-
"axios": "^0.21.3",
88-
"public-ip": "^4.0.4"
75+
"webpack": "^5.72.0",
76+
"webpack-cli": "^4.9.2",
77+
"whatwg-fetch": "^3.6.2"
8978
}
9079
}

public/firefox_manifest.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
{
22
"name": "Get IPs",
3-
"version": "1.0.0",
3+
"version": "1.2.0",
44
"description": "Get Server & Client IPs.",
55
"permissions": [
6-
"clipboardWrite"
6+
"clipboardWrite",
7+
"dns",
8+
"tabs",
9+
"<all_urls>",
10+
"http://*/*",
11+
"https://*/*"
712
],
813
"manifest_version": 2,
9-
"background": {
10-
"scripts": [
11-
"background.js"
12-
],
13-
"persistent": true
14-
},
1514
"browser_action": {
1615
"default_popup": "popup.html",
1716
"default_icon": {
@@ -20,7 +19,7 @@
2019
"48": "images/logo/getips-48.png",
2120
"128": "images/logo/getips-128.png"
2221
},
23-
"default_title": "Getting Started Example"
22+
"default_title": "Get IPs"
2423
},
2524
"icons": {
2625
"16": "images/logo/getips-16.png",

src/components/App/App.svelte

Lines changed: 78 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,55 @@
11
<script lang="ts">
2-
import AppWrapper from '../AppWrapper/AppWrapper.svelte';
2+
import AppWrapper from './AppWrapper.svelte';
33
import axios from 'axios';
4+
import ipaddr from 'ipaddr.js';
45
5-
const publicIp = require('public-ip');
6-
let ipv4 = '...';
7-
let ipv6 = '...';
8-
let textBtnV4 = 'copy';
9-
let textBtnV6 = 'copy';
10-
// let textBtnServer = 'copy';
11-
let classBtnV4 = 'btn-primary';
12-
let classBtnV6 = 'btn-primary';
13-
// let classBtnServer = 'btn-primary';
6+
let ipv4 = '';
7+
let ipv6 = '';
8+
let ipServer = [];
9+
let canonicalName = '';
1410
15-
(async () => {
16-
ipv4 = await publicIp.v4();
17-
ipv6 = await publicIp.v6();
18-
})();
11+
// récupérer l'IPv4 client
12+
axios.get('https://api.ipify.org').then(function (response) {
13+
ipv4 = response.data;
14+
});
1915
20-
function copyIpOnClipboard(typeIP) {
21-
const type = typeIP.target.dataset.type;
16+
// récupérer l'IPv6 client
17+
axios.get('https://api64.ipify.org').then(function (response) {
18+
ipv6 = response.data;
19+
});
2220
23-
textBtnV4 = 'copy';
24-
textBtnV6 = 'copy';
25-
classBtnV4 = 'btn-primary';
26-
classBtnV6 = 'btn-primary';
21+
// récupérer les IPs server
22+
browser.tabs
23+
.query({
24+
currentWindow: true,
25+
active: true,
26+
})
27+
.then(function (tabInfo) {
28+
let domain = new URL(tabInfo[0].url).hostname.replace('www.', '');
29+
if (domain) {
30+
let resolving = browser.dns.resolve(domain, ['bypass_cache', 'canonical_name']);
31+
resolving.then((resolved) => {
32+
console.log(resolved);
33+
ipServer = resolved.addresses;
34+
canonicalName = resolved.canonicalName;
35+
});
36+
}
37+
});
2738
28-
switch (type) {
29-
case 'IPv4':
30-
navigator.clipboard.writeText(ipv4).then(
31-
function () {
32-
textBtnV4 = 'copied';
33-
classBtnV4 = 'btn-success';
34-
setTimeout(function () {
35-
textBtnV4 = 'copy';
36-
classBtnV4 = 'btn-primary';
37-
}, 3000);
38-
},
39-
function () {
40-
console.log('failed');
41-
}
42-
);
43-
break;
44-
case 'IPv6':
45-
navigator.clipboard.writeText(ipv6).then(
46-
function () {
47-
textBtnV6 = 'copied';
48-
classBtnV6 = 'btn-success';
49-
setTimeout(function () {
50-
textBtnV6 = 'copy';
51-
classBtnV6 = 'btn-primary';
52-
}, 3000);
53-
},
54-
function () {
55-
console.log('failed');
56-
}
57-
);
58-
break;
59-
default:
60-
console.log(`Sorry, we are out of ${type}.`);
61-
}
39+
function copyIpOnClipboard(data) {
40+
navigator.clipboard.writeText(data.target.dataset.ip).then(
41+
function () {
42+
data.target.innerText = 'copied';
43+
data.target.className = 'btn-success';
44+
setTimeout(function () {
45+
data.target.innerText = 'copy';
46+
data.target.className = 'btn-primary';
47+
}, 3000);
48+
},
49+
function () {
50+
console.log('failed');
51+
}
52+
);
6253
}
6354
</script>
6455

@@ -67,14 +58,39 @@
6758
<h1 class="d-none">Get IPs</h1>
6859
<div class="kaomoji">°˖✧◝(⁰▿⁰)◜✧˖°</div>
6960
<h2>Your public IPs :</h2>
70-
<strong>IPv4 :</strong>
71-
{ipv4}<button class={classBtnV4} on:click={copyIpOnClipboard} data-type="IPv4">{textBtnV4}</button>
72-
<br />
73-
<strong>IPv6 :</strong>
74-
{ipv6}<button class={classBtnV6} on:click={copyIpOnClipboard} data-type="IPv6">{textBtnV6}</button>
75-
<h2>The current URL IP :</h2>
76-
Soon...
77-
<div class="version">getIPs <strong>1.0.0</strong></div>
61+
{#if ipv4 !== ''}
62+
<strong>IPv4 :</strong>
63+
{ipv4}<button class="btn-primary" on:click={copyIpOnClipboard} data-ip={ipv4}>copy</button>
64+
{:else}
65+
<strong>IPv4</strong> unavailable
66+
{/if}
67+
{#if ipv6 !== ''}
68+
<br />
69+
<strong>IPv6 :</strong>
70+
{ipv6}<button class="btn-primary" on:click={copyIpOnClipboard} data-ip={ipv6}>copy</button>
71+
{:else}
72+
<br />
73+
<strong>IPv6</strong> unavailable
74+
{/if}
75+
<h2>The current URL IPs :</h2>
76+
{#if ipServer.length}
77+
<strong>Canonical name :</strong>
78+
{canonicalName}
79+
<br />
80+
{#each ipServer as ip}
81+
{#if ipaddr.IPv4.isValid(ip)}
82+
<strong>IPv4 :</strong>
83+
{:else if ipaddr.IPv6.isValid(ip)}
84+
<strong>IPv6 :</strong>
85+
{:else}
86+
<strong>IP no valid :</strong>
87+
{/if}
88+
{ip}<button class="btn-primary" on:click={copyIpOnClipboard} data-ip={ip}>copy</button><br />
89+
{/each}
90+
{:else}
91+
<strong>IP server</strong> unavailable
92+
{/if}
93+
<div class="version">getIPs <strong>1.2.0</strong></div>
7894
</div>
7995
</AppWrapper>
8096

File renamed without changes.

src/components/App/__test/App.spec.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/components/App/__test/__snapshots__/App.spec.ts.snap

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/components/AppWrapper/__test/AppWrapper.spec.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)