safesocket

package
v1.82.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: BSD-3-Clause Imports: 12 Imported by: 31

Documentation

Overview

Package safesocket creates either a Unix socket, if possible, or otherwise a localhost TCP connection.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenNotFound = errors.New("no token found")
	ErrNoTokenOnOS   = errors.New("no token on " + runtime.GOOS)
)

Functions

func ConnCloseRead

func ConnCloseRead(c net.Conn) error

ConnCloseRead calls c's CloseRead method. c is expected to be either a UnixConn or TCPConn as returned from this package.

func ConnCloseWrite

func ConnCloseWrite(c net.Conn) error

ConnCloseWrite calls c's CloseWrite method. c is expected to be either a UnixConn or TCPConn as returned from this package.

func Connect

func Connect(path string) (net.Conn, error)

Connect connects to tailscaled using a unix socket or named pipe. Deprecated: use ConnectContext instead.

func ConnectContext added in v1.68.0

func ConnectContext(ctx context.Context, path string) (net.Conn, error)

ConnectContext connects to tailscaled using a unix socket or named pipe.

func GOOSUsesPeerCreds added in v1.8.0

func GOOSUsesPeerCreds(goos string) bool

GOOSUsesPeerCreds is like PlatformUsesPeerCreds but takes a runtime.GOOS value instead of using the current one.

func InitListenerDarwin added in v1.82.0

func InitListenerDarwin(sharedDir string) (*net.Listener, error)

InitListenerDarwin initializes the listener for the CLI commands and localapi HTTP server and sets the port/token. This will override any credentials set explicitly via SetCredentials(). Calling this mulitple times has no effect. The listener and it's corresponding token/port is initialized only once.

func Listen

func Listen(path string) (net.Listener, error)

Listen returns a listener either on Unix socket path (on Unix), or the NamedPipe path (on Windows).

func LocalTCPPortAndToken added in v1.6.0

func LocalTCPPortAndToken() (port int, token string, err error)

LocalTCPPortAndToken returns the port number and auth token to connect to the local Tailscale daemon. It's currently only applicable on macOS when tailscaled is being run in the Mac Sandbox from the App Store version of Tailscale.

func PlatformUsesPeerCreds added in v1.6.0

func PlatformUsesPeerCreds() bool

PlatformUsesPeerCreds reports whether the current platform uses peer credentials to authenticate connections.

func SetCredentials added in v1.82.0

func SetCredentials(token string, port int)

SetCredentials sets an token and port used to authenticate safesocket generated by the NEPacketTunnelProvider tailscaled process. This is only used when running the CLI via Tailscale.app.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL