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

Merge branch 'pr52' into upstream_master

Adam Pritchard 11 лет назад
Родитель
Сommit
5223df0263

+ 3 - 3
AndroidApp/app/src/main/java/ca/psiphon/psibot/Psiphon.java

@@ -173,9 +173,9 @@ public class Psiphon extends Psi.PsiphonProvider.Stub {
     }
 
     private synchronized void parseMessage(String message) {
-        // TODO: this is based on temporary log line formats
-        final String socksProxy = "SOCKS-PROXY local SOCKS proxy running at address 127.0.0.1:";
-        final String httpProxy = "HTTP-PROXY local HTTP proxy running at address 127.0.0.1:";
+        // TODO: this is based on tentative log line formats
+        final String socksProxy = "SOCKS-PROXY-PORT ";
+        final String httpProxy = "HTTP-PROXY-PORT ";
         final String homePage = "HOMEPAGE ";
         final String tunnelStarted = "TUNNELS 1";
         int index;

+ 5 - 1
psiphon/config.go

@@ -33,7 +33,7 @@ type Config struct {
 	SponsorId                          string
 	RemoteServerListUrl                string
 	RemoteServerListSignaturePublicKey string
-	ClientVersion                      int
+	ClientVersion                      string
 	ClientPlatform                     string
 	TunnelWholeDevice                  int
 	EgressRegion                       string
@@ -89,6 +89,10 @@ func LoadConfig(configJson []byte) (*Config, error) {
 		}
 	}
 
+	if config.ClientVersion == "" {
+		config.ClientVersion = "0"
+	}
+
 	if config.ConnectionWorkerPoolSize == 0 {
 		config.ConnectionWorkerPoolSize = CONNECTION_WORKER_POOL_SIZE
 	}

+ 2 - 2
psiphon/httpProxy.go

@@ -66,7 +66,7 @@ func NewHttpProxy(config *Config, tunneler Tunneler) (proxy *HttpProxy, err erro
 	}
 	proxy.serveWaitGroup.Add(1)
 	go proxy.serve()
-	Notice(NOTICE_HTTP_PROXY, "local HTTP proxy running at address %s", proxy.listener.Addr().String())
+	Notice(NOTICE_HTTP_PROXY_PORT, "%d", proxy.listener.Addr().(*net.TCPAddr).Port)
 	return proxy, nil
 }
 
@@ -240,5 +240,5 @@ func (proxy *HttpProxy) serve() {
 			Notice(NOTICE_ALERT, "%s", ContextError(err))
 		}
 	}
-	Notice(NOTICE_HTTP_PROXY, "HTTP proxy stopped")
+	Notice(NOTICE_INFO, "HTTP proxy stopped")
 }

+ 10 - 10
psiphon/notice.go

@@ -25,16 +25,16 @@ import (
 )
 
 const (
-	NOTICE_INFO            = "INFO"
-	NOTICE_ALERT           = "ALERT"
-	NOTICE_VERSION         = "VERSION"
-	NOTICE_TUNNELS         = "TUNNELS"
-	NOTICE_SOCKS_PROXY     = "SOCKS-PROXY"
-	NOTICE_HTTP_PROXY      = "HTTP-PROXY"
-	NOTICE_UPGRADE         = "UPGRADE"
-	NOTICE_HOMEPAGE        = "HOMEPAGE"
-	NOTICE_PAGE_VIEW_REGEX = "PAGE-VIEW-REGEX"
-	NOTICE_HTTPS_REGEX     = "HTTPS-REGEX"
+	NOTICE_INFO             = "INFO"
+	NOTICE_ALERT            = "ALERT"
+	NOTICE_VERSION          = "VERSION"
+	NOTICE_TUNNELS          = "TUNNELS"
+	NOTICE_SOCKS_PROXY_PORT = "SOCKS-PROXY-PORT"
+	NOTICE_HTTP_PROXY_PORT  = "HTTP-PROXY-PORT"
+	NOTICE_UPGRADE          = "UPGRADE"
+	NOTICE_HOMEPAGE         = "HOMEPAGE"
+	NOTICE_PAGE_VIEW_REGEX  = "PAGE-VIEW-REGEX"
+	NOTICE_HTTPS_REGEX      = "HTTPS-REGEX"
 )
 
 func Notice(prefix, format string, args ...interface{}) {

+ 3 - 7
psiphon/serverApi.go

@@ -158,12 +158,8 @@ func (session *Session) doHandshakeRequest() error {
 	for _, homepage := range handshakeConfig.Homepages {
 		Notice(NOTICE_HOMEPAGE, homepage)
 	}
-	upgradeClientVersion, err := strconv.Atoi(handshakeConfig.UpgradeClientVersion)
-	if err != nil {
-		return ContextError(err)
-	}
-	if upgradeClientVersion > session.config.ClientVersion {
-		Notice(NOTICE_UPGRADE, "%d", upgradeClientVersion)
+	if handshakeConfig.UpgradeClientVersion != "" {
+		Notice(NOTICE_UPGRADE, "%s", handshakeConfig.UpgradeClientVersion)
 	}
 	session.tunnel.SetStatsRegexps(MakeRegexps(
 		handshakeConfig.PageViewRegexes,
@@ -232,7 +228,7 @@ func (session *Session) buildRequestUrl(path string, extraParams ...*ExtraParam)
 	requestUrl.WriteString("&sponsor_id=")
 	requestUrl.WriteString(session.config.SponsorId)
 	requestUrl.WriteString("&client_version=")
-	requestUrl.WriteString(strconv.Itoa(session.config.ClientVersion))
+	requestUrl.WriteString(session.config.ClientVersion)
 	// TODO: client_tunnel_core_version
 	requestUrl.WriteString("&relay_protocol=")
 	requestUrl.WriteString(session.tunnel.protocol)

+ 2 - 2
psiphon/socksProxy.go

@@ -56,7 +56,7 @@ func NewSocksProxy(config *Config, tunneler Tunneler) (proxy *SocksProxy, err er
 	}
 	proxy.serveWaitGroup.Add(1)
 	go proxy.serve()
-	Notice(NOTICE_SOCKS_PROXY, "local SOCKS proxy running at address %s", proxy.listener.Addr().String())
+	Notice(NOTICE_SOCKS_PROXY_PORT, "%d", proxy.listener.Addr().(*net.TCPAddr).Port)
 	return proxy, nil
 }
 
@@ -118,5 +118,5 @@ loop:
 			}
 		}()
 	}
-	Notice(NOTICE_SOCKS_PROXY, "SOCKS proxy stopped")
+	Notice(NOTICE_INFO, "SOCKS proxy stopped")
 }