Kaynağa Gözat

- RSL/OSL config params no longer required
- Fix: api.go compile error
- Fix: reference to ReportSLOKs

Rod Hynes 9 yıl önce
ebeveyn
işleme
c9d00ff904

+ 15 - 13
psiphon/config.go

@@ -508,24 +508,26 @@ func LoadConfig(configJson []byte) (*Config, error) {
 
 	if !config.DisableRemoteServerListFetcher {
 
-		if config.RemoteServerListSignaturePublicKey == "" {
-			return nil, common.ContextError(errors.New("missing RemoteServerListSignaturePublicKey"))
-		}
+		if config.RemoteServerListUrl != "" {
 
-		if config.RemoteServerListUrl == "" {
-			return nil, common.ContextError(errors.New("missing RemoteServerListUrl"))
-		}
+			if config.RemoteServerListSignaturePublicKey == "" {
+				return nil, common.ContextError(errors.New("missing RemoteServerListSignaturePublicKey"))
+			}
 
-		if config.RemoteServerListDownloadFilename == "" {
-			return nil, common.ContextError(errors.New("missing RemoteServerListDownloadFilename"))
+			if config.RemoteServerListDownloadFilename == "" {
+				return nil, common.ContextError(errors.New("missing RemoteServerListDownloadFilename"))
+			}
 		}
 
-		if config.ObfuscatedServerListRootURL == "" {
-			return nil, common.ContextError(errors.New("missing ObfuscatedServerListRootURL"))
-		}
+		if config.ObfuscatedServerListRootURL != "" {
+
+			if config.RemoteServerListSignaturePublicKey == "" {
+				return nil, common.ContextError(errors.New("missing RemoteServerListSignaturePublicKey"))
+			}
 
-		if config.ObfuscatedServerListDownloadDirectory == "" {
-			return nil, common.ContextError(errors.New("missing ObfuscatedServerListDownloadDirectory"))
+			if config.ObfuscatedServerListDownloadDirectory == "" {
+				return nil, common.ContextError(errors.New("missing ObfuscatedServerListDownloadDirectory"))
+			}
 		}
 	}
 

+ 0 - 4
psiphon/config_test.go

@@ -59,10 +59,6 @@ func (suite *ConfigTestSuite) SetupSuite() {
 			suite.nonRequiredFields = append(suite.nonRequiredFields, k)
 		}
 	}
-
-	// Force skipping required RSL fields
-	obj["DisableRemoteServerListFetcher"] = true
-	suite.confStubBlob, _ = json.Marshal(obj)
 }
 
 func TestConfigTestSuite(t *testing.T) {

+ 18 - 14
psiphon/controller.go

@@ -189,21 +189,25 @@ func (controller *Controller) Run(shutdownBroadcast <-chan struct{}) {
 		retryPeriod := time.Duration(
 			*controller.config.FetchRemoteServerListRetryPeriodSeconds) * time.Second
 
-		controller.runWaitGroup.Add(1)
-		go controller.remoteServerListFetcher(
-			"common",
-			FetchCommonRemoteServerList,
-			controller.signalFetchCommonRemoteServerList,
-			retryPeriod,
-			FETCH_REMOTE_SERVER_LIST_STALE_PERIOD)
+		if controller.config.RemoteServerListUrl != "" {
+			controller.runWaitGroup.Add(1)
+			go controller.remoteServerListFetcher(
+				"common",
+				FetchCommonRemoteServerList,
+				controller.signalFetchCommonRemoteServerList,
+				retryPeriod,
+				FETCH_REMOTE_SERVER_LIST_STALE_PERIOD)
+		}
 
-		controller.runWaitGroup.Add(1)
-		go controller.remoteServerListFetcher(
-			"obfuscated",
-			FetchObfuscatedServerLists,
-			controller.signalFetchObfuscatedServerLists,
-			retryPeriod,
-			FETCH_REMOTE_SERVER_LIST_STALE_PERIOD)
+		if controller.config.ObfuscatedServerListRootURL != "" {
+			controller.runWaitGroup.Add(1)
+			go controller.remoteServerListFetcher(
+				"obfuscated",
+				FetchObfuscatedServerLists,
+				controller.signalFetchObfuscatedServerLists,
+				retryPeriod,
+				FETCH_REMOTE_SERVER_LIST_STALE_PERIOD)
+		}
 	}
 
 	if controller.config.UpgradeDownloadUrl != "" &&

+ 4 - 4
psiphon/server/api.go

@@ -385,24 +385,24 @@ func statusAPIRequestHandler(
 		if err != nil {
 			return nil, common.ContextError(err)
 		}
-		for _, tunnelStat := range tunnelStats {
+		for _, remoteServerListStat := range remoteServerListStats {
 
 			remoteServerListFields := getRequestLogFields(
 				support, "remote_server_list", geoIPData, params, statusRequestParams)
 
-			clientDownloadTimestamp, err := getStringRequestParam(tunnelStat, "client_download_timestamp")
+			clientDownloadTimestamp, err := getStringRequestParam(remoteServerListStat, "client_download_timestamp")
 			if err != nil {
 				return nil, common.ContextError(err)
 			}
 			remoteServerListFields["client_download_timestamp"] = clientDownloadTimestamp
 
-			url, err := getStringRequestParam(tunnelStat, "url")
+			url, err := getStringRequestParam(remoteServerListStat, "url")
 			if err != nil {
 				return nil, common.ContextError(err)
 			}
 			remoteServerListFields["url"] = url
 
-			etag, err := getStringRequestParam(tunnelStat, "etag")
+			etag, err := getStringRequestParam(remoteServerListStat, "etag")
 			if err != nil {
 				return nil, common.ContextError(err)
 			}

+ 1 - 1
psiphon/server/server_test.go

@@ -343,7 +343,7 @@ func runServer(t *testing.T, runConfig *runServerConfig) {
 	clientConfig.TunnelProtocol = runConfig.tunnelProtocol
 	clientConfig.LocalSocksProxyPort = localSOCKSProxyPort
 	clientConfig.LocalHttpProxyPort = localHTTPProxyPort
-	clientConfig.ReportSLOKs = true
+	clientConfig.EmitSLOKs = true
 
 	clientConfig.DataStoreDirectory = testDataDirName
 	err = psiphon.InitDataStore(clientConfig)