Skip to content

Commit 4f2fb65

Browse files
authored
remove versions older than 1.56 (#2149)
* 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]>
1 parent 07b596d commit 4f2fb65

File tree

8 files changed

+52
-152
lines changed

8 files changed

+52
-152
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Next
44

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

hscontrol/mapper/mapper_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ func Test_fullMapResponse(t *testing.T) {
244244
PrimaryRoutes: []netip.Prefix{netip.MustParsePrefix("192.168.0.0/24")},
245245
LastSeen: &lastSeen,
246246
MachineAuthorized: true,
247-
Capabilities: []tailcfg.NodeCapability{
248-
tailcfg.CapabilityFileSharing,
249-
tailcfg.CapabilityAdmin,
250-
tailcfg.CapabilitySSH,
251-
tailcfg.NodeAttrDisableUPnP,
247+
248+
CapMap: tailcfg.NodeCapMap{
249+
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
250+
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
251+
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
252252
},
253253
}
254254

@@ -299,11 +299,11 @@ func Test_fullMapResponse(t *testing.T) {
299299
PrimaryRoutes: []netip.Prefix{},
300300
LastSeen: &lastSeen,
301301
MachineAuthorized: true,
302-
Capabilities: []tailcfg.NodeCapability{
303-
tailcfg.CapabilityFileSharing,
304-
tailcfg.CapabilityAdmin,
305-
tailcfg.CapabilitySSH,
306-
tailcfg.NodeAttrDisableUPnP,
302+
303+
CapMap: tailcfg.NodeCapMap{
304+
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
305+
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
306+
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
307307
},
308308
}
309309

hscontrol/mapper/tail.go

+6-24
Original file line numberDiff line numberDiff line change
@@ -114,32 +114,14 @@ func tailNode(
114114
Expired: node.IsExpired(),
115115
}
116116

117-
// - 74: 2023-09-18: Client understands NodeCapMap
118-
if capVer >= 74 {
119-
tNode.CapMap = tailcfg.NodeCapMap{
120-
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
121-
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
122-
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
123-
}
124-
125-
if cfg.RandomizeClientPort {
126-
tNode.CapMap[tailcfg.NodeAttrRandomizeClientPort] = []tailcfg.RawMessage{}
127-
}
128-
} else {
129-
tNode.Capabilities = []tailcfg.NodeCapability{
130-
tailcfg.CapabilityFileSharing,
131-
tailcfg.CapabilityAdmin,
132-
tailcfg.CapabilitySSH,
133-
}
134-
135-
if cfg.RandomizeClientPort {
136-
tNode.Capabilities = append(tNode.Capabilities, tailcfg.NodeAttrRandomizeClientPort)
137-
}
117+
tNode.CapMap = tailcfg.NodeCapMap{
118+
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
119+
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
120+
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
138121
}
139122

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

145127
if node.IsOnline == nil || !*node.IsOnline {

hscontrol/mapper/tail_test.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ func TestTailNode(t *testing.T) {
7272
Tags: []string{},
7373
PrimaryRoutes: []netip.Prefix{},
7474
MachineAuthorized: true,
75-
Capabilities: []tailcfg.NodeCapability{
76-
"https://tailscale.com/cap/file-sharing", "https://tailscale.com/cap/is-admin",
77-
"https://tailscale.com/cap/ssh", "debug-disable-upnp",
75+
76+
CapMap: tailcfg.NodeCapMap{
77+
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
78+
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
79+
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
7880
},
7981
},
8082
wantErr: false,
@@ -166,11 +168,10 @@ func TestTailNode(t *testing.T) {
166168
LastSeen: &lastSeen,
167169
MachineAuthorized: true,
168170

169-
Capabilities: []tailcfg.NodeCapability{
170-
tailcfg.CapabilityFileSharing,
171-
tailcfg.CapabilityAdmin,
172-
tailcfg.CapabilitySSH,
173-
tailcfg.NodeAttrDisableUPnP,
171+
CapMap: tailcfg.NodeCapMap{
172+
tailcfg.CapabilityFileSharing: []tailcfg.RawMessage{},
173+
tailcfg.CapabilityAdmin: []tailcfg.RawMessage{},
174+
tailcfg.CapabilitySSH: []tailcfg.RawMessage{},
174175
},
175176
},
176177
wantErr: false,

hscontrol/metrics.go

-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ var (
3737
Name: "mapresponse_updates_received_total",
3838
Help: "total count of mapresponse updates received on update channel",
3939
}, []string{"type"})
40-
mapResponseWriteUpdatesInStream = promauto.NewCounterVec(prometheus.CounterOpts{
41-
Namespace: prometheusNamespace,
42-
Name: "mapresponse_write_updates_in_stream_total",
43-
Help: "total count of writes that occurred in a stream session, pre-68 nodes",
44-
}, []string{"status"})
4540
mapResponseEndpointUpdates = promauto.NewCounterVec(prometheus.CounterOpts{
4641
Namespace: prometheusNamespace,
4742
Name: "mapresponse_endpoint_updates_total",

hscontrol/noise.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (ns *noiseServer) earlyNoise(protocolVersion int, writer io.Writer) error {
166166
}
167167

168168
const (
169-
MinimumCapVersion tailcfg.CapabilityVersion = 61
169+
MinimumCapVersion tailcfg.CapabilityVersion = 82
170170
)
171171

172172
// NoisePollNetMapHandler takes care of /machine/:id/map using the Noise protocol
@@ -182,15 +182,6 @@ func (ns *noiseServer) NoisePollNetMapHandler(
182182
writer http.ResponseWriter,
183183
req *http.Request,
184184
) {
185-
log.Trace().
186-
Str("handler", "NoisePollNetMap").
187-
Msg("PollNetMapHandler called")
188-
189-
log.Trace().
190-
Any("headers", req.Header).
191-
Caller().
192-
Msg("Headers")
193-
194185
body, _ := io.ReadAll(req.Body)
195186

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

198+
log.Trace().
199+
Caller().
200+
Str("handler", "NoisePollNetMap").
201+
Any("headers", req.Header).
202+
Str("node", mapRequest.Hostinfo.Hostname).
203+
Int("capver", int(mapRequest.Version)).
204+
Msg("PollNetMapHandler called")
205+
207206
// Reject unsupported versions
208207
if mapRequest.Version < MinimumCapVersion {
209208
log.Info().

hscontrol/poll.go

-81
Original file line numberDiff line numberDiff line change
@@ -214,21 +214,6 @@ func (m *mapSession) serveLongPoll() {
214214
m.infof("node has disconnected, mapSession: %p, chan: %p", m, m.ch)
215215
}()
216216

217-
// From version 68, all streaming requests can be treated as read only.
218-
// TODO: Remove when we drop support for 1.48
219-
if m.capVer < 68 {
220-
// Error has been handled/written to client in the func
221-
// return
222-
err := m.handleSaveNode()
223-
if err != nil {
224-
mapResponseWriteUpdatesInStream.WithLabelValues("error").Inc()
225-
226-
m.close()
227-
return
228-
}
229-
mapResponseWriteUpdatesInStream.WithLabelValues("ok").Inc()
230-
}
231-
232217
// Set up the client stream
233218
m.h.pollNetMapStreamWG.Add(1)
234219
defer m.h.pollNetMapStreamWG.Done()
@@ -549,72 +534,6 @@ func (m *mapSession) handleEndpointUpdate() {
549534
return
550535
}
551536

552-
// handleSaveNode saves node updates in the maprequest _streaming_
553-
// path and is mostly the same code as in handleEndpointUpdate.
554-
// It is not attempted to be deduplicated since it will go away
555-
// when we stop supporting older than 68 which removes updates
556-
// when the node is streaming.
557-
func (m *mapSession) handleSaveNode() error {
558-
m.tracef("saving node update from stream session")
559-
560-
change := m.node.PeerChangeFromMapRequest(m.req)
561-
562-
// A stream is being set up, the node is Online
563-
online := true
564-
change.Online = &online
565-
566-
m.node.ApplyPeerChange(&change)
567-
568-
sendUpdate, routesChanged := hostInfoChanged(m.node.Hostinfo, m.req.Hostinfo)
569-
m.node.Hostinfo = m.req.Hostinfo
570-
571-
// If there is no changes and nothing to save,
572-
// return early.
573-
if peerChangeEmpty(change) || !sendUpdate {
574-
return nil
575-
}
576-
577-
// Check if the Hostinfo of the node has changed.
578-
// If it has changed, check if there has been a change to
579-
// the routable IPs of the host and update update them in
580-
// the database. Then send a Changed update
581-
// (containing the whole node object) to peers to inform about
582-
// the route change.
583-
// If the hostinfo has changed, but not the routes, just update
584-
// hostinfo and let the function continue.
585-
if routesChanged {
586-
var err error
587-
_, err = m.h.db.SaveNodeRoutes(m.node)
588-
if err != nil {
589-
return err
590-
}
591-
592-
if m.h.ACLPolicy != nil {
593-
// update routes with peer information
594-
err := m.h.db.EnableAutoApprovedRoutes(m.h.ACLPolicy, m.node)
595-
if err != nil {
596-
return err
597-
}
598-
}
599-
}
600-
601-
if err := m.h.db.DB.Save(m.node).Error; err != nil {
602-
return err
603-
}
604-
605-
ctx := types.NotifyCtx(context.Background(), "pre-68-update-while-stream", m.node.Hostname)
606-
m.h.nodeNotifier.NotifyWithIgnore(
607-
ctx,
608-
types.StateUpdate{
609-
Type: types.StatePeerChanged,
610-
ChangeNodes: []types.NodeID{m.node.ID},
611-
Message: "called from handlePoll -> pre-68-update-while-stream",
612-
},
613-
m.node.ID)
614-
615-
return nil
616-
}
617-
618537
func (m *mapSession) handleReadOnlyRequest() {
619538
m.tracef("Client asked for a lite update, responding without peers")
620539

integration/scenario.go

+16-14
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,23 @@ var (
5353
tailscaleVersions2021 = map[string]bool{
5454
"head": true,
5555
"unstable": true,
56-
"1.70": true, // CapVer: not checked
57-
"1.68": true, // CapVer: not checked
58-
"1.66": true, // CapVer: not checked
59-
"1.64": true, // CapVer: not checked
60-
"1.62": true, // CapVer: not checked
61-
"1.60": true, // CapVer: not checked
62-
"1.58": true, // CapVer: not checked
63-
"1.56": true, // CapVer: 82
64-
"1.54": true, // CapVer: 79
65-
"1.52": true, // CapVer: 79
66-
"1.50": true, // CapVer: 74
67-
"1.48": true, // CapVer: 68
68-
"1.46": true, // CapVer: 65
56+
"1.74": true, // CapVer: 106
57+
"1.72": true, // CapVer: 104
58+
"1.70": true, // CapVer: 102
59+
"1.68": true, // CapVer: 97
60+
"1.66": true, // CapVer: 95
61+
"1.64": true, // CapVer: 90
62+
"1.62": true, // CapVer: 88
63+
"1.60": true, // CapVer: 87
64+
"1.58": true, // CapVer: 85
65+
"1.56": true, // Oldest supported version, CapVer: 82
66+
"1.54": false, // CapVer: 79
67+
"1.52": false, // CapVer: 79
68+
"1.50": false, // CapVer: 74
69+
"1.48": false, // CapVer: 68
70+
"1.46": false, // CapVer: 65
6971
"1.44": false, // CapVer: 63
70-
"1.42": false, // Oldest supported version, CapVer: 61
72+
"1.42": false, // CapVer: 61
7173
"1.40": false, // CapVer: 61
7274
"1.38": false, // CapVer: 58
7375
"1.36": false, // CapVer: 56

0 commit comments

Comments
 (0)