@dignetwork/dig-sdk 0.0.1-alpha.152 → 0.0.1-alpha.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -143,9 +143,9 @@ class ServerCoin {
|
|
|
143
143
|
// Sample server coins by epoch
|
|
144
144
|
async sampleServerCoinsByEpoch(epoch, sampleSize = 5, blacklist = []) {
|
|
145
145
|
// We dont want our own IP to be included
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
-
blacklist.push(
|
|
146
|
+
const host = await (0, network_1.getPublicHost)();
|
|
147
|
+
if (host) {
|
|
148
|
+
blacklist.push(host);
|
|
149
149
|
}
|
|
150
150
|
const serverCoinPeers = await this.getAllEpochPeers(epoch, blacklist);
|
|
151
151
|
if (Environment_1.Environment.DEBUG) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Environment.d.ts","sourceRoot":"","sources":["../../src/utils/Environment.ts"],"names":[],"mappings":"AAGA,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAkB;IAGxC,OAAO,CAAC,MAAM,CAAC,SAAS;IAOxB,OAAO,CAAC,MAAM,CAAC,mBAAmB;
|
|
1
|
+
{"version":3,"file":"Environment.d.ts","sourceRoot":"","sources":["../../src/utils/Environment.ts"],"names":[],"mappings":"AAGA,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAkB;IAGxC,OAAO,CAAC,MAAM,CAAC,SAAS;IAOxB,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAUlC,OAAO,CAAC,MAAM,CAAC,WAAW;IAK1B,OAAO,CAAC,MAAM,CAAC,eAAe;IAK9B,OAAO,CAAC,MAAM,CAAC,eAAe;IAO9B,MAAM,KAAK,YAAY,IAAI,MAAM,GAAG,SAAS,CAG5C;IAGD,MAAM,KAAK,YAAY,IAAI,MAAM,GAAG,SAAS,CAG5C;IAGD,MAAM,KAAK,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAGhD;IAGD,MAAM,KAAK,qBAAqB,IAAI,MAAM,GAAG,SAAS,CAGrD;IAGD,MAAM,KAAK,SAAS,IAAI,MAAM,GAAG,SAAS,CAGzC;IAGD,MAAM,KAAK,sBAAsB,IAAI,MAAM,GAAG,SAAS,CAEtD;IAGD,MAAM,KAAK,cAAc,IAAI,OAAO,GAAG,SAAS,CAG/C;IAGD,MAAM,KAAK,KAAK,IAAI,OAAO,GAAG,SAAS,CAGtC;IAGD,MAAM,KAAK,eAAe,IAAI,MAAM,GAAG,SAAS,CAG/C;IAGD,MAAM,KAAK,WAAW,IAAI,OAAO,GAAG,SAAS,CAG5C;IAED,MAAM,KAAK,QAAQ,CAAC,IAAI,EAAE,OAAO,EAEhC;IAED,MAAM,KAAK,QAAQ,IAAI,OAAO,GAAG,SAAS,CAEzC;CACF"}
|
|
@@ -16,7 +16,8 @@ class Environment {
|
|
|
16
16
|
static isValidHostnameOrIp(hostname) {
|
|
17
17
|
// Hostname regex (simple, allows subdomains but not special characters)
|
|
18
18
|
const hostnamePattern = /^(([a-zA-Z0-9](-*[a-zA-Z0-9])*)\.)*([a-zA-Z0-9](-*[a-zA-Z0-9])*)\.?$/;
|
|
19
|
-
|
|
19
|
+
const ipv6Pattern = /^(([0-9a-fA-F]{1,4}:){7}([0-9a-fA-F]{1,4}|:)|(([0-9a-fA-F]{1,4}:){1,7}|:):(([0-9a-fA-F]{1,4}:){1,6}|:):([0-9a-fA-F]{1,4}|:):([0-9a-fA-F]{1,4}|:)|::)$/;
|
|
20
|
+
return this.isValidIp(hostname) || ipv6Pattern.test(hostname) || hostnamePattern.test(hostname);
|
|
20
21
|
}
|
|
21
22
|
// Helper to validate if a number is a valid port (between 1 and 65535)
|
|
22
23
|
static isValidPort(port) {
|
|
@@ -55,7 +56,7 @@ class Environment {
|
|
|
55
56
|
// Static getter for PUBLIC_IP (valid IP)
|
|
56
57
|
static get PUBLIC_IP() {
|
|
57
58
|
const value = process.env["PUBLIC_IP"];
|
|
58
|
-
return value && this.
|
|
59
|
+
return value && this.isValidHostnameOrIp(value) ? value : undefined;
|
|
59
60
|
}
|
|
60
61
|
// Static getter for DISK_SPACE_LIMIT_BYTES (number, optional)
|
|
61
62
|
static get DISK_SPACE_LIMIT_BYTES() {
|