summaryrefslogtreecommitdiffhomepage
path: root/ipn/ipn_clone.go
blob: 94aebefdfd73d86bfc13e34e2d82f3914693fd35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause

// Code generated by tailscale.com/cmd/cloner; DO NOT EDIT.

package ipn

import (
	"maps"
	"net/netip"

	"tailscale.com/drive"
	"tailscale.com/tailcfg"
	"tailscale.com/types/opt"
	"tailscale.com/types/persist"
	"tailscale.com/types/preftype"
	"tailscale.com/types/ptr"
)

// Clone makes a deep copy of LoginProfile.
// The result aliases no memory with the original.
func (src *LoginProfile) Clone() *LoginProfile {
	if src == nil {
		return nil
	}
	dst := new(LoginProfile)
	*dst = *src
	return dst
}

// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _LoginProfileCloneNeedsRegeneration = LoginProfile(struct {
	ID             ProfileID
	Name           string
	NetworkProfile NetworkProfile
	Key            StateKey
	UserProfile    tailcfg.UserProfile
	NodeID         tailcfg.StableNodeID
	LocalUserID    WindowsUserID
	ControlURL     string
}{})

// Clone makes a deep copy of Prefs.
// The result aliases no memory with the original.
func (src *Prefs) Clone() *Prefs {
	if src == nil {
		return nil
	}
	dst := new(Prefs)
	*dst = *src
	dst.AdvertiseTags = append(src.AdvertiseTags[:0:0], src.AdvertiseTags...)
	dst.AdvertiseRoutes = append(src.AdvertiseRoutes[:0:0], src.AdvertiseRoutes...)
	dst.AdvertiseServices = append(src.AdvertiseServices[:0:0], src.AdvertiseServices...)
	if src.DriveShares != nil {
		dst.DriveShares = make([]*drive.Share, len(src.DriveShares))
		for i := range dst.DriveShares {
			if src.DriveShares[i] == nil {
				dst.DriveShares[i] = nil
			} else {
				dst.DriveShares[i] = src.DriveShares[i].Clone()
			}
		}
	}
	if dst.RelayServerPort != nil {
		dst.RelayServerPort = ptr.To(*src.RelayServerPort)
	}
	dst.RelayServerStaticEndpoints = append(src.RelayServerStaticEndpoints[:0:0], src.RelayServerStaticEndpoints...)
	dst.Persist = src.Persist.Clone()
	return dst
}

// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _PrefsCloneNeedsRegeneration = Prefs(struct {
	ControlURL                 string
	RouteAll                   bool
	ExitNodeID                 tailcfg.StableNodeID
	ExitNodeIP                 netip.Addr
	AutoExitNode               ExitNodeExpression
	InternalExitNodePrior      tailcfg.StableNodeID
	ExitNodeAllowLANAccess     bool
	CorpDNS                    bool
	RunSSH                     bool
	RunWebClient               bool
	WantRunning                bool
	LoggedOut                  bool
	ShieldsUp                  bool
	AdvertiseTags              []string
	Hostname                   string
	NotepadURLs                bool
	ForceDaemon                bool
	Egg                        bool
	AdvertiseRoutes            []netip.Prefix
	AdvertiseServices          []string
	Sync                       opt.Bool
	NoSNAT                     bool
	NoStatefulFiltering        opt.Bool
	NetfilterMode              preftype.NetfilterMode
	OperatorUser               string
	ProfileName                string
	AutoUpdate                 AutoUpdatePrefs
	AppConnector               AppConnectorPrefs
	PostureChecking            bool
	NetfilterKind              string
	DriveShares                []*drive.Share
	RelayServerPort            *uint16
	RelayServerStaticEndpoints []netip.AddrPort
	AllowSingleHosts           marshalAsTrueInJSON
	Persist                    *persist.Persist
}{})

