client/tailscale,ipn/localapi: warn on tailscale/tailscaled version skew

Fixes #1905

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/2687/head
Brad Fitzpatrick 3 years ago
parent 8269a23758
commit faa891c1f2

@ -17,6 +17,7 @@ import (
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
"os"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -28,6 +29,7 @@ import (
"tailscale.com/paths" "tailscale.com/paths"
"tailscale.com/safesocket" "tailscale.com/safesocket"
"tailscale.com/tailcfg" "tailscale.com/tailcfg"
"tailscale.com/version"
) )
// TailscaledSocket is the tailscaled Unix socket. // TailscaledSocket is the tailscaled Unix socket.
@ -94,6 +96,9 @@ func send(ctx context.Context, method, path string, wantStatus int, body io.Read
return nil, err return nil, err
} }
defer res.Body.Close() defer res.Body.Close()
if server := res.Header.Get("Tailscale-Version"); server != version.Long {
fmt.Fprintf(os.Stderr, "Warning: client version %q != tailscaled server version %q\n", version.Long, server)
}
slurp, err := ioutil.ReadAll(res.Body) slurp, err := ioutil.ReadAll(res.Body)
if err != nil { if err != nil {
return nil, err return nil, err

@ -30,6 +30,7 @@ import (
"tailscale.com/ipn/ipnstate" "tailscale.com/ipn/ipnstate"
"tailscale.com/tailcfg" "tailscale.com/tailcfg"
"tailscale.com/types/logger" "tailscale.com/types/logger"
"tailscale.com/version"
) )
func randHex(n int) string { func randHex(n int) string {
@ -64,6 +65,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, "server has no local backend", http.StatusInternalServerError) http.Error(w, "server has no local backend", http.StatusInternalServerError)
return return
} }
w.Header().Set("Tailscale-Version", version.Long)
if h.RequiredPassword != "" { if h.RequiredPassword != "" {
_, pass, ok := r.BasicAuth() _, pass, ok := r.BasicAuth()
if !ok { if !ok {

Loading…
Cancel
Save