Skip to content

Commit

Permalink
Merge pull request #366 from adam-p/ios-beta
Browse files Browse the repository at this point in the history
Fix the ClientPlatform on old iOS; enable bindToDevice code
  • Loading branch information
adam-p authored Apr 18, 2017
2 parents 863ed82 + a1c0f88 commit f6b8837
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,31 @@ -(NSString * _Nullable)getConfig {
// Fill in the rest of the values.
//

// Ensure the elements of the ClientPlatform do not contain underscores, as that's what we use to separate the elements.
// Like "iOS"
NSString *systemName = [[[UIDevice currentDevice] systemName] stringByReplacingOccurrencesOfString:@"_" withString:@"-"];
// ClientPlatform must not contain:
// - underscores, which are used by us to separate the constituent parts
// - spaces, which are considered invalid by the server
// Like "iOS". Older iOS reports "iPhone OS", which we will convert.
NSString *systemName = [[UIDevice currentDevice] systemName];
if ([systemName isEqual: @"iPhone OS"]) {
systemName = @"iOS";
}
systemName = [[systemName
stringByReplacingOccurrencesOfString:@"_" withString:@"-"]
stringByReplacingOccurrencesOfString:@" " withString:@"-"];
// Like "10.2.1"
NSString *systemVersion = [[[UIDevice currentDevice]systemVersion] stringByReplacingOccurrencesOfString:@"_" withString:@"-"];
NSString *systemVersion = [[[[UIDevice currentDevice]systemVersion]
stringByReplacingOccurrencesOfString:@"_" withString:@"-"]
stringByReplacingOccurrencesOfString:@" " withString:@"-"];

// "unjailbroken"/"jailbroken"
NSString *jailbroken = @"unjailbroken";
if ([JailbreakCheck isDeviceJailbroken]) {
jailbroken = @"jailbroken";
}
// Like "com.psiphon3.browser"
NSString *bundleIdentifier = [[[NSBundle mainBundle] bundleIdentifier] stringByReplacingOccurrencesOfString:@"_" withString:@"-"];
NSString *bundleIdentifier = [[[[NSBundle mainBundle] bundleIdentifier]
stringByReplacingOccurrencesOfString:@"_" withString:@"-"]
stringByReplacingOccurrencesOfString:@" " withString:@"-"];

NSString *clientPlatform = [NSString stringWithFormat:@"%@_%@_%@_%@",
systemName,
Expand Down Expand Up @@ -548,15 +561,10 @@ - (void)handlePsiphonNotice:(NSString * _Nonnull)noticeJSON {
#pragma mark - GoPsiPsiphonProvider protocol implementation (private)

- (BOOL)bindToDevice:(long)fileDescriptor error:(NSError **)error {
/*
This code is not currently used, so we won't leave it in untested. However,
this implementation info will probably be useful later.
// DEBUG
[self logMessage:[NSString stringWithFormat: @"***** DEBUG: bindToDevice called"]];
// This function is only called in TunnelWholeDevice mode

// TODO: Does this function ever get called?

// TODO: Determine if this is robust.
unsigned int interfaceIndex = if_nametoindex("ap1");

Expand All @@ -565,7 +573,6 @@ - (BOOL)bindToDevice:(long)fileDescriptor error:(NSError **)error {
[self logMessage:[NSString stringWithFormat: @"bindToDevice: setsockopt failed; errno: %d", errno]];
return FALSE;
}
*/

return TRUE;
}
Expand Down

0 comments on commit f6b8837

Please sign in to comment.