Skip to content

Commit

Permalink
remove versions older than 1.56 (juanfont#2149)
Browse files Browse the repository at this point in the history
* remove versions older than 1.56

Signed-off-by: Kristoffer Dalby <[email protected]>

* remove code no longer needed for new clients

Signed-off-by: Kristoffer Dalby <[email protected]>

* update changelog

Signed-off-by: Kristoffer Dalby <[email protected]>

---------

Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Sep 30, 2024
1 parent 67acc61 commit 65cd082
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 152 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Next

- Remove versions older than 1.56 [#2149](https://github.com/juanfont/headscale/pull/2149)
- Clean up old code required by old versions
- Improved compatibilty of built-in DERP server with clients connecting over WebSocket.
- Allow nodes to use SSH agent forwarding [#2145](https://github.com/juanfont/headscale/pull/2145)

Expand Down
20 changes: 10 additions & 10 deletions hscontrol/mapper/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ func Test_fullMapResponse(t *testing.T) {
PrimaryRoutes: []netip.Prefix{netip.MustParsePrefix("192.168.0.0/24")},
LastSeen: &lastSeen,
MachineAuthorized: true,
Capabilities: []tailcfg.NodeCapability{
tailcfg.CapabilityFileSharing,
tailcfg.CapabilityAdmin,
tailcfg.CapabilitySSH,
tailcfg.NodeAttrDisableUPnP,

CapMap: tailcfg.NodeCapMap{
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
},
}

Expand Down Expand Up @@ -299,11 +299,11 @@ func Test_fullMapResponse(t *testing.T) {
PrimaryRoutes: []netip.Prefix{},
LastSeen: &lastSeen,
MachineAuthorized: true,
Capabilities: []tailcfg.NodeCapability{
tailcfg.CapabilityFileSharing,
tailcfg.CapabilityAdmin,
tailcfg.CapabilitySSH,
tailcfg.NodeAttrDisableUPnP,

CapMap: tailcfg.NodeCapMap{
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
},
}

Expand Down
30 changes: 6 additions & 24 deletions hscontrol/mapper/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,32 +114,14 @@ func tailNode(
Expired: node.IsExpired(),
}

// - 74: 2023-09-18: Client understands NodeCapMap
if capVer >= 74 {
tNode.CapMap = tailcfg.NodeCapMap{
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
}

if cfg.RandomizeClientPort {
tNode.CapMap[tailcfg.NodeAttrRandomizeClientPort] = []tailcfg.RawMessage{}
}
} else {
tNode.Capabilities = []tailcfg.NodeCapability{
tailcfg.CapabilityFileSharing,
tailcfg.CapabilityAdmin,
tailcfg.CapabilitySSH,
}

if cfg.RandomizeClientPort {
tNode.Capabilities = append(tNode.Capabilities, tailcfg.NodeAttrRandomizeClientPort)
}
tNode.CapMap = tailcfg.NodeCapMap{
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
}

// - 72: 2023-08-23: TS-2023-006 UPnP issue fixed; UPnP can now be used again
if capVer < 72 {
tNode.Capabilities = append(tNode.Capabilities, tailcfg.NodeAttrDisableUPnP)
if cfg.RandomizeClientPort {
tNode.CapMap[tailcfg.NodeAttrRandomizeClientPort] = []tailcfg.RawMessage{}
}

if node.IsOnline == nil || !*node.IsOnline {
Expand Down
17 changes: 9 additions & 8 deletions hscontrol/mapper/tail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ func TestTailNode(t *testing.T) {
Tags: []string{},
PrimaryRoutes: []netip.Prefix{},
MachineAuthorized: true,
Capabilities: []tailcfg.NodeCapability{
"https://tailscale.com/cap/file-sharing", "https://tailscale.com/cap/is-admin",
"https://tailscale.com/cap/ssh", "debug-disable-upnp",

CapMap: tailcfg.NodeCapMap{
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
},
},
wantErr: false,
Expand Down Expand Up @@ -166,11 +168,10 @@ func TestTailNode(t *testing.T) {
LastSeen: &lastSeen,
MachineAuthorized: true,

Capabilities: []tailcfg.NodeCapability{
tailcfg.CapabilityFileSharing,
tailcfg.CapabilityAdmin,
tailcfg.CapabilitySSH,
tailcfg.NodeAttrDisableUPnP,
CapMap: tailcfg.NodeCapMap{
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
},
},
wantErr: false,
Expand Down
5 changes: 0 additions & 5 deletions hscontrol/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ var (
Name: "mapresponse_updates_received_total",
Help: "total count of mapresponse updates received on update channel",
}, []string{"type"})
mapResponseWriteUpdatesInStream = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: prometheusNamespace,
Name: "mapresponse_write_updates_in_stream_total",
Help: "total count of writes that occurred in a stream session, pre-68 nodes",
}, []string{"status"})
mapResponseEndpointUpdates = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: prometheusNamespace,
Name: "mapresponse_endpoint_updates_total",
Expand Down
19 changes: 9 additions & 10 deletions hscontrol/noise.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (ns *noiseServer) earlyNoise(protocolVersion int, writer io.Writer) error {
}

const (
MinimumCapVersion tailcfg.CapabilityVersion = 61
MinimumCapVersion tailcfg.CapabilityVersion = 82
)

// NoisePollNetMapHandler takes care of /machine/:id/map using the Noise protocol
Expand All @@ -182,15 +182,6 @@ func (ns *noiseServer) NoisePollNetMapHandler(
writer http.ResponseWriter,
req *http.Request,
) {
log.Trace().
Str("handler", "NoisePollNetMap").
Msg("PollNetMapHandler called")

log.Trace().
Any("headers", req.Header).
Caller().
Msg("Headers")

body, _ := io.ReadAll(req.Body)

mapRequest := tailcfg.MapRequest{}
Expand All @@ -204,6 +195,14 @@ func (ns *noiseServer) NoisePollNetMapHandler(
return
}

log.Trace().
Caller().
Str("handler", "NoisePollNetMap").
Any("headers", req.Header).
Str("node", mapRequest.Hostinfo.Hostname).
Int("capver", int(mapRequest.Version)).
Msg("PollNetMapHandler called")

// Reject unsupported versions
if mapRequest.Version < MinimumCapVersion {
log.Info().
Expand Down
81 changes: 0 additions & 81 deletions hscontrol/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,6 @@ func (m *mapSession) serveLongPoll() {
m.infof("node has disconnected, mapSession: %p, chan: %p", m, m.ch)
}()

// From version 68, all streaming requests can be treated as read only.
// TODO: Remove when we drop support for 1.48
if m.capVer < 68 {
// Error has been handled/written to client in the func
// return
err := m.handleSaveNode()
if err != nil {
mapResponseWriteUpdatesInStream.WithLabelValues("error").Inc()

m.close()
return
}
mapResponseWriteUpdatesInStream.WithLabelValues("ok").Inc()
}

// Set up the client stream
m.h.pollNetMapStreamWG.Add(1)
defer m.h.pollNetMapStreamWG.Done()
Expand Down Expand Up @@ -550,72 +535,6 @@ func (m *mapSession) handleEndpointUpdate() {
return
}

// handleSaveNode saves node updates in the maprequest _streaming_
// path and is mostly the same code as in handleEndpointUpdate.
// It is not attempted to be deduplicated since it will go away
// when we stop supporting older than 68 which removes updates
// when the node is streaming.
func (m *mapSession) handleSaveNode() error {
m.tracef("saving node update from stream session")

change := m.node.PeerChangeFromMapRequest(m.req)

// A stream is being set up, the node is Online
online := true
change.Online = &online

m.node.ApplyPeerChange(&change)

sendUpdate, routesChanged := hostInfoChanged(m.node.Hostinfo, m.req.Hostinfo)
m.node.Hostinfo = m.req.Hostinfo

// If there is no changes and nothing to save,
// return early.
if peerChangeEmpty(change) || !sendUpdate {
return nil
}

// Check if the Hostinfo of the node has changed.
// If it has changed, check if there has been a change to
// the routable IPs of the host and update update them in
// the database. Then send a Changed update
// (containing the whole node object) to peers to inform about
// the route change.
// If the hostinfo has changed, but not the routes, just update
// hostinfo and let the function continue.
if routesChanged {
var err error
_, err = m.h.db.SaveNodeRoutes(m.node)
if err != nil {
return err
}

if m.h.ACLPolicy != nil {
// update routes with peer information
err := m.h.db.EnableAutoApprovedRoutes(m.h.ACLPolicy, m.node)
if err != nil {
return err
}
}
}

if err := m.h.db.DB.Save(m.node).Error; err != nil {
return err
}

ctx := types.NotifyCtx(context.Background(), "pre-68-update-while-stream", m.node.Hostname)
m.h.nodeNotifier.NotifyWithIgnore(
ctx,
types.StateUpdate{
Type: types.StatePeerChanged,
ChangeNodes: []types.NodeID{m.node.ID},
Message: "called from handlePoll -> pre-68-update-while-stream",
},
m.node.ID)

return nil
}

func (m *mapSession) handleReadOnlyRequest() {
m.tracef("Client asked for a lite update, responding without peers")

Expand Down
30 changes: 16 additions & 14 deletions integration/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,23 @@ var (
tailscaleVersions2021 = map[string]bool{
"head": true,
"unstable": true,
"1.70": true, // CapVer: not checked
"1.68": true, // CapVer: not checked
"1.66": true, // CapVer: not checked
"1.64": true, // CapVer: not checked
"1.62": true, // CapVer: not checked
"1.60": true, // CapVer: not checked
"1.58": true, // CapVer: not checked
"1.56": true, // CapVer: 82
"1.54": true, // CapVer: 79
"1.52": true, // CapVer: 79
"1.50": true, // CapVer: 74
"1.48": true, // CapVer: 68
"1.46": true, // CapVer: 65
"1.74": true, // CapVer: 106
"1.72": true, // CapVer: 104
"1.70": true, // CapVer: 102
"1.68": true, // CapVer: 97
"1.66": true, // CapVer: 95
"1.64": true, // CapVer: 90
"1.62": true, // CapVer: 88
"1.60": true, // CapVer: 87
"1.58": true, // CapVer: 85
"1.56": true, // Oldest supported version, CapVer: 82
"1.54": false, // CapVer: 79
"1.52": false, // CapVer: 79
"1.50": false, // CapVer: 74
"1.48": false, // CapVer: 68
"1.46": false, // CapVer: 65
"1.44": false, // CapVer: 63
"1.42": false, // Oldest supported version, CapVer: 61
"1.42": false, // CapVer: 61
"1.40": false, // CapVer: 61
"1.38": false, // CapVer: 58
"1.36": false, // CapVer: 56
Expand Down

0 comments on commit 65cd082

Please sign in to comment.