trojan

package
v5.19.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: MIT Imports: 34 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_proxy_trojan_config_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Account

type Account struct {
	Password string `protobuf:"bytes,1,opt,name=password,proto3" json:"password,omitempty"`
	// contains filtered or unexported fields
}

func (*Account) AsAccount

func (a *Account) AsAccount() (protocol.Account, error)

AsAccount implements protocol.AsAccount.

func (*Account) Descriptor deprecated

func (*Account) Descriptor() ([]byte, []int)

Deprecated: Use Account.ProtoReflect.Descriptor instead.

func (*Account) GetPassword

func (x *Account) GetPassword() string

func (*Account) ProtoMessage

func (*Account) ProtoMessage()

func (*Account) ProtoReflect

func (x *Account) ProtoReflect() protoreflect.Message

func (*Account) Reset

func (x *Account) Reset()

func (*Account) String

func (x *Account) String() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an inbound handler for trojan protocol

func NewClient

func NewClient(ctx context.Context, config *ClientConfig) (*Client, error)

NewClient create a new trojan client.

func (*Client) Process

func (c *Client) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error

Process implements OutboundHandler.Process().

type ClientConfig

type ClientConfig struct {
	Server []*protocol.ServerEndpoint `protobuf:"bytes,1,rep,name=server,proto3" json:"server,omitempty"`
	// contains filtered or unexported fields
}

func (*ClientConfig) Descriptor deprecated

func (*ClientConfig) Descriptor() ([]byte, []int)

Deprecated: Use ClientConfig.ProtoReflect.Descriptor instead.

func (*ClientConfig) GetServer

func (x *ClientConfig) GetServer() []*protocol.ServerEndpoint

func (*ClientConfig) ProtoMessage

func (*ClientConfig) ProtoMessage()

func (*ClientConfig) ProtoReflect

func (x *ClientConfig) ProtoReflect() protoreflect.Message

func (*ClientConfig) Reset

func (x *ClientConfig) Reset()

func (*ClientConfig) String

func (x *ClientConfig) String() string

type ConnReader

type ConnReader struct {
	io.Reader
	Target net.Destination
	// contains filtered or unexported fields
}

ConnReader is TCP Connection Reader Wrapper for trojan protocol

func (*ConnReader) ParseHeader

func (c *ConnReader) ParseHeader() error

ParseHeader parses the trojan protocol header

func (*ConnReader) Read

func (c *ConnReader) Read(p []byte) (int, error)

Read implements io.Reader

func (*ConnReader) ReadMultiBuffer

func (c *ConnReader) ReadMultiBuffer() (buf.MultiBuffer, error)

ReadMultiBuffer implements buf.Reader

type ConnWriter

type ConnWriter struct {
	io.Writer
	Target  net.Destination
	Account *MemoryAccount
	// contains filtered or unexported fields
}

ConnWriter is TCP Connection Writer Wrapper for trojan protocol

func (*ConnWriter) Write

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

Write implements io.Writer

func (*ConnWriter) WriteHeader added in v5.5.0

func (c *ConnWriter) WriteHeader() error

func (*ConnWriter) WriteMultiBuffer

func (c *ConnWriter) WriteMultiBuffer(mb buf.MultiBuffer) error

WriteMultiBuffer implements buf.Writer

type Fallback

type Fallback struct {
	Alpn string `protobuf:"bytes,1,opt,name=alpn,proto3" json:"alpn,omitempty"`
	Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
	Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
	Dest string `protobuf:"bytes,4,opt,name=dest,proto3" json:"dest,omitempty"`
	Xver uint64 `protobuf:"varint,5,opt,name=xver,proto3" json:"xver,omitempty"`
	// contains filtered or unexported fields
}

func (*Fallback) Descriptor deprecated

func (*Fallback) Descriptor() ([]byte, []int)

Deprecated: Use Fallback.ProtoReflect.Descriptor instead.

func (*Fallback) GetAlpn

func (x *Fallback) GetAlpn() string

func (*Fallback) GetDest

func (x *Fallback) GetDest() string

func (*Fallback) GetPath

func (x *Fallback) GetPath() string

func (*Fallback) GetType

func (x *Fallback) GetType() string

func (*Fallback) GetXver

func (x *Fallback) GetXver() uint64

func (*Fallback) ProtoMessage

func (*Fallback) ProtoMessage()

func (*Fallback) ProtoReflect

func (x *Fallback) ProtoReflect() protoreflect.Message

func (*Fallback) Reset

