Documentation ¶
Overview ¶
Package safesocket creates either a Unix socket, if possible, or otherwise a localhost TCP connection.
Index ¶
- Constants
- Variables
- func ConnCloseRead(c net.Conn) error
- func ConnCloseWrite(c net.Conn) error
- func Connect(s *ConnectionStrategy) (net.Conn, error)
- func GOOSUsesPeerCreds(goos string) bool
- func Listen(path string, port uint16) (_ net.Listener, gotPort uint16, _ error)
- func LocalTCPPortAndToken() (port int, token string, err error)
- func PlatformUsesPeerCreds() bool
- type ConnectionStrategy
Constants ¶
const WindowsLocalPort = 41112
WindowsLocalPort is the default localhost TCP port used by safesocket on Windows.
Variables ¶
Functions ¶
func ConnCloseRead ¶
ConnCloseRead calls c's CloseRead method. c is expected to be either a UnixConn or TCPConn as returned from this package.
func ConnCloseWrite ¶
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(s *ConnectionStrategy) (net.Conn, error)
Connect connects to tailscaled using s
func GOOSUsesPeerCreds ¶ added in v1.8.0
GOOSUsesPeerCreds is like PlatformUsesPeerCreds but takes a runtime.GOOS value instead of using the current one.
func Listen ¶
Listen returns a listener either on Unix socket path (on Unix), or the localhost port (on Windows). If port is 0, the returned gotPort says which port was selected on Windows.
func LocalTCPPortAndToken ¶ added in v1.6.0
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.
Types ¶
type ConnectionStrategy ¶ added in v1.20.0
type ConnectionStrategy struct {
// contains filtered or unexported fields
}
A ConnectionStrategy is a plan for how to connect to tailscaled or equivalent (e.g. IPNExtension on macOS).
func DefaultConnectionStrategy ¶ added in v1.20.0
func DefaultConnectionStrategy(path string) *ConnectionStrategy
DefaultConnectionStrategy returns a default connection strategy. The default strategy is to attempt to connect in as many ways as possible. It uses path as the unix socket path, when applicable, and defaults to WindowsLocalPort for the TCP port when applicable. It falls back to auto-discovery across sandbox boundaries on macOS. TODO: maybe take no arguments, since path is irrelevant on Windows? Discussion in PR 3499.
func ExactPath ¶ added in v1.20.0
func ExactPath(path string) *ConnectionStrategy
ExactPath returns a connection strategy that only attempts to connect via path.
func (*ConnectionStrategy) UseFallback ¶ added in v1.20.0
func (s *ConnectionStrategy) UseFallback(b bool)
UseFallback modifies s to set whether it should fall back to connecting to the macOS GUI's tailscaled if the Unix socket path wasn't reachable.
func (*ConnectionStrategy) UsePort ¶ added in v1.20.0
func (s *ConnectionStrategy) UsePort(port uint16)
UsePort modifies s to use port for the TCP port when applicable. UsePort is only applicable on Windows, and only then when not using the default for Windows.