Define alt ports for web socket connections
Summary: The changes below add the notion of alternative ports to Flipper. These alternative ports are meant to and will be used to connect via WebSocket instead of RSocket. The name does not suggest that as to make as generic as possible so that they can be reused for different purposes in the future. Reviewed By: passy Differential Revision: D30898874 fbshipit-source-id: 5eed8c61b41b502c859192aaac59c284b7b36228
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6359c82be1
commit
1390bf4a33
@@ -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.
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
@interface SKEnvironmentVariables : NSObject
|
||||
+ (int)getInsecurePort;
|
||||
+ (int)getSecurePort;
|
||||
+ (int)getAltInsecurePort;
|
||||
+ (int)getAltSecurePort;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user