func (x *Fallback) Reset()

func (*Fallback) String

func (x *Fallback) String() string

type MemoryAccount

type MemoryAccount struct {
	Password string
	Key      []byte
}

MemoryAccount is an account type converted from Account.

func (*MemoryAccount) Equals

func (a *MemoryAccount) Equals(another protocol.Account) bool

Equals implements protocol.Account.Equals().

type PacketConnectionReader added in v5.4.0

type PacketConnectionReader struct {
	// contains filtered or unexported fields
}

func (*PacketConnectionReader) ReadFrom added in v5.4.0

func (r *PacketConnectionReader) ReadFrom(p []byte) (n int, addr gonet.Addr, err error)

type PacketPayload

type PacketPayload struct {
	Target net.Destination
	Buffer buf.MultiBuffer
}

PacketPayload combines udp payload and destination

type PacketReader

type PacketReader struct {
	io.Reader
}

PacketReader is UDP Connection Reader Wrapper for trojan protocol

func (*PacketReader) ReadMultiBuffer

func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error)

ReadMultiBuffer implements buf.Reader

func (*PacketReader) ReadMultiBufferWithMetadata

func (r *PacketReader) ReadMultiBufferWithMetadata() (*PacketPayload, error)

ReadMultiBufferWithMetadata reads udp packet with destination

type PacketWriter

type PacketWriter struct {
	io.Writer
	Target net.Destination
}

PacketWriter UDP Connection Writer Wrapper for trojan protocol

func (*PacketWriter) WriteMultiBuffer

func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error

WriteMultiBuffer implements buf.Writer

func (*PacketWriter) WriteMultiBufferWithMetadata

func (w *PacketWriter) WriteMultiBufferWithMetadata(mb buf.MultiBuffer, dest net.Destination) error

WriteMultiBufferWithMetadata writes udp packet with destination specified

func (*PacketWriter) WriteTo added in v5.4.0

func (w *PacketWriter) WriteTo(payload []byte, addr gonet.Addr) (int, error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an inbound connection handler that handles messages in trojan protocol.

func NewServer

func NewServer(ctx context.Context, config *ServerConfig) (*Server, error)

NewServer creates a new trojan inbound handler.

func (*Server) AddUser

func (s *Server) AddUser(ctx context.Context, u *protocol.MemoryUser) error

AddUser implements proxy.UserManager.AddUser().

func (*Server) Network

func (s *Server) Network() []net.Network

Network implements proxy.Inbound.Network().

func (*Server) Process

func (s *Server) Process(ctx context.Context, network net.Network, conn internet.Connection, dispatcher routing.Dispatcher) error

Process implements proxy.Inbound.Process().

func (*Server) RemoveUser

func (s *Server) RemoveUser(ctx context.Context, e string) error

RemoveUser implements proxy.UserManager.RemoveUser().

type ServerConfig

type ServerConfig struct {
	Users          []*protocol.User          `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"`
	Fallbacks      []*Fallback               `protobuf:"bytes,3,rep,name=fallbacks,proto3" json:"fallbacks,omitempty"`
	PacketEncoding packetaddr.PacketAddrType `` /* 150-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*ServerConfig) Descriptor deprecated

func (*ServerConfig) Descriptor() ([]byte, []int)

Deprecated: Use ServerConfig.ProtoReflect.Descriptor instead.

func (*ServerConfig) GetFallbacks

func (x *ServerConfig) GetFallbacks() []*Fallback

func (*ServerConfig) GetPacketEncoding added in v5.4.0

func (x *ServerConfig) GetPacketEncoding() packetaddr.PacketAddrType

func (*ServerConfig) GetUsers

func (x *ServerConfig) GetUsers() []*protocol.User

func (*ServerConfig) ProtoMessage

func (*ServerConfig) ProtoMessage()

func (*ServerConfig) ProtoReflect

func (x *ServerConfig) ProtoReflect() protoreflect.Message

func (*ServerConfig) Reset

func (x *ServerConfig) Reset()

func (*ServerConfig) String

func (x *ServerConfig) String() string

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator stores valid trojan users.

func (*Validator) Add

func (v *Validator) Add(u *protocol.MemoryUser) error

Add a trojan user, Email must be empty or unique.

func (*Validator) Del

func (v *Validator) Del(e string) error

Del a trojan user with a non-empty Email.

func (*Validator) Get

func (v *Validator) Get(hash string) *protocol.MemoryUser

Get a trojan user with hashed key, nil if user doesn't exist.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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