trojan

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientHandshake

func ClientHandshake(conn net.Conn, hostPort, password string) error

func ClientHandshakeTimeout

func ClientHandshakeTimeout(conn net.Conn, hostPort, password string, timeout time.Duration) error

func Dial

func Dial(network, address, hostPort, password string, config *tls.Config) (*tls.Conn, error)

func DialTimeout

func DialTimeout(network, address, hostPort, password string, config *tls.Config, timeout time.Duration) (*tls.Conn, error)

func Hash added in v0.3.1

func Hash(password string) []byte

func ServerHandshake

func ServerHandshake(conn net.Conn, auth AuthMethod) (network string, hostPort string, err error)

func ServerHandshakeTimeout

func ServerHandshakeTimeout(conn net.Conn, auth AuthMethod, timeout time.Duration) (network string, hostPort string, err error)

Types

type AuthFailure

type AuthFailure string

func (AuthFailure) Error

func (a AuthFailure) Error() string

type AuthMethod

type AuthMethod interface {
	Method() string
	Auth(r io.Reader) error
}

AuthMethod trojan 认证方式接口

type AuthPassword

type AuthPassword struct {
	Map map[string]int
}

func NewAuthPasswordMap

func NewAuthPasswordMap(m map[string]int, toHash bool) *AuthPassword

func NewAuthPasswordSlice

func NewAuthPasswordSlice(slice []string, toHash bool) *AuthPassword

func (*AuthPassword) Auth

func (a *AuthPassword) Auth(r io.Reader) error

func (*AuthPassword) Method

func (a *AuthPassword) Method() string

type Listener

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

func Listen

func Listen(network, address string, auth AuthMethod, config *tls.Config) (*Listener, error)

func ListenTimeout

func ListenTimeout(network, address string, auth AuthMethod, config *tls.Config, timeout time.Duration) (*Listener, error)

func (*Listener) Accept

func (l *Listener) Accept() (conn net.Conn, network, hostPort string, err error)

Accept 返回client请求的network,hostPort. err为trojan.AuthFailed时,[]byte(err.(trojan.AuthFailed))可以获取原始Bytes数据,进行重定向

Jump to

Keyboard shortcuts

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