mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
ipn: add AllowVersionSkew bool to Notify & Message
For "tailscale status" on macOS (from separately downloaded cmd/tailscale binary against App Store IPNExtension). (This isn't all of it, but I've had this sitting around uncommitted.)
This commit is contained in:
parent
fde384b359
commit
529e2cb31a
@ -48,6 +48,8 @@ func runStatus(ctx context.Context, args []string) error {
|
|||||||
c, bc, ctx, cancel := connect(ctx)
|
c, bc, ctx, cancel := connect(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
bc.AllowVersionSkew = true
|
||||||
|
|
||||||
ch := make(chan *ipnstate.Status, 1)
|
ch := make(chan *ipnstate.Status, 1)
|
||||||
bc.SetNotifyCallback(func(n ipn.Notify) {
|
bc.SetNotifyCallback(func(n ipn.Notify) {
|
||||||
if n.ErrMessage != nil {
|
if n.ErrMessage != nil {
|
||||||
|
@ -35,9 +35,16 @@ type FakeExpireAfterArgs struct {
|
|||||||
// Command is a command message that is JSON encoded and sent by a
|
// Command is a command message that is JSON encoded and sent by a
|
||||||
// frontend to a backend.
|
// frontend to a backend.
|
||||||
type Command struct {
|
type Command struct {
|
||||||
_ structs.Incomparable
|
_ structs.Incomparable
|
||||||
|
|
||||||
|
// Version is the binary version of the frontend (the client).
|
||||||
Version string
|
Version string
|
||||||
|
|
||||||
|
// AllowVersionSkew controls whether it's permitted for the
|
||||||
|
// client and server to have a different version. The default
|
||||||
|
// (false) means to be strict.
|
||||||
|
AllowVersionSkew bool
|
||||||
|
|
||||||
// Exactly one of the following must be non-nil.
|
// Exactly one of the following must be non-nil.
|
||||||
Quit *NoArgs
|
Quit *NoArgs
|
||||||
Start *StartArgs
|
Start *StartArgs
|
||||||
@ -92,7 +99,7 @@ func (bs *BackendServer) GotFakeCommand(cmd *Command) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bs *BackendServer) GotCommand(cmd *Command) error {
|
func (bs *BackendServer) GotCommand(cmd *Command) error {
|
||||||
if cmd.Version != version.LONG {
|
if cmd.Version != version.LONG && !cmd.AllowVersionSkew {
|
||||||
vs := fmt.Sprintf("GotCommand: Version mismatch! frontend=%#v backend=%#v",
|
vs := fmt.Sprintf("GotCommand: Version mismatch! frontend=%#v backend=%#v",
|
||||||
cmd.Version, version.LONG)
|
cmd.Version, version.LONG)
|
||||||
bs.logf("%s", vs)
|
bs.logf("%s", vs)
|
||||||
@ -147,6 +154,10 @@ type BackendClient struct {
|
|||||||
logf logger.Logf
|
logf logger.Logf
|
||||||
sendCommandMsg func(jsonb []byte)
|
sendCommandMsg func(jsonb []byte)
|
||||||
notify func(Notify)
|
notify func(Notify)
|
||||||
|
|
||||||
|
// AllowVersionSkew controls whether to allow mismatched
|
||||||
|
// frontend & backend versions.
|
||||||
|
AllowVersionSkew bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBackendClient(logf logger.Logf, sendCommandMsg func(jsonb []byte)) *BackendClient {
|
func NewBackendClient(logf logger.Logf, sendCommandMsg func(jsonb []byte)) *BackendClient {
|
||||||
@ -165,7 +176,7 @@ func (bc *BackendClient) GotNotifyMsg(b []byte) {
|
|||||||
if err := json.Unmarshal(b, &n); err != nil {
|
if err := json.Unmarshal(b, &n); err != nil {
|
||||||
log.Fatalf("BackendClient.Notify: cannot decode message (length=%d)\n%#v", len(b), string(b))
|
log.Fatalf("BackendClient.Notify: cannot decode message (length=%d)\n%#v", len(b), string(b))
|
||||||
}
|
}
|
||||||
if n.Version != version.LONG {
|
if n.Version != version.LONG && !bc.AllowVersionSkew {
|
||||||
vs := fmt.Sprintf("GotNotify: Version mismatch! frontend=%#v backend=%#v",
|
vs := fmt.Sprintf("GotNotify: Version mismatch! frontend=%#v backend=%#v",
|
||||||
version.LONG, n.Version)
|
version.LONG, n.Version)
|
||||||
bc.logf("%s", vs)
|
bc.logf("%s", vs)
|
||||||
@ -223,7 +234,7 @@ func (bc *BackendClient) RequestEngineStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bc *BackendClient) RequestStatus() {
|
func (bc *BackendClient) RequestStatus() {
|
||||||
bc.send(Command{RequestStatus: &NoArgs{}})
|
bc.send(Command{AllowVersionSkew: true, RequestStatus: &NoArgs{}})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bc *BackendClient) FakeExpireAfter(x time.Duration) {
|
func (bc *BackendClient) FakeExpireAfter(x time.Duration) {
|
||||||
|
Loading…
Reference in New Issue
Block a user