Documentation
¶
Overview ¶
Package hostbridge pkg/hostbridge/auth.go c3-vis-wasm
Package hostbridge pkg/hostbridge/client.go c3-vis-wasm
Package hostbridge pkg/hostbridge/proto.go c3-vis-wasm
Package hostbridge pkg/hostbridge/run.go c3-vis-wasm
Package hostbridge pkg/hostbridge/server.go c3-vis-wasm
Package hostbridge lends a browser visor the host's sockets. The tab dials the bridge over one WebSocket, both ends run yamux on it, and each stream asks the bridge to dial, listen on TCP, or bind UDP on the tab's behalf.
The bridge keeps no keys or state of its own, so the same small binary serves any visor that knows its token.
Package hostbridge pkg/hostbridge/tun_linux.go c3-vis-wasm
Package hostbridge pkg/hostbridge/ws.go c3-vis-wasm
Index ¶
- Constants
- func DefaultTokenFile() string
- func LoadToken(path string) (string, error)
- func NewToken() (string, error)
- func PairFile(tokenFile string) string
- func ResolveToken(token, tokenFile string) (string, error)
- func Run(addr string, cfg Config, ready func(url string)) error
- func SplitOrigins(s string) []string
- func Unpair(pairFile string) error
- type Client
- func (c *Client) Close() error
- func (c *Client) Dial(network, addr string) (net.Conn, error)
- func (c *Client) DialContext(ctx context.Context, network, addr string) (net.Conn, error)
- func (c *Client) Done() <-chan struct{}
- func (c *Client) Listen(network, addr string) (net.Listener, error)
- func (c *Client) ListenPacket(network, addr string) (net.PacketConn, error)
- func (c *Client) Net(ctx context.Context, cmd string, args ...string) (string, error)
- func (c *Client) TUN(ctx context.Context) (*TUN, error)
- type Config
- type Pairing
- type Server
- type TUN
Constants ¶
const DefaultAddr = "127.0.0.1:3438"
DefaultAddr is where the bridge listens for the tab.
const DefaultOrigin = "https://skywire.dev"
DefaultOrigin is the browser visor's page.
Variables ¶
This section is empty.
Functions ¶
func DefaultTokenFile ¶
func DefaultTokenFile() string
DefaultTokenFile is where the bridge keeps its token, so the URL a visor saved still works after the bridge restarts. It is empty when the OS has no config directory.
func PairFile ¶
PairFile is where the bridge keeps its paired visor: beside tokenFile, resolved as ResolveToken does, or in memory only when that is "none".
func ResolveToken ¶
ResolveToken returns token when set, else the one kept in tokenFile. An empty tokenFile means DefaultTokenFile, and "none" a new token each run.
func Run ¶
Run listens on addr and serves tabs until the listener fails. ready gets the URL the tab connects to, token included.
func SplitOrigins ¶
SplitOrigins parses a comma separated origin list.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the tab end of the bridge. Its Dial, Listen and ListenPacket return the standard net types, backed by sockets on the bridge's host.
func NewClient ¶
NewClient runs the tab end over conn, the tab's WebSocket to the bridge, after pairing with it as p. When the bridge pairs for the first time it sets p.Secret, which the visor keeps for later sessions.
func (*Client) DialContext ¶
DialContext is Dial bounded by ctx.
func (*Client) Done ¶
func (c *Client) Done() <-chan struct{}
Done is closed when the session to the bridge ends.
func (*Client) Listen ¶
Listen listens on TCP on the bridge's host. Closing the listener closes the host socket.
func (*Client) ListenPacket ¶
func (c *Client) ListenPacket(network, addr string) (net.PacketConn, error)
ListenPacket binds UDP on the bridge's host.
type Config ¶
type Config struct {
// Token is the secret the tab puts in the WebSocket path.
Token string
// Origins are the pages allowed to connect. "*" allows any.
Origins []string
// PairFile keeps the visor the bridge paired with, so a restart serves
// only that visor. Empty keeps the pairing in memory.
PairFile string
Logf func(format string, args ...any)
}
Config is the bridge's access policy.
type Pairing ¶
type Pairing struct {
// PK is the visor's public key, in hex.
PK string
// Secret is the one the bridge gave this visor when they paired. Empty
// asks to pair, which only an unpaired bridge accepts. NewClient sets it
// when the bridge pairs.
Secret string
}
Pairing is how a visor identifies itself to the bridge.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the host end of the bridge.