MCPcopy Create free account
hub / github.com/tailscale/tailcat / Server

Struct Server

tailcat.go:277–350  ·  view source on GitHub ↗

Server listens for clients over a WireGuard tunnel relayed through DERP. Incoming TCP connections are dispatched via [Server.OnTCP] (for connections addressed to the server itself) and [Server.OnTCPForward] (for connections the server relays to other addresses, acting as an exit node). The zero val

Source from the content-addressed store, hash-verified

275// configuration fields, then call [Server.Start], which picks
276// defaults for anything unset.
277type Server struct {
278 // Key is the server's node identity.
279 // If zero, Start generates a new ephemeral key.
280 Key key.NodePrivate
281
282 // Logf is the logger used for debug messages.
283 // If nil, log.Printf is used.
284 Logf logger.Logf
285
286 // Region, if non-nil, is the DERP region to use as the bootstrap
287 // relay, without fetching any DERP map.
288 Region *tailcfg.DERPRegion
289
290 // RegionID, if non-zero and Region is nil, is the ID of the DERP
291 // map region to use. If zero, the nearest region is picked based
292 // on latency at Start.
293 RegionID int
294
295 // DERPMapURL, if non-empty, is an alternate URL to fetch the DERP
296 // map from when Region is nil. If empty, [DefaultDERPMapURL] is
297 // used.
298 DERPMapURL string
299
300 // DERPMapCache, if non-nil, caches fetched DERP maps. If nil, a
301 // process-wide in-memory cache is used.
302 DERPMapCache DERPMapCache
303
304 // AllowedClients, if non-empty, restricts which client node keys
305 // may connect; all others are silently ignored. If empty, all
306 // clients are allowed. See [Server.AddAllowedClient] to add more
307 // at runtime.
308 AllowedClients []key.NodePublic
309
310 lb *locoBackend // non-nil once Start has been called
311
312 // AllowProxy, if non-nil, reports whether
313 // a TCP or UDP proxy is allowed for that target.
314 AllowProxy func(netip.AddrPort) bool
315
316 // OnTCP, if non-nil, specifies a func that returns a handler to handle
317 // incoming connections to the provided port. If nil or if it returns nil,
318 // then a RST is sent.
319 //
320 // This only applies to connections directly to the server node and not
321 // when being a subnet router. See OnTCPForward for relayed connections.
322 //
323 // It must be set before calling Start.
324 OnTCP func(port uint16) (handler func(net.Conn))
325
326 // OnTCPForward, if non-nil, specifies a func that returns a handler to handle
327 // incoming connections to the provided IP:port. If nil or if it returns nil,
328 // then a RST is sent.
329 //
330 // This only applies to connections relayed through the server and not to the server
331 // itself. See OnTCP for direct connections to the server.
332 //
333 // It must be set before calling Start. Setting it also widens the
334 // packet filter installed at Start to admit traffic to any

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected