Skip to content

Commit

Permalink
Moving in robust ipv4 & ipv6 support
Browse files Browse the repository at this point in the history
Certs have DIS/DNS record examples
  • Loading branch information
Universal Web committed Oct 2, 2023
1 parent 9b18e2a commit e350e6d
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 4 deletions.
72 changes: 72 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@universalweb/acid": "^3.0.39",
"@universalweb/docredux": "^3.2.2",
"auto-changelog": "^2.4.0",
"axios": "^1.5.1",
"brotli": "^1.3.3",
"compression": "^1.7.4",
"electron": "^23.1.3",
Expand Down Expand Up @@ -120,4 +121,4 @@
"devDependencies": {
"@electron-forge/cli": "^6.0.5"
}
}
}
Binary file modified profiles/default-Ephemeral.cert
Binary file not shown.
Binary file modified profiles/default-EphemeralPublic.cert
Binary file not shown.
Binary file modified profiles/default-Master.cert
Binary file not shown.
Binary file modified profiles/default-MasterPublic.cert
Binary file not shown.
Binary file modified profiles/default-Profile.cert
Binary file not shown.
39 changes: 36 additions & 3 deletions scripts/certificates.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,45 @@ const domainProfile = await createProfile({
url: 'universal.web',
domain: 'universal',
extension: 'web',
// The ip, ipv4, & ipv6 properties are used to determine the IP address of the server.
// The ip property can be either ipv4 or ipv6.
// ipv4/ipv6 can also be used as a form of backup ips or the primary ips for their respective versions. Similar to A & AAAA records.
ip: '::1',
ipv4: 'localhost',
// This allows for IPv4 and IPv6 to use specific details that is more fitting for that endpoint.
// This is not intended to be used when IPv6 becomes the standard.
ipv4: '127.0.0.1',
ipv6: '::1',
// Another format for IPv4 and ipv6 is an object with specific details that can override the initial certificate's details.
// ipv4: {
// ip: '127.0.0.1',
// keypair: {}
// },
// Records can be attached to this domain certificate in their own certificate or included in this certificate.
// If multiple A or AAAA records are provided in addition to the ips listed above then they will be used as backup ips.
records: {
aaaa: '::1',
a: 'localhost'
aaaa: [{
name: '@',
content: '::1',
priority: 0,
ttl: 'auto'
}],
a: [{
name: '@',
content: '127.0.0.1',
priority: 0,
ttl: 'auto'
}],
mx: [{
name: '@',
content: 'email.universal.web',
priority: 0,
ttl: 'auto'
}, {
name: '@',
content: 'email2.universal.web',
priority: 1,
ttl: 'auto'
}],
},
port: 8888,
// Used when a custom Domain name server is used to resolve the domain name locations still provides valid certificates else will be warned of invalid certificate
Expand Down
45 changes: 45 additions & 0 deletions scripts/getSupportedIPversion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { forEachAsync } from '@universalweb/acid';
import axios from 'axios';
const ipv6Servers = ['https://api64.ipify.org?format=json'];
const ipv4Servers = ['https://api.ipify.org?format=json'];
async function fetchFromAPI(url) {
try {
const response = await axios.get(url);
if (response.data && response.data.ip) {
return response.data.ip;
} else {
// console.error('Failed to retrieve WAN IP address.');
}
} catch (error) {
// console.error('Error fetching WAN IP address:', error.message);
}
}
async function getWANIPAddress(getBoth) {
const ip6length = ipv6Servers.length;
const ip4length = ipv4Servers.length;
let globalIP;
const results = {};
for (let i = 0; i < ip6length; i++) {
const result = await fetchFromAPI(ipv6Servers[i]);
if (result) {
results.ip = result;
if (result.includes(':')) {
results.ipv6 = result;
} else {
results.ipv4 = result;
}
break;
}
}
if (getBoth && results.ipv6) {
for (let i = 0; i < ip4length; i++) {
const result = await fetchFromAPI(ipv4Servers[i]);
if (result) {
results.ipv4 = result;
break;
}
}
}
return results;
}
console.log(await getWANIPAddress());
Binary file modified services/universal.web-Ephemeral.cert
Binary file not shown.
Binary file modified services/universal.web-EphemeralPublic.cert
Binary file not shown.
Binary file modified services/universal.web-Master.cert
Binary file not shown.
Binary file modified services/universal.web-MasterPublic.cert
Binary file not shown.
Binary file modified services/universal.web-Profile.cert
Binary file not shown.

0 comments on commit e350e6d

Please sign in to comment.