Documentation
¶
Index ¶
- Constants
- Variables
- type Authenticator
- type Client
- type Delimited
- func (d *Delimited) BufferedData() ([]byte, error)
- func (d *Delimited) Close() error
- func (d *Delimited) RawConn() net.Conn
- func (d *Delimited) RecvFrame(timeout bool) ([]byte, bool, error)
- func (d *Delimited) RecvServer(timeout bool) (ServerMessage, bool, error)
- func (d *Delimited) SendJSON(v interface{}) error
- type ServerMessage
- type ServerMessageKind
Constants ¶
const ( // ControlPort is the TCP port used by the bore control channel. ControlPort = 7835 // MaxFrameLength caps the length of a JSON frame (excluding the trailing null byte). MaxFrameLength = 256 // NetworkTimeout defines the timeout for dialing and initial protocol steps. NetworkTimeout = 3 * time.Second )
Variables ¶
var ( // ErrUnexpectedEOF indicates that the server closed the connection unexpectedly. ErrUnexpectedEOF = errors.New("unexpected EOF from server") // ErrUnexpectedHandshake indicates an unexpected message during authentication. ErrUnexpectedHandshake = errors.New("unexpected handshake message") )
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator replies to server challenges using a shared secret.
func NewAuthenticator ¶
func NewAuthenticator(secret string) *Authenticator
NewAuthenticator constructs an authenticator from a secret string.
func (*Authenticator) Answer ¶
func (a *Authenticator) Answer(challenge uuid.UUID) string
Answer creates the HMAC tag for a challenge UUID.
func (*Authenticator) ClientHandshake ¶
func (a *Authenticator) ClientHandshake(conn *Delimited) error
ClientHandshake answers the server's challenge when authentication is enabled.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client maintains a control connection to a bore server and proxies incoming connections.
func NewClient ¶
func NewClient(localHost string, localPort uint16, to string, desiredPort uint16, secret string) (*Client, error)
NewClient connects to the remote server and performs the initial handshake.
func (*Client) ActiveProxies ¶
ActiveProxies returns the number of currently active proxy connections.
func (*Client) LastHeartbeat ¶
LastHeartbeat returns the last heartbeat time and whether one has been observed.
func (*Client) Listen ¶
Listen waits for new connection notifications from the server and proxies them.
func (*Client) RemotePort ¶
RemotePort returns the public port assigned by the server.
type Delimited ¶
type Delimited struct {
// contains filtered or unexported fields
}
Delimited wraps a TCP connection with null-delimited JSON framing.
func NewDelimited ¶
NewDelimited constructs a framed connection.
func (*Delimited) BufferedData ¶
BufferedData drains any data currently buffered by the reader.
func (*Delimited) RecvFrame ¶
RecvFrame reads the next null-delimited JSON frame. The returned bool is false on clean EOF.
func (*Delimited) RecvServer ¶
func (d *Delimited) RecvServer(timeout bool) (ServerMessage, bool, error)
RecvServer reads and decodes a server message.
type ServerMessage ¶
type ServerMessage struct {
Kind ServerMessageKind
Port uint16
ID uuid.UUID
ErrorText string
}
ServerMessage is a parsed message sent from the bore server.
type ServerMessageKind ¶
type ServerMessageKind string
ServerMessageKind enumerates message types sent from the server.
const ( ServerHello ServerMessageKind = "hello" ServerChallenge ServerMessageKind = "challenge" ServerHeartbeat ServerMessageKind = "heartbeat" ServerConnection ServerMessageKind = "connection" ServerError ServerMessageKind = "error" )