From e1642827d101964d00784afc2c88c6641a67f82f Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Thu, 2 Apr 2020 16:08:27 +0200 Subject: [PATCH] token-validator: use version to distinguish TP2's VM from TP3 --- token-validator/wg.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/token-validator/wg.go b/token-validator/wg.go index b48b646..544dd81 100644 --- a/token-validator/wg.go +++ b/token-validator/wg.go @@ -98,19 +98,23 @@ func getWgTunnelInfo(w http.ResponseWriter, r *http.Request, ps httprouter.Param } var pt PubTunnel + var version int if r.Method == "POST" { if err := json.NewDecoder(r.Body).Decode(&pt); err != nil { http.Error(w, fmt.Sprintf("{errmsg:%q}", err), http.StatusBadRequest) return } + version = 2 } else if pubkey := r.Header.Get("X-WG-PubKey"); pubkey != "" { pt.PubKey, _ = base64.StdEncoding.DecodeString(pubkey) + version = 3 } else { http.Error(w, fmt.Sprintf("{errmsg:\"No public key given\"}", err), http.StatusBadRequest) return } token.PubKey = pt.PubKey + token.Version = version _, err = token.Update() if err != nil { http.Error(w, fmt.Sprintf("{errmsg:%q}", err), http.StatusBadRequest)