trojan

package
v1.10.0-alpha.18 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: GPL-2.0 Imports: 18 Imported by: 7

Documentation

Index

Constants

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

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 HandleMuxConnection

func HandleMuxConnection(ctx context.Context, conn net.Conn, metadata M.Metadata, handler Handler) 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 {
	N.ExtendedConn
	// contains filtered or unexported fields
}

func NewClientConn

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

func (*ClientConn) FrontHeadroom

func (c *ClientConn) FrontHeadroom() int

func (*ClientConn) NeedHandshake added in v1.2.0

func (c *ClientConn) NeedHandshake() bool

func (*ClientConn) Upstream

func (c *ClientConn) Upstream() any

func (*ClientConn) Write

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

func (*ClientConn) WriteBuffer

func (c *ClientConn) WriteBuffer(buffer *buf.Buffer) 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) FrontHeadroom

func (c *ClientPacketConn) FrontHeadroom() int

func (*ClientPacketConn) InitializeReadWaiter added in v1.8.0

func (c *ClientPacketConn) InitializeReadWaiter(options N.ReadWaitOptions) (needCopy bool)

func (*ClientPacketConn) NeedHandshake added in v1.2.0

func (c *ClientPacketConn) NeedHandshake() bool

func (*ClientPacketConn) Read

func (c *ClientPacketConn) Read(p []byte) (n int, err error)

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) Upstream

func (c *ClientPacketConn) Upstream() any

func (*ClientPacketConn) WaitReadPacket added in v1.8.0

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

func (*ClientPacketConn) Write

func (c *ClientPacketConn) Write(p []byte) (n int, err 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 Handler

type Handler interface {
	N.TCPConnectionHandler
	N.UDPConnectionHandler
	E.Handler
}

type PacketConn

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

func (*PacketConn) FrontHeadroom

func (c *PacketConn) FrontHeadroom() int

func (*PacketConn) InitializeReadWaiter added in v1.8.0

func (c *PacketConn) InitializeReadWaiter(options N.ReadWaitOptions) (needCopy bool)

func (*PacketConn) NeedAdditionalReadDeadline added in v1.2.5

func (c *PacketConn) NeedAdditionalReadDeadline() bool

func (*PacketConn) ReadPacket

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

func (*PacketConn) Upstream added in v1.2.5

func (c *PacketConn) Upstream() any

func (*PacketConn) WaitReadPacket added in v1.8.0

func (c *PacketConn) WaitReadPacket() (buffer *buf.Buffer, destination M.Socksaddr, err 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, fallbackHandler N.TCPConnectionHandler) *Service[K]

func (*Service[K]) NewConnection

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

func (*Service[K]) UpdateUsers

func (s *Service[K]) UpdateUsers(userList []K, passwordList []string) error

Jump to

Keyboard shortcuts

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