Просмотр исходного кода

Reset proxy ports to 0 when proxies torn down

Adam Pritchard 8 лет назад
Родитель
Сommit
dbe4e2c5c6

+ 2 - 2
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.h

@@ -325,14 +325,14 @@ typedef NS_ENUM(NSInteger, PsiphonConnectionState)
 - (PsiphonConnectionState)getConnectionState;
 
 /*!
- Provides the port number of the local SOCKS proxy. Only valid when currently connected.
+ Provides the port number of the local SOCKS proxy. Only valid when currently connected (will return 0 otherwise).
  @return  The current local SOCKS proxy port number.
  Swift: @code open func getLocalSocksProxyPort() -> Int @endcode
  */
 -(NSInteger)getLocalSocksProxyPort;
 
 /*!
- Provides the port number of the local HTTP proxy. Only valid when currently connected.
+ Provides the port number of the local HTTP proxy. Only valid when currently connected (will return 0 otherwise).
  @return  The current local HTTP proxy port number.
  Swift: @code open func getLocalHttpProxyPort() -> Int @endcode
  */

+ 5 - 0
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m

@@ -47,6 +47,8 @@
 
 - (id)init {
     atomic_init(&connectionState, PsiphonConnectionStateDisconnected);
+    atomic_init(&localSocksProxyPort, 0);
+    atomic_init(&localHttpProxyPort, 0);
     reachability = [Reachability reachabilityForInternetConnection];
 
     return self;
@@ -172,6 +174,9 @@
         
         [self logMessage: @"Psiphon library stopped"];
 
+        atomic_store(&localSocksProxyPort, 0);
+        atomic_store(&localHttpProxyPort, 0);
+
         [self changeConnectionStateTo:PsiphonConnectionStateDisconnected evenIfSameState:NO];
     }
 }