trojan

package
v0.0.0-...-c6b16a5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "trojan"
)

Variables

This section is empty.

Functions

func HexSha224

func HexSha224(password string) []byte

func NewTrojanClient

func NewTrojanClient(ctx context.Context, url *url.URL) (proxy.Client, error)

func NewTrojanServer

func NewTrojanServer(ctx context.Context, url *url.URL) (proxy.Server, error)

func SHA224String

func SHA224String(password string) string

Types

type Client

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

Client is a vmess client

func (*Client) Addr

func (c *Client) Addr() string

func (*Client) Handshake

func (c *Client) Handshake(underlay net.Conn, target string) (proxy.StreamConn, error)

func (*Client) Name

func (c *Client) Name() string

func (*Client) Pack

func (c *Client) Pack(underlay net.Conn) (proxy.PacketConn, error)

type ClientConn

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

func (*ClientConn) Close

func (c *ClientConn) Close() error

func (*ClientConn) Read

func (c *ClientConn) Read(b []byte) (int, error)

func (*ClientConn) Request

func (c *ClientConn) Request() error

Request sends request to server. https://trojan-gfw.github.io/trojan/protocol

func (*ClientConn) Write

func (c *ClientConn) Write(b []byte) (int, error)

type PacketConn

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

func (*PacketConn) GetTargetAddr

func (pc *PacketConn) GetTargetAddr() *proxy.TargetAddr

func (*PacketConn) ReadFrom

func (pc *PacketConn) ReadFrom(b []byte) (int, net.Addr, error)

ReadFrom overrides the original function from net.PacketConn.

func (*PacketConn) WriteTo

func (pc *PacketConn) WriteTo(b []byte, addr net.Addr) (int, error)

WriteTo overrides the original function from net.PacketConn.

type Server

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

func (*Server) Addr

func (s *Server) Addr() string

func (*Server) Handshake

func (s *Server) Handshake(underlay net.Conn) (proxy.StreamConn, *proxy.TargetAddr, error)

func (*Server) Name

func (s *Server) Name() string

func (*Server) Pack

func (s *Server) Pack(underlay net.Conn) (proxy.PacketConn, error)

type ServerConn

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

ServerConn wrapper a net.Conn with trojan protocol

func (*ServerConn) Close

func (c *ServerConn) Close() error

func (*ServerConn) Read

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

func (*ServerConn) Write

func (c *ServerConn) Write(p []byte) (int, error)

type User

type User struct {
	*user.Meter

	Hex string
}

Trojan user

func NewUser

func NewUser(ctx context.Context, password string) *User

type UserManager

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

Trojan user manager

func NewUserManager

func NewUserManager(ctx context.Context, passwords ...string) *UserManager

Create Authenticator from user ids

func (*UserManager) AddUser

func (m *UserManager) AddUser(hash string, more ...string) error

func (*UserManager) AuthUser

func (m *UserManager) AuthUser(hash string) (bool, user.User)

func (*UserManager) CheckHex

func (m *UserManager) CheckHex(hex string) (*User, error)

func (*UserManager) DelUser

func (m *UserManager) DelUser(hash string) error

func (*UserManager) ListUsers

func (m *UserManager) ListUsers() []user.User

Jump to

Keyboard shortcuts

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