Jelajahi Sumber

Add distinct server_entry_source for OSLs

Rod Hynes 9 tahun lalu
induk
melakukan
fdfb2bca33

+ 6 - 4
psiphon/common/protocol/protocol.go

@@ -32,10 +32,11 @@ const (
 	TUNNEL_PROTOCOL_FRONTED_MEEK                  = "FRONTED-MEEK-OSSH"
 	TUNNEL_PROTOCOL_FRONTED_MEEK_HTTP             = "FRONTED-MEEK-HTTP-OSSH"
 
-	SERVER_ENTRY_SOURCE_EMBEDDED  = "EMBEDDED"
-	SERVER_ENTRY_SOURCE_REMOTE    = "REMOTE"
-	SERVER_ENTRY_SOURCE_DISCOVERY = "DISCOVERY"
-	SERVER_ENTRY_SOURCE_TARGET    = "TARGET"
+	SERVER_ENTRY_SOURCE_EMBEDDED   = "EMBEDDED"
+	SERVER_ENTRY_SOURCE_REMOTE     = "REMOTE"
+	SERVER_ENTRY_SOURCE_DISCOVERY  = "DISCOVERY"
+	SERVER_ENTRY_SOURCE_TARGET     = "TARGET"
+	SERVER_ENTRY_SOURCE_OBFUSCATED = "OBFUSCATED"
 
 	CAPABILITY_SSH_API_REQUESTS            = "ssh-api-requests"
 	CAPABILITY_UNTUNNELED_WEB_API_REQUESTS = "handshake"
@@ -69,6 +70,7 @@ var SupportedServerEntrySources = []string{
 	SERVER_ENTRY_SOURCE_REMOTE,
 	SERVER_ENTRY_SOURCE_DISCOVERY,
 	SERVER_ENTRY_SOURCE_TARGET,
+	SERVER_ENTRY_SOURCE_OBFUSCATED,
 }
 
 func TunnelProtocolUsesSSH(protocol string) bool {

+ 2 - 1
psiphon/common/protocol/serverEntry.go

@@ -153,7 +153,8 @@ func EncodeServerEntry(serverEntry *ServerEntry) (string, error) {
 //
 // The resulting ServerEntry.LocalSource is populated with serverEntrySource,
 // which should be one of SERVER_ENTRY_SOURCE_EMBEDDED, SERVER_ENTRY_SOURCE_REMOTE,
-// SERVER_ENTRY_SOURCE_DISCOVERY, SERVER_ENTRY_SOURCE_TARGET.
+// SERVER_ENTRY_SOURCE_DISCOVERY, SERVER_ENTRY_SOURCE_TARGET,
+// SERVER_ENTRY_SOURCE_OBFUSCATED.
 // ServerEntry.LocalTimestamp is populated with the provided timestamp, which
 // should be a RFC 3339 formatted string. These local fields are stored with the
 // server entry and reported to the server as stats (a coarse granularity timestamp

+ 4 - 4
psiphon/remoteServerList.go

@@ -76,7 +76,7 @@ func FetchCommonRemoteServerList(
 		return fmt.Errorf("failed to unpack common remote server list: %s", common.ContextError(err))
 	}
 
-	err = storeServerEntries(serverListPayload)
+	err = storeServerEntries(serverListPayload, protocol.SERVER_ENTRY_SOURCE_REMOTE)
 	if err != nil {
 		return fmt.Errorf("failed to store common remote server list: %s", common.ContextError(err))
 	}
@@ -263,7 +263,7 @@ func FetchObfuscatedServerLists(
 			continue
 		}
 
-		err = storeServerEntries(serverListPayload)
+		err = storeServerEntries(serverListPayload, protocol.SERVER_ENTRY_SOURCE_OBFUSCATED)
 		if err != nil {
 			failed = true
 			NoticeAlert("failed to store obfuscated server list file (%s): %s", hexID, common.ContextError(err))
@@ -389,12 +389,12 @@ func unpackRemoteServerListFile(
 	return payload, nil
 }
 
-func storeServerEntries(serverList string) error {
+func storeServerEntries(serverList, serverEntrySource string) error {
 
 	serverEntries, err := protocol.DecodeAndValidateServerEntryList(
 		serverList,
 		common.GetCurrentTimestamp(),
-		protocol.SERVER_ENTRY_SOURCE_REMOTE)
+		serverEntrySource)
 	if err != nil {
 		return common.ContextError(err)
 	}