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

added 'resetCache' field to NoticeClientVerificationRequired

Eugene Fryntov 9 лет назад
Родитель
Сommit
23f9f25e2c
2 измененных файлов с 10 добавлено и 5 удалено
  1. 4 3
      psiphon/notice.go
  2. 6 2
      psiphon/serverApi.go

+ 4 - 3
psiphon/notice.go

@@ -216,9 +216,10 @@ func NoticeHomepage(url string) {
 // NoticeClientVerificationRequired indicates that client verification is required, as
 // indicated by the handshake. The client should submit a client verification payload.
 // Empty nonce is allowed, if ttlSeconds is 0 the client should not send verification
-// payload to the server.
-func NoticeClientVerificationRequired(nonce string, ttlSeconds int) {
-	outputNotice("ClientVerificationRequired", 0, "nonce", nonce, "ttlSeconds", ttlSeconds)
+// payload to the server. If resetCache is set the client must always perform a new
+// verification and update its cache
+func NoticeClientVerificationRequired(nonce string, ttlSeconds int, resetCache bool) {
+	outputNotice("ClientVerificationRequired", 0, "nonce", nonce, "ttlSeconds", ttlSeconds, "resetCache", resetCache)
 }
 
 // NoticeClientRegion is the client's region, as determined by the server and

+ 6 - 2
psiphon/serverApi.go

@@ -183,6 +183,7 @@ func (serverContext *ServerContext) doHandshakeRequest() error {
 		ClientVerificationRequired    bool                `json:"client_verification_required"`
 		ClientVerificationServerNonce string              `json:"client_verification__server_nonce"`
 		ClientVerificationTTLSeconds  int                 `json:"client_verification_ttl_seconds"`
+		ClientVerificationResetCache  bool                `json:"client_verification_reset_cache"`
 	}
 	err := json.Unmarshal(response, &handshakeResponse)
 	if err != nil {
@@ -250,7 +251,8 @@ func (serverContext *ServerContext) doHandshakeRequest() error {
 
 	if handshakeResponse.ClientVerificationRequired {
 		NoticeClientVerificationRequired(handshakeResponse.ClientVerificationServerNonce,
-			handshakeResponse.ClientVerificationTTLSeconds)
+			handshakeResponse.ClientVerificationTTLSeconds,
+			handshakeResponse.ClientVerificationResetCache)
 	}
 
 	return nil
@@ -684,6 +686,7 @@ func (serverContext *ServerContext) DoClientVerificationRequest(
 	var clientVerificationResponse struct {
 		ClientVerificationServerNonce string `json:"client_verification_server_nonce"`
 		ClientVerificationTTLSeconds  int    `json:"client_verification_ttl_seconds"`
+		ClientVerificationResetCache  bool   `json:"client_verification_reset_cache"`
 	}
 
 	err = json.Unmarshal(response, &clientVerificationResponse)
@@ -694,7 +697,8 @@ func (serverContext *ServerContext) DoClientVerificationRequest(
 	if clientVerificationResponse.ClientVerificationTTLSeconds > 0 {
 		NoticeClientVerificationRequired(
 			clientVerificationResponse.ClientVerificationServerNonce,
-			clientVerificationResponse.ClientVerificationTTLSeconds)
+			clientVerificationResponse.ClientVerificationTTLSeconds,
+			clientVerificationResponse.ClientVerificationResetCache)
 	} else {
 		NoticeClientVerificationRequestCompleted(serverIP)
 	}