diff --git a/desktop/app/src/server/comms/ServerController.tsx b/desktop/app/src/server/comms/ServerController.tsx index 457512015..83e4caf73 100644 --- a/desktop/app/src/server/comms/ServerController.tsx +++ b/desktop/app/src/server/comms/ServerController.tsx @@ -125,10 +125,15 @@ class ServerController extends EventEmitter implements ServerEventsListener { this.initialized = this.certificateProvider .loadSecureServerConfig() .then((options) => { + console.log('[conn] secure server listening at port: ', secure); this.secureServer = createServer(secure, this, options); if (GK.get('flipper_websocket_server')) { const {secure: altSecure} = this.store.getState().application.altServerPorts; + console.log( + '[conn] secure server (ws) listening at port: ', + altSecure, + ); this.altSecureServer = createServer( altSecure, this, @@ -138,10 +143,15 @@ class ServerController extends EventEmitter implements ServerEventsListener { } }) .then(() => { + console.log('[conn] insecure server listening at port: ', insecure); this.insecureServer = createServer(insecure, this); if (GK.get('flipper_websocket_server')) { const {insecure: altInsecure} = this.store.getState().application.altServerPorts; + console.log( + '[conn] insecure server (ws) listening at port: ', + altInsecure, + ); this.altInsecureServer = createServer( altInsecure, this, diff --git a/iOS/FlipperKit/FlipperClient.mm b/iOS/FlipperKit/FlipperClient.mm index f19d22752..340b0701a 100644 --- a/iOS/FlipperKit/FlipperClient.mm +++ b/iOS/FlipperKit/FlipperClient.mm @@ -101,7 +101,9 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin; sonarThread.getEventBase(), connectionThread.getEventBase(), [SKEnvironmentVariables getInsecurePort], - [SKEnvironmentVariables getSecurePort]}); + [SKEnvironmentVariables getSecurePort], + [SKEnvironmentVariables getAltInsecurePort], + [SKEnvironmentVariables getAltSecurePort]}); _cppClient = facebook::flipper::FlipperClient::instance(); // To switch to a websocket provider, uncomment the line below. diff --git a/iOS/FlipperKit/SKEnvironmentVariables.h b/iOS/FlipperKit/SKEnvironmentVariables.h index 901b9ec83..9fd786b4f 100644 --- a/iOS/FlipperKit/SKEnvironmentVariables.h +++ b/iOS/FlipperKit/SKEnvironmentVariables.h @@ -14,6 +14,8 @@ @interface SKEnvironmentVariables : NSObject + (int)getInsecurePort; + (int)getSecurePort; ++ (int)getAltInsecurePort; ++ (int)getAltSecurePort; @end #endif diff --git a/iOS/FlipperKit/SKEnvironmentVariables.m b/iOS/FlipperKit/SKEnvironmentVariables.m index fc692a44d..3dda22b38 100644 --- a/iOS/FlipperKit/SKEnvironmentVariables.m +++ b/iOS/FlipperKit/SKEnvironmentVariables.m @@ -12,6 +12,9 @@ static int const DEFAULT_INSECURE_PORT = 8089; static int const DEFAULT_SECURE_PORT = 8088; +static int const DEFAULT_ALT_INSECURE_PORT = 9089; +static int const DEFAULT_ALT_SECURE_PORT = 9088; + @implementation SKEnvironmentVariables + (int)getInsecurePort { @@ -26,6 +29,18 @@ static int const DEFAULT_SECURE_PORT = 8088; atIndex:1 withDefault:DEFAULT_SECURE_PORT]; } ++ (int)getAltInsecurePort { + NSString* envVar = [self getFlipperAltPortsVariable]; + return [self extractIntFromPropValue:envVar + atIndex:0 + withDefault:DEFAULT_ALT_INSECURE_PORT]; +} ++ (int)getAltSecurePort { + NSString* envVar = [self getFlipperAltPortsVariable]; + return [self extractIntFromPropValue:envVar + atIndex:1 + withDefault:DEFAULT_ALT_SECURE_PORT]; +} + (int)extractIntFromPropValue:(NSString*)propValue atIndex:(int)index withDefault:(int)fallback { @@ -45,6 +60,17 @@ static int const DEFAULT_SECURE_PORT = 8088; return value; } ++ (NSString*)getFlipperAltPortsVariable { + // Try to retrieve from environment first. + NSString* value = NSProcessInfo.processInfo.environment[@"FLIPPER_ALT_PORTS"]; + // If empty, check defaults instead. + if ([value length] == 0) { + value = [[NSUserDefaults standardUserDefaults] + stringForKey:@"com.facebook.flipper.ports.alt"]; + } + + return value; +} @end #endif diff --git a/xplat/Flipper/FlipperInitConfig.h b/xplat/Flipper/FlipperInitConfig.h index 378367a5d..08aab69ad 100644 --- a/xplat/Flipper/FlipperInitConfig.h +++ b/xplat/Flipper/FlipperInitConfig.h @@ -41,6 +41,8 @@ struct FlipperInitConfig { int insecurePort = 8089; int securePort = 8088; + int altInsecurePort = 9089; + int altSecurePort = 9088; }; } // namespace flipper