Movatterモバイル変換


[0]ホーム

URL:


Alert GO-2024-3228: Coder vulnerable to post-auth URL redirection to untrusted site ('Open Redirect') in github.com/coder/coder
Notice  The highest tagged major version isv2.

tailnet

package
v0.27.3Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2023 License:AGPL-3.0Imports:52Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

View Source
const (WorkspaceAgentSSHPort             = 1WorkspaceAgentReconnectingPTYPort = 2WorkspaceAgentSpeedtestPort       = 3)
View Source
const LoggerName = "coord"
View Source
const WriteTimeout =time.Second * 5

WriteTimeout is the amount of time we wait to write a node update to a connection before we declare it hung.It is exported so that tests can use it.

Variables

View Source
var ErrMultiAgentClosed =xerrors.New("multiagent is closed")
View Source
var ErrWouldBlock =xerrors.New("would block")

Functions

funcCoordinatorHTTPDebugadded inv0.15.3

func CoordinatorHTTPDebug(agentSocketsMap map[uuid.UUID]Queue,agentToConnectionSocketsMap map[uuid.UUID]map[uuid.UUID]Queue,agentNameCache *lru.Cache[uuid.UUID,string],) func(whttp.ResponseWriter, _ *http.Request)

funcIP

func IP()netip.Addr

IP generates a random IP with a static service prefix.

funcIPFromUUIDadded inv0.26.2

func IPFromUUID(uiduuid.UUID)netip.Addr

IP generates a new IP from a UUID.

funcLogger

func Logger(loggerslog.Logger)tslogger.Logf

Logger converts the Tailscale logging function to use slog.

funcNewDERPMap

func NewDERPMap(ctxcontext.Context, region *tailcfg.DERPRegion, stunAddrs []string, remoteURL, localPathstring, disableSTUNbool) (*tailcfg.DERPMap,error)

NewDERPMap constructs a DERPMap from a set of STUN addresses and optionally a remoteURL to fetch a mapping from e.g.https://controlplane.tailscale.com/derpmap/default.

funcServeCoordinator

func ServeCoordinator(connnet.Conn, updateNodes func(node []*Node)error) (func(node *Node), <-chanerror)

ServeCoordinator matches the RW structure of a coordinator to exchange node messages.

funcWithWebsocketSupportadded inv0.18.1

func WithWebsocketSupport(s *derp.Server, basehttp.Handler) (http.Handler, func())

WithWebsocketSupport returns an http.Handler that upgradesconnections to the "derp" subprotocol to WebSockets andpasses them to the DERP server.Taken from:https://github.com/tailscale/tailscale/blob/e3211ff88ba85435f70984cf67d9b353f3d650d8/cmd/derper/websocket.go#L21

Types

typeConn

