trojan

package
v0.0.0-...-d3bc976 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2023 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyLength  = 56
	CommandTCP = 1
	CommandUDP = 3
)

Variables

View Source
var CRLF = []byte{'\r', '\n'}
View Source
var ErrUserExists = E.New("user already exists")

Functions

func ClientHandshake

func ClientHandshake(conn net.Conn, key [KeyLength]byte, destination M.Socksaddr, payload []byte) error

func ClientHandshakeBuffer

func ClientHandshakeBuffer(conn net.Conn, key [KeyLength]byte, destination M.Socksaddr, payload *buf.Buffer) error

func ClientHandshakePacket

func ClientHandshakePacket(conn net.Conn, key [KeyLength]byte, destination M.Socksaddr, payload *buf.Buffer) error

func ClientHandshakeRaw

func ClientHandshakeRaw(conn net.Conn, key [KeyLength]byte, command byte, destination M.Socksaddr, payload []byte) error

func Key

func Key(password string) [KeyLength]byte

func ReadPacket

func ReadPacket(conn net.Conn, buffer *buf.Buffer) (M.Socksaddr, error)

func WritePacket

func WritePacket(conn net.Conn, buffer *buf.Buffer, destination M.Socksaddr) error

Types

type ClientConn

type ClientConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewClientConn

func NewClientConn(conn net.Conn, key [KeyLength]byte, destination M.Socksaddr) *ClientConn

func (*ClientConn) ReadFrom

func (c *ClientConn) ReadFrom(r io.Reader) (n int64, err error)

func (*ClientConn) Write

func (c *ClientConn) Write(p []byte) (n int, err error)

func (*ClientConn) WriteBuffer

func (c *ClientConn) WriteBuffer(buffer *buf.Buffer) error

func (*ClientConn) WriteTo

func (c *ClientConn) WriteTo(w io.Writer) (n int64, err error)

type ClientPacketConn

type ClientPacketConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewClientPacketConn

func NewClientPacketConn(conn net.Conn, key [KeyLength]byte) *ClientPacketConn

func (*ClientPacketConn) ReadFrom

func (c *ClientPacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (*ClientPacketConn) ReadPacket

func (c *ClientPacketConn) ReadPacket(buffer *buf.Buffer) (M.Socksaddr, error)

func (*ClientPacketConn) WritePacket

func (c *ClientPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error

func (*ClientPacketConn) WriteTo

func (c *ClientPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

type Error

type Error struct {
	Metadata M.Metadata
	Conn     net.Conn
	Inner    error
}

func (*Error) Close

func (e *Error) Close() error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Handler

type Handler interface {
	N.TCPConnectionHandler
	N.UDPConnectionHandler
}

type PacketConn

type PacketConn struct {
	net.Conn
}

func (*PacketConn) ReadPacket

func (c *PacketConn) ReadPacket(buffer *buf.Buffer) (M.Socksaddr, error)

func (*PacketConn) WritePacket

func (c *PacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error

type Service

type Service[K comparable] struct {
	// contains filtered or unexported fields
}

func NewService

func NewService[K comparable](handler Handler) Service[K]

func (*Service[K]) AddUser

func (s *Service[K]) AddUser(user K, password string) error

func (*Service[K]) NewConnection

func (s *Service[K]) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error

func (*Service[K]) RemoveUser

func (s *Service[K]) RemoveUser(user K) bool

func (*Service[K]) ResetUsers

func (s *Service[K]) ResetUsers()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL