mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			88 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Objective-C
		
	
			
		
		
	
	
			88 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Objective-C
		
	
| //
 | |
| //  Copyright (c) 2017 Open Whisper Systems. All rights reserved.
 | |
| //
 | |
| 
 | |
| #import "OWSCensorshipConfiguration.h"
 | |
| #import "TSStorageManager.h"
 | |
| 
 | |
| NS_ASSUME_NONNULL_BEGIN
 | |
| 
 | |
| NSString *const OWSCensorshipConfigurationReflectorHost = @"signal-reflector-meek.appspot.com";
 | |
| 
 | |
| @implementation OWSCensorshipConfiguration
 | |
| 
 | |
| - (NSString *)frontingHost:(NSString *)e164PhonNumber
 | |
| {
 | |
|     OWSAssert(e164PhonNumber.length > 0);
 | |
|     
 | |
|     NSString *domain = nil;
 | |
|     for (NSString *countryCode in self.censoredCountryCodes) {
 | |
|         if ([e164PhonNumber hasPrefix:countryCode]) {
 | |
|             domain = self.censoredCountryCodes[countryCode];
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     // Fronting should only be auto-activated for countries specified in censoredCountryCodes,
 | |
|     // all of which have a domain specified.  However users can also manually enable
 | |
|     // censorship circumvention.
 | |
|     if (!domain) {
 | |
|         domain = @"google.com";
 | |
|     }
 | |
|     
 | |
|     return [@"https://" stringByAppendingString:domain];
 | |
| }
 | |
| 
 | |
| - (NSString *)reflectorHost
 | |
| {
 | |
|     return OWSCensorshipConfigurationReflectorHost;
 | |
| }
 | |
| 
 | |
| - (NSDictionary<NSString *, NSString *> *)censoredCountryCodes
 | |
| {
 | |
|     // The set of countries for which domain fronting should be used.
 | |
|     //
 | |
|     // For each country, we should add the appropriate google domain,
 | |
|     // per:  https://en.wikipedia.org/wiki/List_of_Google_domains
 | |
|     //
 | |
|     // If we ever use any non-google domains for domain fronting,
 | |
|     // remember to:
 | |
|     //
 | |
|     // a) Add the appropriate pinning certificate(s) in
 | |
|     //    SignalServiceKit.podspec.
 | |
|     // b) Update reflectorHost accordingly.
 | |
|     return @{
 | |
|              // Egypt
 | |
|              @"+20": @"google.com.eg",
 | |
|              // Oman
 | |
|              @"+968": @"google.com.om",
 | |
|              // UAE
 | |
|              @"+971": @"google.ae",
 | |
|              };
 | |
| }
 | |
| 
 | |
| - (BOOL)isCensoredPhoneNumber:(NSString *)e164PhonNumber
 | |
| {
 | |
|     for (NSString *countryCode in self.censoredCountryCodes) {
 | |
|         if ([e164PhonNumber hasPrefix:countryCode]) {
 | |
|             return YES;
 | |
|         }
 | |
|     }
 | |
|     return NO;
 | |
| }
 | |
| 
 | |
| #pragma mark - Logging
 | |
| 
 | |
| + (NSString *)tag
 | |
| {
 | |
|     return [NSString stringWithFormat:@"[%@]", self.class];
 | |
| }
 | |
| 
 | |
| - (NSString *)tag
 | |
| {
 | |
|     return self.class.tag;
 | |
| }
 | |
| 
 | |
| @end
 | |
| 
 | |
| NS_ASSUME_NONNULL_END
 |