token-validator: use version to distinguish TP2's VM from TP3
This commit is contained in:
parent
28d5aa8fca
commit
e1642827d1
1 changed files with 4 additions and 0 deletions
|
@ -98,19 +98,23 @@ func getWgTunnelInfo(w http.ResponseWriter, r *http.Request, ps httprouter.Param
|
||||||
}
|
}
|
||||||
|
|
||||||
var pt PubTunnel
|
var pt PubTunnel
|
||||||
|
var version int
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
if err := json.NewDecoder(r.Body).Decode(&pt); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&pt); err != nil {
|
||||||
http.Error(w, fmt.Sprintf("{errmsg:%q}", err), http.StatusBadRequest)
|
http.Error(w, fmt.Sprintf("{errmsg:%q}", err), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
version = 2
|
||||||
} else if pubkey := r.Header.Get("X-WG-PubKey"); pubkey != "" {
|
} else if pubkey := r.Header.Get("X-WG-PubKey"); pubkey != "" {
|
||||||
pt.PubKey, _ = base64.StdEncoding.DecodeString(pubkey)
|
pt.PubKey, _ = base64.StdEncoding.DecodeString(pubkey)
|
||||||
|
version = 3
|
||||||
} else {
|
} else {
|
||||||
http.Error(w, fmt.Sprintf("{errmsg:\"No public key given\"}", err), http.StatusBadRequest)
|
http.Error(w, fmt.Sprintf("{errmsg:\"No public key given\"}", err), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
token.PubKey = pt.PubKey
|
token.PubKey = pt.PubKey
|
||||||
|
token.Version = version
|
||||||
_, err = token.Update()
|
_, err = token.Update()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, fmt.Sprintf("{errmsg:%q}", err), http.StatusBadRequest)
|
http.Error(w, fmt.Sprintf("{errmsg:%q}", err), http.StatusBadRequest)
|
||||||
|
|
Reference in a new issue