Versions in this module Expand all Collapse all v1 v1.0.1 May 14, 2025 Changes in this version + const ATYPDomain + const ATYPIPv4 + const ATYPIPv6 + const CmdBind + const CmdConnect + const CmdUDP + const MethodGSSAPI + const MethodNone + const MethodUnsupportAll + const MethodUsernamePassword + const RepAddressNotSupported + const RepCommandNotSupported + const RepConnectionRefused + const RepHostUnreachable + const RepNetworkUnreachable + const RepNotAllowed + const RepServerFailure + const RepSuccess + const RepTTLExpired + const UserPassStatusFailure + const UserPassStatusSuccess + const UserPassVer + const Ver + var Debug bool + var DialTCP func(network string, laddr, raddr string) (net.Conn, error) = func(network string, laddr, raddr string) (net.Conn, error) + var DialUDP func(network string, laddr, raddr string) (net.Conn, error) = func(network string, laddr, raddr string) (net.Conn, error) + var ErrBadReply = errors.New("Bad Reply") + var ErrBadRequest = errors.New("Bad Request") + var ErrUnsupportCmd = errors.New("Unsupport Command") + var ErrUserPassAuth = errors.New("Invalid Username or Password for Auth") + var ErrUserPassVersion = errors.New("Invalid Version of Username Password Auth") + var ErrVersion = errors.New("Invalid Version") + var Resolve func(network string, addr string) (net.Addr, error) = func(network string, addr string) (net.Addr, error) + func ParseAddress(address string) (a byte, addr []byte, port []byte, err error) + func ParseBytesAddress(b []byte) (a byte, addr []byte, port []byte, err error) + func ToAddress(a byte, addr []byte, port []byte) string + type Client struct + Dst string + Password string + RemoteAddress net.Addr + Server string + TCPConn net.Conn + TCPTimeout int + UDPConn net.Conn + UDPTimeout int + UserName string + func NewClient(addr, username, password string, tcpTimeout, udpTimeout int) (*Client, error) + func (c *Client) Close() error + func (c *Client) Dial(network, addr string) (net.Conn, error) + func (c *Client) DialWithLocalAddr(network, src, dst string, remoteAddr net.Addr) (net.Conn, error) + func (c *Client) LocalAddr() net.Addr + func (c *Client) Negotiate(laddr net.Addr) error + func (c *Client) Read(b []byte) (int, error) + func (c *Client) RemoteAddr() net.Addr + func (c *Client) Request(r *Request) (*Reply, error) + func (c *Client) SetDeadline(t time.Time) error + func (c *Client) SetReadDeadline(t time.Time) error + func (c *Client) SetWriteDeadline(t time.Time) error + func (c *Client) Write(b []byte) (int, error) + type Datagram struct + Atyp byte + Data []byte + DstAddr []byte + DstPort []byte + Frag byte + Rsv []byte + func NewDatagram(atyp byte, dstaddr []byte, dstport []byte, data []byte) *Datagram + func NewDatagramFromBytes(bb []byte) (*Datagram, error) + func (d *Datagram) Address() string + func (d *Datagram) Bytes() []byte + type DefaultHandle struct + func (h *DefaultHandle) TCPHandle(s *Server, c *net.TCPConn, r *Request, username, password string) error + func (h *DefaultHandle) UDPHandle(s *Server, addr *net.UDPAddr, d *Datagram) error + type Handler interface + TCPHandle func(*Server, *net.TCPConn, *Request, string, string) error + UDPHandle func(*Server, *net.UDPAddr, *Datagram) error + type NegotiationReply struct + Method byte + Ver byte + func NewNegotiationReply(method byte) *NegotiationReply + func NewNegotiationReplyFrom(r io.Reader) (*NegotiationReply, error) + func (r *NegotiationReply) WriteTo(w io.Writer) (int64, error) + type NegotiationRequest struct + Methods []byte + NMethods byte + Ver byte + func NewNegotiationRequest(methods []byte) *NegotiationRequest + func NewNegotiationRequestFrom(r io.Reader) (*NegotiationRequest, error) + func (r *NegotiationRequest) WriteTo(w io.Writer) (int64, error) + type Reply struct + Atyp byte + BndAddr []byte + BndPort []byte + Rep byte + Rsv byte + Ver byte + func NewReply(rep byte, atyp byte, bndaddr []byte, bndport []byte) *Reply + func NewReplyFrom(r io.Reader) (*Reply, error) + func (r *Reply) Address() string + func (r *Reply) WriteTo(w io.Writer) (int64, error) + type Request struct + Atyp byte + Cmd byte + DstAddr []byte + DstPort []byte + Rsv byte + Ver byte + func NewRequest(cmd byte, atyp byte, dstaddr []byte, dstport []byte) *Request + func NewRequestFrom(r io.Reader) (*Request, error) + func (r *Request) Address() string + func (r *Request) Connect(w io.Writer) (net.Conn, error) + func (r *Request) UDP(c net.Conn, serverAddr net.Addr) (net.Addr, error) + func (r *Request) WriteTo(w io.Writer) (int64, error) + type Server struct + Addr string + AssociatedUDP *cache.Cache + Handle Handler + LimitUDP bool + Method byte + Password string + RunnerGroup *runnergroup.RunnerGroup + ServerAddr net.Addr + SupportedCommands []byte + TCPTimeout int + UDPConn *net.UDPConn + UDPExchanges *cache.Cache + UDPSrc *cache.Cache + UDPTimeout int + UserName string + func NewClassicServer(addr, ip, username, password string, tcpTimeout, udpTimeout int) (*Server, error) + func (s *Server) GetRequest(rw io.ReadWriter) (*Request, error) + func (s *Server) ListenAndServe(h Handler) error + func (s *Server) Negotiate(rw *net.TCPConn, username, password *string) error + func (s *Server) Shutdown() error + type UDPExchange struct + ClientAddr *net.UDPAddr + RemoteConn net.Conn + type UserPassNegotiationReply struct + Status byte + Ver byte + func NewUserPassNegotiationReply(status byte) *UserPassNegotiationReply + func NewUserPassNegotiationReplyFrom(r io.Reader) (*UserPassNegotiationReply, error) + func (r *UserPassNegotiationReply) WriteTo(w io.Writer) (int64, error) + type UserPassNegotiationRequest struct + Passwd []byte + Plen byte + Ulen byte + Uname []byte + Ver byte + func NewUserPassNegotiationRequest(username []byte, password []byte) *UserPassNegotiationRequest + func NewUserPassNegotiationRequestFrom(r io.Reader) (*UserPassNegotiationRequest, error) + func (r *UserPassNegotiationRequest) WriteTo(w io.Writer) (int64, error)