// Clone makes a deep copy of ServeConfig.
// The result aliases no memory with the original.
func (src *ServeConfig) Clone() *ServeConfig {
	if src == nil {
		return nil
	}
	dst := new(ServeConfig)
	*dst = *src
	if dst.TCP != nil {
		dst.TCP = map[uint16]*TCPPortHandler{}
		for k, v := range src.TCP {
			if v == nil {
				dst.TCP[k] = nil
			} else {
				dst.TCP[k] = ptr.To(*v)
			}
		}
	}
	if dst.Web != nil {
		dst.Web = map[HostPort]*WebServerConfig{}
		for k, v := range src.Web {
			if v == nil {
				dst.Web[k] = nil
			} else {
				dst.Web[k] = v.Clone()
			}
		}
	}
	if dst.Services != nil {
		dst.Services = map[tailcfg.ServiceName]*ServiceConfig{}
		for k, v := range src.Services {
			if v == nil {
				dst.Services[k] = nil
			} else {
				dst.Services[k] = v.Clone()
			}
		}
	}
	dst.AllowFunnel = maps.Clone(src.AllowFunnel)
	if dst.Foreground != nil {
		dst.Foreground = map[string]*ServeConfig{}
		for k, v := range src.Foreground {
			if v == nil {
				dst.Foreground[k] = nil
			} else {
				dst.Foreground[k] = v.Clone()
			}
		}
	}
	return dst
}

// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _ServeConfigCloneNeedsRegeneration = ServeConfig(struct {
	TCP         map[uint16]*TCPPortHandler
	Web         map[HostPort]*WebServerConfig
	Services    map[tailcfg.ServiceName]*ServiceConfig
	AllowFunnel map[HostPort]bool
	Foreground  map[string]*ServeConfig
	ETag        string
}{})

// Clone makes a deep copy of ServiceConfig.
// The result aliases no memory with the original.
func (src *ServiceConfig) Clone() *ServiceConfig {
	if src == nil {
		return nil
	}
	dst := new(ServiceConfig)
	*dst = *src
	if dst.TCP != nil {
		dst.TCP = map[uint16]*TCPPortHandler{}
		for k, v := range src.TCP {
			if v == nil {
				dst.TCP[k] = nil
			} else {
				dst.TCP[k] = ptr.To(*v)
			}
		}
	}
	if dst.Web != nil {
		dst.Web = map[HostPort]*WebServerConfig{}
		for k, v := range src.Web {
			if v == nil {
				dst.Web[k] = nil
			} else {
				dst.Web[k] = v.Clone()
			}
		}
	}
	return dst
}

// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _ServiceConfigCloneNeedsRegeneration = ServiceConfig(struct {
	TCP map[uint16]*TCPPortHandler
	Web map[HostPort]*WebServerConfig
	Tun bool
}{})

// Clone makes a deep copy of TCPPortHandler.
// The result aliases no memory with the original.
func (src *TCPPortHandler) Clone() *TCPPortHandler {
	if src == nil {
		return nil
	}
	dst := new(TCPPortHandler)
	*dst = *src
	return dst
}

// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _TCPPortHandlerCloneNeedsRegeneration = TCPPortHandler(struct {
	HTTPS         bool
	HTTP          bool
	TCPForward    string
	TerminateTLS  string
	ProxyProtocol int
}{})

// Clone makes a deep copy of HTTPHandler.
// The result aliases no memory with the original.
func (src *HTTPHandler) Clone() *HTTPHandler {
	if src == nil {
		return nil
	}
	dst := new(HTTPHandler)
	*dst = *src
	dst.AcceptAppCaps = append(src.AcceptAppCaps[:0:0], src.AcceptAppCaps...)
	return dst
}

// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _HTTPHandlerCloneNeedsRegeneration = HTTPHandler(struct {
	Path          string
	Proxy         string
	Text          string
	AcceptAppCaps []tailcfg.PeerCapability
	Redirect      string
}{})

// Clone makes a deep copy of WebServerConfig.
// The result aliases no memory with the original.
func (src *WebServerConfig) Clone() *WebServerConfig {
	if src == nil {
		return nil
	}
	dst := new(WebServerConfig)
	*dst = *src
	if dst.Handlers != nil {
		dst.Handlers = map[string]*HTTPHandler{}
		for k, v := range src.Handlers {
			if v == nil {
				dst.Handlers[k] = nil
			} else {
				dst.Handlers[k] = v.Clone()
			}
		}
	}
	return dst
}

// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _WebServerConfigCloneNeedsRegeneration = WebServerConfig(struct {
	Handlers map[string]*HTTPHandler
}{})