Files

73 lines
1.1 KiB
Go
Raw Permalink Normal View History

package core
import (
"bufio"
"fmt"
"net"
"time"
)
type Conn struct {
Conn net.Conn
Reader *bufio.Reader
Tag [16]byte
Protocol string
Dest *FwdAddr
Auth *AuthContext
}
func (c Conn) Read(b []byte) (n int, err error) {
return c.Reader.Read(b)
}
func (c Conn) Write(b []byte) (n int, err error) {
return c.Conn.Write(b)
}
func (c Conn) Close() error {
return c.Conn.Close()
}
func (c Conn) LocalAddr() net.Addr {
return c.Conn.LocalAddr()
}
func (c Conn) RemoteAddr() net.Addr {
return c.Conn.RemoteAddr()
}
func (c Conn) SetDeadline(t time.Time) error {
return c.Conn.SetDeadline(t)
}
func (c Conn) SetReadDeadline(t time.Time) error {
return c.Conn.SetReadDeadline(t)
}
func (c Conn) SetWriteDeadline(t time.Time) error {
return c.Conn.SetWriteDeadline(t)
}
type FwdAddr struct {
IP net.IP
Port int
Domain string
}
func (a FwdAddr) Network() string {
return "tcp"
}
func (a FwdAddr) String() string {
return fmt.Sprintf("%s:%d", a.IP, a.Port)
}
type AuthContext struct {
Payload Payload
Meta map[string]any
}
type Payload struct {
ID int32
}