Documentation ¶
Index ¶
- Variables
- func BytesToUint16(bys []byte) uint16
- func MustParseNonce(nonce string) byte
- func NewNonce() string
- func RealIP(r *http.Request) string
- func SetDefaultLogger(logger *slog.Logger)
- func Uint16ToBytes(n uint16) []byte
- func Uint32ToBytes(n uint32) []byte
- type ConfigFileWriter
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(b []byte) (n int, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(b []byte) (n int, err error)
- type ConnectParameters
- type Dial
- type LogField
- type NetDialer
- type PacketConnWrapper
- type PipeEngine
- type StreamConn
- type StreamConnKeeper
- type StreamConnListener
- type TohClient
- type TrafficEvent
- type TrafficEventConsumer
Constants ¶
This section is empty.
Variables ¶
var ( ErrAuth = errors.New("authentication failed! invalid/limited ToH key") ErrDNSTypeANotFound = errors.New("type A record not found") ErrDNSTypeAAAANotFound = errors.New("type AAAA record not found") ErrDNSRecordNotFound = errors.New("dns record not found") ErrUnsupportNetwork = errors.New("unsupport network") HeaderHandshakeKey = "X-Toh-Key" HeaderHandshakeNet = "X-Toh-Net" HeaderHandshakeAddr = "X-Toh-Addr" HeaderHandshakeNonce = "X-Toh-Nonce" HeaderEstablishAddr = "X-Toh-EstAddr" HeaderSessionID = "X-Toh-SessionID" HeaderSourceIP = "X-Toh-SourceIP" HeaderOP = "X-Toh-OP" OPOverlayControl = "overlay-control" OPOverlayData = "overlay-data" )
var (
Version, Commit string
)
Functions ¶
func BytesToUint16 ¶
func MustParseNonce ¶ added in v0.12.4
func SetDefaultLogger ¶ added in v0.13.0
func Uint16ToBytes ¶
func Uint32ToBytes ¶
Types ¶
type ConfigFileWriter ¶
type ConfigFileWriter struct {
// contains filtered or unexported fields
}
ConfigFileWriter a writer that writes to both files and stdout
func NewConfigWriter ¶
func NewConfigWriter(f *os.File) *ConfigFileWriter
type Conn ¶ added in v0.12.3
type Conn struct {
// contains filtered or unexported fields
}
Conn tcp/udp connection based on StreamConn connection
func NewConn ¶ added in v0.12.3
func NewConn(conn StreamConn) *Conn
func (*Conn) Close ¶ added in v0.12.3
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*Conn) Read ¶ added in v0.12.3
Read reads data from the connection. Read can be made to time out and return an error after a fixed time limit; see SetDeadline and SetReadDeadline.
func (*Conn) RemoteAddr ¶ added in v0.12.3
RemoteAddr returns the remote network address, if known.
func (*Conn) SetDeadline ¶ added in v0.12.3
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other I/O methods will return an error that wraps os.ErrDeadlineExceeded. This can be tested using errors.Is(err, os.ErrDeadlineExceeded). The error's Timeout method will return true, but note that there are other possible errors for which the Timeout method will return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out.
func (*Conn) SetReadDeadline ¶ added in v0.12.3
SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.
func (*Conn) SetWriteDeadline ¶ added in v0.12.3
SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.
type ConnectParameters ¶ added in v0.13.2
type NetDialer ¶ added in v0.14.0
type NetDialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
NetDialer dialer interface
type PacketConnWrapper ¶
PacketConnWrapper wrap UDP conn
func NewPacketConn ¶ added in v0.13.1
func NewPacketConn(wsConn StreamConn) *PacketConnWrapper
type PipeEngine ¶
type PipeEngine struct {
// contains filtered or unexported fields
}
func NewPipeEngine ¶
func NewPipeEngine() *PipeEngine
func (*PipeEngine) AddEventConsumer ¶ added in v0.9.12
func (s *PipeEngine) AddEventConsumer(c TrafficEventConsumer)
func (*PipeEngine) PubEvent ¶
func (s *PipeEngine) PubEvent(e *TrafficEvent)
func (*PipeEngine) RunTrafficEventConsumeLoop ¶
func (s *PipeEngine) RunTrafficEventConsumeLoop()
type StreamConn ¶ added in v0.12.3
type StreamConn interface { Read() ([]byte, error) Write(p []byte) error LocalAddr() net.Addr RemoteAddr() net.Addr Close(code int, reason string) error Nonce() byte SetReadDeadline(t time.Time) error SetWriteDeadline(t time.Time) error }
StreamConn under layer transport connection. .i.e websocket
type StreamConnKeeper ¶ added in v0.13.2
StreamConnKeeper keep stream connection alive
type StreamConnListener ¶ added in v0.13.2
type StreamConnListener interface { SetOnClose(func()) SetOnReadWrite(func()) }
StreamConnListener listen conn lifecycle
type TohClient ¶
type TohClient interface { DialTCP(ctx context.Context, address string) (net.Conn, error) DialUDP(ctx context.Context, address string) (net.Conn, error) LookupIP(host string) (ips []net.IP, err error) LookupIP4(host string) (ips []net.IP, err error) LookupIP6(host string) (ips []net.IP, err error) NetDialer }
TohClient the ToH client
type TrafficEvent ¶
type TrafficEventConsumer ¶
type TrafficEventConsumer func(e *TrafficEvent)