Documentation
¶
Index ¶
- func SplitBasicAuth(auth string) (user, pass string, ok bool)
- type Assignment
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect(ctx context.Context, version string) (string, error)
- func (c *Client) Run(ctx context.Context) error
- func (c *Client) RunWithReconnect(ctx context.Context, version string, onConnect func(subdomain string), ...)
- func (c *Client) Subdomain() string
- type Registration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SplitBasicAuth ¶
SplitBasicAuth splits a "user:pass" string.
Types ¶
type Assignment ¶
type Assignment struct {
Subdomain string `json:"subdomain,omitempty"`
Error string `json:"error,omitempty"`
}
Assignment is the JSON response from the relay after registration.
type Client ¶
type Client struct {
RelayAddr string
Handler http.Handler // handler to serve requests (e.g. StaticServer)
BasicAuth string // "user:pass" or "" for no auth
// contains filtered or unexported fields
}
Client tunnels a local HTTP server through a relay to expose it publicly.
func New ¶
New creates a new share client. handler is the http.Handler to serve (typically a StaticServer). basicAuth should be "user:pass" or empty for no auth.
func (*Client) Connect ¶
Connect dials the relay, registers, and establishes a yamux session. Returns the assigned subdomain on success.
func (*Client) Run ¶
Run serves HTTP requests from the relay using the configured Handler. It creates an http.Server backed by a yamux-based net.Listener. Blocks until the context is cancelled or the session dies.
func (*Client) RunWithReconnect ¶
func (c *Client) RunWithReconnect(ctx context.Context, version string, onConnect func(subdomain string), onDisconnect func(err error))
RunWithReconnect runs the client with automatic reconnection on failure. It calls onConnect with the subdomain each time a connection is established, and onDisconnect when the connection drops.
type Registration ¶
type Registration struct {
Version string `json:"version"`
BasicAuth string `json:"basic_auth,omitempty"`
}
Registration is the JSON message sent to the relay on connect.