Skip to content

Commit

Permalink
Add dns api & bugfixes, release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Silbad committed Apr 16, 2022
1 parent b3e44e6 commit fd913ad
Show file tree
Hide file tree
Showing 12 changed files with 10,851 additions and 7,461 deletions.
Binary file added .dev/getips_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules/
coverage/
.DS_Store
*.code-workspace
*.env
*.env
.yarn
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
63 changes: 26 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"name": "get-ips",
"version": "1.0.0",
"version": "1.2.0",
"description": "WebExtension to Get Server & Client IPs",
"license": "MPL-2.0",
"author": "Silbad",
"repository": {
"type": "git",
"url": "https://github.com/Silbad/getIPs"
},
"bugs": {
"url": "https://github.com/Silbad/getIPs/issues"
},
"scripts": {
"code:lint": "eslint '**/**/*.{ts,tsx,svelte}'",
"code:lint-fix": "eslint --fix '**/**/*.{ts,tsx,svelte}'",
Expand All @@ -19,7 +28,10 @@
"test:unit": "jest",
"test:unit-update-snapshot": "jest --updateSnapshot"
},
"author": "Silbad",
"dependencies": {
"axios": "^0.26.1",
"ipaddr.js": "^2.0.1"
},
"devDependencies": {
"@babel/core": "^7.14.2",
"@babel/preset-env": "^7.14.2",
Expand All @@ -42,49 +54,26 @@
"eslint-plugin-import": "^2.23.0",
"eslint-plugin-svelte3": "^3.2.0",
"git-hooks-plus": "^1.0.1",
"jest": "^26.6.3",
"mini-css-extract-plugin": "^1.6.0",
"prettier": "^2.3.0",
"prettier-plugin-svelte": "^2.3.0",
"jest": "^27.5.1",
"mini-css-extract-plugin": "^2.6.0",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
"rimraf": "^3.0.2",
"sinon": "^10.0.0",
"stylelint": "^13.13.1",
"stylelint-config-standard": "^22.0.0",
"svelte": "^3.31.2",
"svelte-check": "^1.0.46",
"svelte-jester": "^1.5.0",
"svelte-loader": "^3.0.0",
"svelte-preprocess": "^4.9.1",
"svelte": "^3.47.0",
"svelte-check": "^2.7.0",
"svelte-jester": "^2.3.2",
"svelte-loader": "^3.1.2",
"svelte-preprocess": "^4.10.6",
"ts-jest": "^26.5.6",
"ts-loader": "^8.2.0",
"tslib": "^2.0.1",
"typescript": "^4.2.4",
"web-ext-types": "^3.2.1",
"webpack": "^5.16.0",
"webpack-cli": "^4.4.0",
"whatwg-fetch": "^3.0.0"
},
"keywords": [
"chrome extension",
"microsoft edge extension",
"firefox addon",
"web extension",
"typescript",
"ts",
"jest",
"sinon"
],
"repository": {
"type": "git",
"url": "https://github.com/davidnguyen179/web-extension-svelte-boilerplate.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/davidnguyen179/web-extension-svelte-boilerplate/issues"
},
"homepage": "https://github.com/davidnguyen179/web-extension-svelte-boilerplate/blob/main/README.md",
"dependencies": {
"axios": "^0.21.3",
"public-ip": "^4.0.4"
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2",
"whatwg-fetch": "^3.6.2"
}
}
17 changes: 8 additions & 9 deletions public/firefox_manifest.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"name": "Get IPs",
"version": "1.0.0",
"version": "1.2.0",
"description": "Get Server & Client IPs.",
"permissions": [
"clipboardWrite"
"clipboardWrite",
"dns",
"tabs",
"<all_urls>",
"http://*/*",
"https://*/*"
],
"manifest_version": 2,
"background": {
"scripts": [
"background.js"
],
"persistent": true
},
"browser_action": {
"default_popup": "popup.html",
"default_icon": {
Expand All @@ -20,7 +19,7 @@
"48": "images/logo/getips-48.png",
"128": "images/logo/getips-128.png"
},
"default_title": "Getting Started Example"
"default_title": "Get IPs"
},
"icons": {
"16": "images/logo/getips-16.png",
Expand Down
140 changes: 78 additions & 62 deletions src/components/App/App.svelte
Original file line number Diff line number Diff line change
@@ -1,64 +1,55 @@
<script lang="ts">
import AppWrapper from '../AppWrapper/AppWrapper.svelte';
import AppWrapper from './AppWrapper.svelte';
import axios from 'axios';
import ipaddr from 'ipaddr.js';
const publicIp = require('public-ip');
let ipv4 = '...';
let ipv6 = '...';
let textBtnV4 = 'copy';
let textBtnV6 = 'copy';
// let textBtnServer = 'copy';
let classBtnV4 = 'btn-primary';
let classBtnV6 = 'btn-primary';
// let classBtnServer = 'btn-primary';
let ipv4 = '';
let ipv6 = '';
let ipServer = [];
let canonicalName = '';
(async () => {
ipv4 = await publicIp.v4();
ipv6 = await publicIp.v6();
})();
// récupérer l'IPv4 client
axios.get('https://api.ipify.org').then(function (response) {
ipv4 = response.data;
});
function copyIpOnClipboard(typeIP) {
const type = typeIP.target.dataset.type;
// récupérer l'IPv6 client
axios.get('https://api64.ipify.org').then(function (response) {
ipv6 = response.data;
});
textBtnV4 = 'copy';
textBtnV6 = 'copy';
classBtnV4 = 'btn-primary';
classBtnV6 = 'btn-primary';
// récupérer les IPs server
browser.tabs
.query({
currentWindow: true,
active: true,
})
.then(function (tabInfo) {
let domain = new URL(tabInfo[0].url).hostname.replace('www.', '');
if (domain) {
let resolving = browser.dns.resolve(domain, ['bypass_cache', 'canonical_name']);
resolving.then((resolved) => {
console.log(resolved);
ipServer = resolved.addresses;
canonicalName = resolved.canonicalName;
});
}
});
switch (type) {
case 'IPv4':
navigator.clipboard.writeText(ipv4).then(
function () {
textBtnV4 = 'copied';
classBtnV4 = 'btn-success';
setTimeout(function () {
textBtnV4 = 'copy';
classBtnV4 = 'btn-primary';
}, 3000);
},
function () {
console.log('failed');
}
);
break;
case 'IPv6':
navigator.clipboard.writeText(ipv6).then(
function () {
textBtnV6 = 'copied';
classBtnV6 = 'btn-success';
setTimeout(function () {
textBtnV6 = 'copy';
classBtnV6 = 'btn-primary';
}, 3000);
},
function () {
console.log('failed');
}
);
break;
default:
console.log(`Sorry, we are out of ${type}.`);
}
function copyIpOnClipboard(data) {
navigator.clipboard.writeText(data.target.dataset.ip).then(
function () {
data.target.innerText = 'copied';
data.target.className = 'btn-success';
setTimeout(function () {
data.target.innerText = 'copy';
data.target.className = 'btn-primary';
}, 3000);
},
function () {
console.log('failed');
}
);
}
</script>

Expand All @@ -67,14 +58,39 @@
<h1 class="d-none">Get IPs</h1>
<div class="kaomoji">°˖✧◝(⁰▿⁰)◜✧˖°</div>
<h2>Your public IPs :</h2>
<strong>IPv4 :</strong>
{ipv4}<button class={classBtnV4} on:click={copyIpOnClipboard} data-type="IPv4">{textBtnV4}</button>
<br />
<strong>IPv6 :</strong>
{ipv6}<button class={classBtnV6} on:click={copyIpOnClipboard} data-type="IPv6">{textBtnV6}</button>
<h2>The current URL IP :</h2>
Soon...
<div class="version">getIPs <strong>1.0.0</strong></div>
{#if ipv4 !== ''}
<strong>IPv4 :</strong>
{ipv4}<button class="btn-primary" on:click={copyIpOnClipboard} data-ip={ipv4}>copy</button>
{:else}
<strong>IPv4</strong> unavailable
{/if}
{#if ipv6 !== ''}
<br />
<strong>IPv6 :</strong>
{ipv6}<button class="btn-primary" on:click={copyIpOnClipboard} data-ip={ipv6}>copy</button>
{:else}
<br />
<strong>IPv6</strong> unavailable
{/if}
<h2>The current URL IPs :</h2>
{#if ipServer.length}
<strong>Canonical name :</strong>
{canonicalName}
<br />
{#each ipServer as ip}
{#if ipaddr.IPv4.isValid(ip)}
<strong>IPv4 :</strong>
{:else if ipaddr.IPv6.isValid(ip)}
<strong>IPv6 :</strong>
{:else}
<strong>IP no valid :</strong>
{/if}
{ip}<button class="btn-primary" on:click={copyIpOnClipboard} data-ip={ip}>copy</button><br />
{/each}
{:else}
<strong>IP server</strong> unavailable
{/if}
<div class="version">getIPs <strong>1.2.0</strong></div>
</div>
</AppWrapper>

Expand Down
File renamed without changes.
14 changes: 0 additions & 14 deletions src/components/App/__test/App.spec.ts

This file was deleted.

31 changes: 0 additions & 31 deletions src/components/App/__test/__snapshots__/App.spec.ts.snap

This file was deleted.

20 changes: 0 additions & 20 deletions src/components/AppWrapper/__test/AppWrapper.spec.ts

This file was deleted.

1 change: 0 additions & 1 deletion webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const SRC_DIR_NAME = 'src';
module.exports = {
entry: {
popup: path.join(__dirname, `../${SRC_DIR_NAME}/popup.ts`),
background: path.join(__dirname, `../${SRC_DIR_NAME}/background/${browser}/background.ts`),
},
output: {
path: path.join(__dirname, `../${BUILD_DIR_NAME}`),
Expand Down
Loading

0 comments on commit fd913ad

Please sign in to comment.