Skip to content

Commit d170a28

Browse files
authored
Merge pull request #1507 from Bilb/feat/allow-local-devnet
feat: allow to provide local devnet url
2 parents 23a5eda + 12cbeea commit d170a28

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

preload.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ window.sessionFeatureFlags = {
5959
useClosedGroupV2QAButtons: false, // TODO DO NOT MERGE
6060
useOnionRequests: true,
6161
useTestNet: isTestNet() || isTestIntegration(),
62+
useLocalDevNet: !isEmpty(process.env.LOCAL_DEVNET_SEED_URL)
63+
? process.env.LOCAL_DEVNET_SEED_URL
64+
: undefined,
6265
debugInputCommands: !isEmpty(process.env.SESSION_DEBUG),
6366
alwaysShowRemainingChars: false,
6467
showPopoverAnchors: false,
@@ -292,6 +295,10 @@ setInterval(() => {
292295
window.clipboard = clipboard;
293296

294297
window.getSeedNodeList = () => {
298+
if (window.sessionFeatureFlags.useLocalDevNet) {
299+
return [window.sessionFeatureFlags.useLocalDevNet];
300+
}
301+
295302
if (window.sessionFeatureFlags.useTestNet) {
296303
return ['http://seed2.getsession.org:38157'];
297304
}

ts/components/dialog/debug/FeatureFlags.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const FlagToggle = ({
5959
);
6060
};
6161

62-
type FlagValues = boolean | object;
62+
type FlagValues = boolean | object | string;
6363

6464
export const FeatureFlags = ({
6565
flags,

ts/components/dialog/debug/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ type DebugFeatureFlagsType = {
99
export const DEBUG_FEATURE_FLAGS: DebugFeatureFlagsType = {
1010
// NOTE Put new feature flags in here during development so they are not available in production environments. Remove from here when they are ready for QA and production
1111
DEV: ['showPopoverAnchors', 'debugInputCommands'],
12-
UNSUPPORTED: ['useTestNet'],
12+
UNSUPPORTED: ['useTestNet', 'useLocalDevNet'],
1313
UNTESTED: ['useOnionRequests', 'replaceLocalizedStringsWithKeys'],
1414
};

ts/session/apis/seed_node_api/SeedNodeAPI.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ const getSslAgentForSeedNode = async (seedNodeHost: string, isSsl = false) => {
6464
return undefined;
6565
}
6666

67+
if (window.sessionFeatureFlags?.useLocalDevNet) {
68+
const sslOptions: https.AgentOptions = {
69+
// local devnet: allow unauthorized
70+
rejectUnauthorized: false,
71+
keepAlive: true,
72+
};
73+
74+
return new https.Agent(sslOptions);
75+
}
76+
6777
switch (seedNodeHost) {
6878
case 'seed1.getsession.org':
6979
certContent = isLinux() ? storageSeed1Crt : Buffer.from(storageSeed1Crt, 'utf-8').toString();

ts/session/onions/onionPath.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,9 @@ async function buildNewOnionPathsWorker() {
486486
'Too few nodes "unique by ip" to build an onion path. Even after fetching from seed.'
487487
);
488488
}
489-
let otherNodes = _.differenceBy(
490-
oneNodeForEachSubnet24KeepingRatio,
491-
guardNodes,
492-
'pubkey_ed25519'
493-
);
489+
let otherNodes = window.sessionFeatureFlags?.useLocalDevNet
490+
? allNodes
491+
: _.differenceBy(oneNodeForEachSubnet24KeepingRatio, guardNodes, 'pubkey_ed25519');
494492
const guards = _.shuffle(guardNodes);
495493

496494
// Create path for every guard node:

ts/state/ducks/types/releasedFeaturesReduxTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type SessionFeatureFlags = {
66
// Hooks
77
useOnionRequests: boolean;
88
useTestNet: boolean;
9+
useLocalDevNet: string;
910
useClosedGroupV2QAButtons: boolean;
1011
alwaysShowRemainingChars: boolean;
1112
showPopoverAnchors: boolean;

0 commit comments

Comments
 (0)