type Conn struct {// contains filtered or unexported fields}

Conn is an actively listening Wireguard connection.

funcNewConn

func NewConn(options *Options) (conn *Conn, errerror)

NewConn constructs a new Wireguard server that will accept connections from the addresses provided.

func (*Conn)Addressesadded inv0.26.2

func (c *Conn) Addresses() []netip.Prefix

func (*Conn)AwaitReachableadded inv0.12.7

func (c *Conn) AwaitReachable(ctxcontext.Context, ipnetip.Addr)bool

AwaitReachable pings the provided IP continually until theaddress is reachable. It's the callers responsibility to providea timeout, otherwise this function will block forever.

func (*Conn)BlockEndpointsadded inv0.25.0

func (c *Conn) BlockEndpoints()bool

BlockEndpoints returns whether or not P2P is blocked.

func (*Conn)Close

func (c *Conn) Close()error

Close shuts down the Wireguard connection.

func (*Conn)Closed

func (c *Conn) Closed() <-chan struct{}

Closed is a channel that ends when the connection hasbeen closed.

func (*Conn)DERPMapadded inv0.13.5

func (c *Conn) DERPMap() *tailcfg.DERPMap

DERPMap returns the currently set DERP mapping.

func (*Conn)DialContextTCP

func (c *Conn) DialContextTCP(ctxcontext.Context, ippnetip.AddrPort) (*gonet.TCPConn,error)

func (*Conn)DialContextUDP

func (c *Conn) DialContextUDP(ctxcontext.Context, ippnetip.AddrPort) (*gonet.UDPConn,error)

func (*Conn)Listen

func (c *Conn) Listen(network, addrstring) (net.Listener,error)

Listen listens for connections only on the Tailscale network.

func (*Conn)MagicsockServeHTTPDebugadded inv0.23.1

func (c *Conn) MagicsockServeHTTPDebug(whttp.ResponseWriter, r *http.Request)

func (*Conn)Nodeadded inv0.13.5

func (c *Conn) Node() *Node

Node returns the last node that was sent to the node callback.

func (*Conn)NodeAddressesadded inv0.18.1

func (c *Conn) NodeAddresses(publicKeykey.NodePublic) ([]netip.Prefix,bool)

NodeAddresses returns the addresses of a node from the NetworkMap.

func (*Conn)Ping

Ping sends a Disco ping to the Wireguard engine.The bool returned is true if the ping was performed P2P.

func (*Conn)SetAddressesadded inv0.26.2

func (c *Conn) SetAddresses(ips []netip.Prefix)error

func (*Conn)SetBlockEndpointsadded inv0.25.0

func (c *Conn) SetBlockEndpoints(blockEndpointsbool)

SetBlockEndpoints sets whether or not to block P2P endpoints. This settingwill only apply to new peers.

func (*Conn)SetConnStatsCallbackadded inv0.17.2

func (c *Conn) SetConnStatsCallback(maxPeriodtime.Duration, maxConnsint, dump func(start, endtime.Time, virtual, physical map[netlogtype.Connection]netlogtype.Counts))

SetConnStatsCallback sets a callback to be called after maxPeriod ormaxConns, whichever comes first. Multiple calls overwrites the callback.

func (*Conn)SetDERPMap

func (c *Conn) SetDERPMap(derpMap *tailcfg.DERPMap)

SetDERPMap updates the DERPMap of a connection.

func (*Conn)SetDERPRegionDialeradded inv0.20.0

func (c *Conn) SetDERPRegionDialer(dialer func(ctxcontext.Context, region *tailcfg.DERPRegion)net.Conn)

SetDERPRegionDialer updates the dialer to use for connecting to DERP regions.

func (*Conn)SetNodeCallback

func (c *Conn) SetNodeCallback(callback func(node *Node))

func (*Conn)Status

func (c *Conn) Status() *ipnstate.Status

Status returns the current ipnstate of a connection.

func (*Conn)UpdateNodes

func (c *Conn) UpdateNodes(nodes []*Node, replacePeersbool)error

UpdateNodes connects with a set of peers. This can be constantly updated,and peers will continually be reconnected as necessary. If replacePeers istrue, all peers will be removed before adding the new ones.

typeCoordinator

type Coordinator interface {// ServeHTTPDebug serves a debug webpage that shows the internal state of// the coordinator.ServeHTTPDebug(whttp.ResponseWriter, r *http.Request)// Node returns an in-memory node by ID.Node(iduuid.UUID) *Node// ServeClient accepts a WebSocket connection that wants to connect to an agent// with the specified ID.ServeClient(connnet.Conn, iduuid.UUID, agentuuid.UUID)error// ServeAgent accepts a WebSocket connection to an agent that listens to// incoming connections and publishes node updates.// Name is just used for debug information. It can be left blank.ServeAgent(connnet.Conn, iduuid.UUID, namestring)error// Close closes the coordinator.Close()errorServeMultiAgent(iduuid.UUID)MultiAgentConn}

Coordinator exchanges nodes with agents to establish connections.┌──────────────────┐ ┌────────────────────┐ ┌───────────────────┐ ┌──────────────────┐│tailnet.Coordinate├──►│tailnet.AcceptClient│◄─►│tailnet.AcceptAgent│◄──┤tailnet.Coordinate│└──────────────────┘ └────────────────────┘ └───────────────────┘ └──────────────────┘Coordinators have different guarantees for HA support.

funcNewCoordinator

func NewCoordinator(loggerslog.Logger)Coordinator

NewCoordinator constructs a new in-memory connection coordinator. Thiscoordinator is incompatible with multiple Coder replicas as all node data isin-memory.

typeMultiAgentadded inv0.26.2

type MultiAgent struct {IDuuid.UUIDAgentIsLegacyFunc func(agentIDuuid.UUID)boolOnSubscribe       func(enqQueue, agentuuid.UUID) (*Node,error)OnUnsubscribe     func(enqQueue, agentuuid.UUID)errorOnNodeUpdate      func(iduuid.UUID, node *Node)errorOnRemove          func(iduuid.UUID)// contains filtered or unexported fields}

func (*MultiAgent)AgentIsLegacyadded inv0.26.2

func (m *MultiAgent) AgentIsLegacy(agentIDuuid.UUID)bool

func (*MultiAgent)Closeadded inv0.26.2

func (m *MultiAgent) Close()error

func (*MultiAgent)CoordinatorCloseadded inv0.26.2

func (m *MultiAgent) CoordinatorClose()error

func (*MultiAgent)Enqueueadded inv0.26.2

func (m *MultiAgent) Enqueue(nodes []*Node)error

func (*MultiAgent)Initadded inv0.26.2

func (m *MultiAgent) Init() *MultiAgent

func (*MultiAgent)IsClosedadded inv0.26.2

func (m *MultiAgent) IsClosed()bool

func (*MultiAgent)Nameadded inv0.26.2

func (m *MultiAgent) Name()string

func (*MultiAgent)NextUpdateadded inv0.26.2

func (m *MultiAgent) NextUpdate(ctxcontext.Context) ([]*Node,bool)

func (*MultiAgent)Overwritesadded inv0.26.2

func (m *MultiAgent) Overwrites()int64

func (*MultiAgent)Statsadded inv0.26.2

func (m *MultiAgent) Stats() (startint64, lastWriteint64)

func (*MultiAgent)SubscribeAgentadded inv0.26.2

func (m *MultiAgent) SubscribeAgent(agentIDuuid.UUID)error

func (*MultiAgent)UniqueIDadded inv0.26.2

func (m *MultiAgent) UniqueID()uuid.UUID

func (*MultiAgent)UnsubscribeAgentadded inv0.26.2

func (m *MultiAgent) UnsubscribeAgent(agentIDuuid.UUID)error

func (*MultiAgent)UpdateSelfadded inv0.26.2

func (m *MultiAgent) UpdateSelf(node *Node)error

typeMultiAgentConnadded inv0.26.2

type MultiAgentConn interface {UpdateSelf(node *Node)errorSubscribeAgent(agentIDuuid.UUID)errorUnsubscribeAgent(agentIDuuid.UUID)errorNextUpdate(ctxcontext.Context) ([]*Node,bool)AgentIsLegacy(agentIDuuid.UUID)boolClose()errorIsClosed()bool}

typeNode

type Node struct {// ID is used to identify the connection.IDtailcfg.NodeID `json:"id"`// AsOf is the time the node was created.AsOftime.Time `json:"as_of"`// Key is the Wireguard public key of the node.Keykey.NodePublic `json:"key"`// DiscoKey is used for discovery messages over DERP to establish// peer-to-peer connections.DiscoKeykey.DiscoPublic `json:"disco"`// PreferredDERP is the DERP server that peered connections should meet at// to establish.PreferredDERPint `json:"preferred_derp"`// DERPLatency is the latency in seconds to each DERP server.DERPLatency map[string]float64 `json:"derp_latency"`// DERPForcedWebsocket contains a mapping of DERP regions to// error messages that caused the connection to be forced to// use WebSockets. We don't use WebSockets by default because// they are less performant.DERPForcedWebsocket map[int]string `json:"derp_forced_websockets"`// Addresses are the IP address ranges this connection exposes.Addresses []netip.Prefix `json:"addresses"`// AllowedIPs specify what addresses can dial the connection. We allow all// by default.AllowedIPs []netip.Prefix `json:"allowed_ips"`// Endpoints are ip:port combinations that can be used to establish// peer-to-peer connections.Endpoints []string `json:"endpoints"`}

Node represents a node in the network.

typeOptions

type Options struct {Addresses  []netip.PrefixDERPMap    *tailcfg.DERPMapDERPHeader *http.Header// BlockEndpoints specifies whether P2P endpoints are blocked.// If so, only DERPs can establish connections.BlockEndpointsboolLoggerslog.LoggerListenPortuint16}

typeQueueadded inv0.26.2

type Queue interface {UniqueID()uuid.UUIDEnqueue(n []*Node)errorName()stringStats() (start, lastWriteint64)Overwrites()int64// CoordinatorClose is used by the coordinator when closing a Queue. It// should skip removing itself from the coordinator.CoordinatorClose()errorClose()error}

typeTrackedConnadded inv0.15.3

type TrackedConn struct {// contains filtered or unexported fields}

funcNewTrackedConnadded inv0.23.1

func NewTrackedConn(ctxcontext.Context, cancel func(), connnet.Conn, iduuid.UUID, loggerslog.Logger, overwritesint64) *TrackedConn

func (*TrackedConn)Closeadded inv0.23.1

func (t *TrackedConn) Close()error

Close the connection and cancel the context for reading node updates from the queue

func (*TrackedConn)CoordinatorCloseadded inv0.26.2

func (t *TrackedConn) CoordinatorClose()error

func (*TrackedConn)Enqueueadded inv0.23.1

func (t *TrackedConn) Enqueue(n []*Node) (errerror)

func (*TrackedConn)Nameadded inv0.15.3

func (t *TrackedConn) Name()string

func (*TrackedConn)Overwritesadded inv0.15.3

func (t *TrackedConn) Overwrites()int64

func (*TrackedConn)SendUpdatesadded inv0.23.1

func (t *TrackedConn) SendUpdates()

SendUpdates reads node updates and writes them to the connection. Ends when writes hit an error or context iscanceled.

func (*TrackedConn)Statsadded inv0.26.2

func (t *TrackedConn) Stats() (start, lastWriteint64)

func (*TrackedConn)UniqueIDadded inv0.26.2

func (t *TrackedConn) UniqueID()uuid.UUID

Source Files

View all Source files

Directories

PathSynopsis
Package tailnettest is a generated GoMock package.
Package tailnettest is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp