Browse Source

Fix: don't clobber local server entry info

Rod Hynes 6 years ago
parent
commit
cce4cbe34d
1 changed files with 15 additions and 0 deletions
  1. 15 0
      psiphon/serverApi.go

+ 15 - 0
psiphon/serverApi.go

@@ -125,7 +125,9 @@ func (serverContext *ServerContext) doHandshakeRequest(
 	//
 	// The server entry will be included in handshakeResponse.EncodedServerList,
 	// along side discovery servers.
+	requestedMissingSignature := false
 	if !serverContext.tunnel.dialParams.ServerEntry.HasSignature() {
+		requestedMissingSignature = true
 		params["missing_server_entry_signature"] =
 			serverContext.tunnel.dialParams.ServerEntry.Tag
 	}
@@ -222,6 +224,19 @@ func (serverContext *ServerContext) doHandshakeRequest(
 			return common.ContextError(err)
 		}
 
+		// Retain the original timestamp and source in the requestedMissingSignature
+		// case, as this server entry was not discovered here.
+		//
+		// Limitation: there is a transient edge case where
+		// requestedMissingSignature will be set for a discovery server entry that
+		// _is_ also discovered here.
+		if requestedMissingSignature &&
+			serverEntryFields.GetIPAddress() == serverContext.tunnel.dialParams.ServerEntry.IpAddress {
+
+			serverEntryFields.SetLocalTimestamp(serverContext.tunnel.dialParams.ServerEntry.LocalTimestamp)
+			serverEntryFields.SetLocalSource(serverContext.tunnel.dialParams.ServerEntry.LocalSource)
+		}
+
 		err = protocol.ValidateServerEntryFields(serverEntryFields)
 		if err != nil {
 			// Skip this entry and continue with the next one