Documentation
¶
Index ¶
- Constants
- Variables
- func DialOnConn(RouterAddress string, TargetChannel string, Conn net.Conn) (string, error)
- func ReadFrame(frame *Frame, reader io.Reader) error
- func WriteFrame(frame *Frame, writer io.Writer) error
- type Address
- type Authority
- type Client
- type Frame
- type Listener
- type Option
- type PeerInfo
- type Router
- type TrackerConnection
- type WriteCounter
Constants ¶
const ( // DefaultDialConnectionTimeout is the default timeout for a dial operation. DefaultDialConnectionTimeout = 2 * time.Second // DefaultListenConnectionKeepAlive is the default keep alive checking interval for listening threads. DefaultListenConnectionKeepAlive = 20 * time.Second // DefaultServerBufferBytes is the default buffer size to exchange between connections. DefaultServerBufferBytes = 4096 )
const MaxChannelNameLength = 256
MaxChannelNameLength limits the maxmimum length of a channel name.
Variables ¶
var DefaultRouterOption = Option{ TokenAuthority: &noPermissionCheckAuthority{}, DialConnectionTimeout: DefaultDialConnectionTimeout, ListenConnectionKeepAlive: DefaultListenConnectionKeepAlive, ChannelBufferBytes: DefaultServerBufferBytes, }
DefaultRouterOption is a set of parameters in default value.
Functions ¶
func DialOnConn ¶ added in v0.0.22
DialOnConn initiaites a dial protocol with the router on `RouterAddress`. It is caller's resposibility to close the connection on error.
Types ¶
type Address ¶
type Address struct {
Channel string
}
Address represents an address in Router network.
type Authority ¶
type Authority interface { // Only returns a PeerInfo when the connection has the access permission. ValidatePeerInfo(*Frame, net.Conn) (*PeerInfo, error) }
Authority will be used by the router for ACL control.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements a Dial method to join the Router network.
func NewClientWithoutAuth ¶
NewClientWithoutAuth creates a RouterClient structure.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener implements a net.Listener interface on Router network.
func NewListener ¶
NewListener creates a RouterListener.
func NewListenerWithoutAuth ¶
NewListenerWithoutAuth creates a RouterListener structure and try to handshake with Router in `RouterAddress`.
func NewRouterListenerWithConn ¶
func NewRouterListenerWithConn( RouterAddress string, Channel string, RouterAddressDialer func(string) (net.Conn, error)) (*Listener, error)
NewRouterListenerWithConn creates a RouterListener structure. Conn here can be a just initialized connectiono from TLS.
type Option ¶
type Option struct { // TokenAuthority is the authority used for checking permissions. TokenAuthority Authority // DialConnectionTimeout specifies the timeout when a dialer connects to a listener. DialConnectionTimeout time.Duration // ListenConnectionKeepAlive specfies the health check interval. ListenConnectionKeepAlive time.Duration // ChannelBufferBytes specifies the size of the buffer while bridging the channel. ChannelBufferBytes uint64 }
Option specifies a set of options being used by the router.
type PeerInfo ¶ added in v0.0.29
type PeerInfo struct { Name string `json:"name"` RemoteAddress string `json:"remote-address"` Expiration time.Time }
PeerInfo provides the necessary information to identify a peer.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router proxies requests.
func NewDefaultRouter ¶
func NewDefaultRouter() *Router
NewDefaultRouter creates a router with default option.
type TrackerConnection ¶ added in v0.0.29
TrackerConnection keeps the track of the wrapped connection.
func (*TrackerConnection) Close ¶ added in v0.0.29
func (conn *TrackerConnection) Close() error
Close implements the net.Conn Close interface as well as finish the tracking.
func (*TrackerConnection) PrintF ¶ added in v0.0.29
func (conn *TrackerConnection) PrintF(format string, args ...interface{})
PrintF prints a message to the according tracker.
type WriteCounter ¶ added in v0.0.27
WriteCounter exports the traffic info to the exporter.