Documentation ¶
Index ¶
- Variables
- type Account
- type Client
- type ClientConfig
- type ConnReader
- type ConnWriter
- type Fallback
- func (*Fallback) Descriptor() ([]byte, []int)deprecated
- func (x *Fallback) GetAlpn() string
- func (x *Fallback) GetDest() string
- func (x *Fallback) GetName() string
- func (x *Fallback) GetPath() string
- func (x *Fallback) GetType() string
- func (x *Fallback) GetXver() uint64
- func (*Fallback) ProtoMessage()
- func (x *Fallback) ProtoReflect() protoreflect.Message
- func (x *Fallback) Reset()
- func (x *Fallback) String() string
- type MemoryAccount
- type PacketReader
- type PacketWriter
- type Server
- func (s *Server) AddUser(ctx context.Context, u *protocol.MemoryUser) error
- func (s *Server) GetUser(ctx context.Context, email string) *protocol.MemoryUser
- func (s *Server) GetUsers(ctx context.Context) []*protocol.MemoryUser
- func (s *Server) GetUsersCount(context.Context) int64
- func (s *Server) Network() []net.Network
- func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, ...) error
- func (s *Server) RemoveUser(ctx context.Context, e string) error
- type ServerConfig
- func (*ServerConfig) Descriptor() ([]byte, []int)deprecated
- func (x *ServerConfig) GetFallbacks() []*Fallback
- func (x *ServerConfig) GetUsers() []*protocol.User
- func (*ServerConfig) ProtoMessage()
- func (x *ServerConfig) ProtoReflect() protoreflect.Message
- func (x *ServerConfig) Reset()
- func (x *ServerConfig) String() string
- type Validator
- func (v *Validator) Add(u *protocol.MemoryUser) error
- func (v *Validator) Del(e string) error
- func (v *Validator) Get(hash string) *protocol.MemoryUser
- func (v *Validator) GetAll() []*protocol.MemoryUser
- func (v *Validator) GetByEmail(email string) *protocol.MemoryUser
- func (v *Validator) GetCount() int64
Constants ¶
This section is empty.
Variables ¶
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) Descriptor
deprecated
func (*Account) GetPassword ¶
func (*Account) ProtoMessage ¶
func (*Account) ProtoMessage()
func (*Account) ProtoReflect ¶
func (x *Account) ProtoReflect() protoreflect.Message
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a inbound handler for trojan protocol
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 Flow string // 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) WriteMultiBuffer ¶
func (c *ConnWriter) WriteMultiBuffer(mb buf.MultiBuffer) error
WriteMultiBuffer implements buf.Writer
type Fallback ¶
type Fallback struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Alpn string `protobuf:"bytes,2,opt,name=alpn,proto3" json:"alpn,omitempty"` Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"` Dest string `protobuf:"bytes,5,opt,name=dest,proto3" json:"dest,omitempty"` Xver uint64 `protobuf:"varint,6,opt,name=xver,proto3" json:"xver,omitempty"` // contains filtered or unexported fields }
func (*Fallback) Descriptor
deprecated
func (*Fallback) ProtoMessage ¶
func (*Fallback) ProtoMessage()
func (*Fallback) ProtoReflect ¶
func (x *Fallback) ProtoReflect() protoreflect.Message
type MemoryAccount ¶
MemoryAccount is an account type converted from Account.
func (*MemoryAccount) Equals ¶
func (a *MemoryAccount) Equals(another protocol.Account) bool
Equals implements protocol.Account.Equals().
func (*MemoryAccount) ToProto ¶
func (a *MemoryAccount) ToProto() proto.Message
type PacketReader ¶
PacketReader is UDP Connection Reader Wrapper for trojan protocol
func (*PacketReader) ReadMultiBuffer ¶
func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error)
ReadMultiBuffer implements buf.Reader
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
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) GetUsers ¶
func (s *Server) GetUsers(ctx context.Context) []*protocol.MemoryUser
GetUsers implements proxy.UserManager.GetUsers().
func (*Server) GetUsersCount ¶
GetUsersCount implements proxy.UserManager.GetUsersCount().
type ServerConfig ¶
type ServerConfig struct { Users []*protocol.User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` Fallbacks []*Fallback `protobuf:"bytes,2,rep,name=fallbacks,proto3" json:"fallbacks,omitempty"` // 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) 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) Get ¶
func (v *Validator) Get(hash string) *protocol.MemoryUser
Get a trojan user with hashed key, nil if user doesn't exist.
func (*Validator) GetByEmail ¶
func (v *Validator) GetByEmail(email string) *protocol.MemoryUser
Get a trojan user with hashed key, nil if user doesn't exist.