Documentation ¶
Overview ¶
Package trojan implements trojan protocol for proxy.Client and proxy.Server.
Index ¶
- Constants
- func GenerateOfficialDraftShareURL(dialconf *proxy.DialConf) string
- func GetAddrFrom(buf utils.ByteReader, ismux bool) (addr netLayer.Addr, err error)
- func InitUsers(uc []utils.UserConf) (us []utils.User)
- func PassBytesToStr(bs []byte) string
- func PassStrToBytes(str string) []byte
- func SHA224(password string) (r [passBytesLen]byte)
- func SHA224_hexString(password string) string
- func SHA224_hexStringBytes(password string) []byte
- func WriteAddrToBuf(target netLayer.Addr, buf *bytes.Buffer)
- type Client
- func (c *Client) EstablishUDPChannel(underlay net.Conn, firstPayload []byte, target netLayer.Addr) (netLayer.MsgConn, error)
- func (*Client) GetCreator() proxy.ClientCreator
- func (c *Client) GetUser() utils.User
- func (c *Client) Handshake(underlay net.Conn, firstPayload []byte, target netLayer.Addr) (io.ReadWriteCloser, error)
- func (c *Client) HasInnerMux() (int, string)
- func (*Client) Name() string
- type ClientCreator
- type Server
- type ServerCreator
- type UDPConn
- type User
- type UserTCPConn
- func (c *UserTCPConn) CanSpliceRead() (bool, *net.TCPConn, *net.UnixConn)
- func (c *UserTCPConn) CanSpliceWrite() (r bool, conn *net.TCPConn)
- func (c *UserTCPConn) EverPossibleToSpliceRead() bool
- func (c *UserTCPConn) EverPossibleToSpliceWrite() bool
- func (c *UserTCPConn) Read(p []byte) (int, error)
- func (c *UserTCPConn) ReadFrom(r io.Reader) (written int64, err error)
- func (c *UserTCPConn) Upstream() net.Conn
- func (c *UserTCPConn) Write(p []byte) (int, error)
- func (c *UserTCPConn) WriteBuffers(buffers [][]byte) (int64, error)
Constants ¶
View Source
const ( ATypIP4 = 0x1 ATypDomain = 0x3 ATypIP6 = 0x4 )
View Source
const ( CmdConnect = 0x01 CmdUDPAssociate = 0x03 CmdMux = 0x7f //trojan-gfw 那个文档里并没有提及Mux, 这个定义作者似乎没有在任何文档中提及,所以这个是在trojan-go的源代码文件中找到的。 )
View Source
const Name = "trojan"
Variables ¶
This section is empty.
Functions ¶
func GetAddrFrom ¶
依照trojan协议的格式读取 地址的域名、ip、port信息
func SHA224_hexString ¶
func SHA224_hexStringBytes ¶
trojan协议 的前56字节 是 sha224的28字节 每字节 转义成 base 16, with lower-case letters for a-f 的 两个字符。 实际上trojan协议文档写的不严谨,它只说了用hex,没说用大写还是小写。我看它代码实现用的是小写。
Types ¶
type Client ¶
func (*Client) EstablishUDPChannel ¶
func (*Client) GetCreator ¶ added in v1.2.4
func (*Client) GetCreator() proxy.ClientCreator
func (*Client) HasInnerMux ¶
type ClientCreator ¶
type ClientCreator struct{ proxy.CreatorCommonStruct }
type Server ¶
type Server struct { proxy.Base *utils.MultiUserMap }
implements proxy.Server
func (*Server) CanFallback ¶ added in v1.2.1
func (*Server) Handshake ¶
func (s *Server) Handshake(underlay net.Conn) (result net.Conn, msgConn netLayer.MsgConn, targetAddr netLayer.Addr, returnErr error)
若握手步骤数据不对, 会返回 ErrDetail 为 utils.ErrInvalidData 的 utils.ErrInErr
func (*Server) HasInnerMux ¶
type ServerCreator ¶
type ServerCreator struct{ proxy.CreatorCommonStruct }
func (ServerCreator) NewServer ¶
func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error)
func (ServerCreator) URLToListenConf ¶ added in v1.2.4
func (ServerCreator) URLToListenConf(url *url.URL, lc *proxy.ListenConf, format int) (*proxy.ListenConf, error)
type UDPConn ¶
func NewUDPConn ¶
func (*UDPConn) CloseConnWithRaddr ¶
type User ¶ added in v1.2.2
type User struct {
// contains filtered or unexported fields
}
func NewUserByPlainTextPassword ¶ added in v1.2.2
type UserTCPConn ¶
trojan比较简洁,这个 UserTCPConn 只是用于读取握手读取时读到的剩余的缓存。 实现 net.Conn, io.ReaderFrom, utils.User, utils.MultiWriter, netLayer.Splicer, netLayer.ConnWrapper
func (*UserTCPConn) CanSpliceRead ¶ added in v1.2.5
func (*UserTCPConn) CanSpliceWrite ¶ added in v1.2.5
func (c *UserTCPConn) CanSpliceWrite() (r bool, conn *net.TCPConn)
func (*UserTCPConn) EverPossibleToSpliceRead ¶ added in v1.2.5
func (c *UserTCPConn) EverPossibleToSpliceRead() bool
当底层链接可以暴露为 tcp或 unix链接时,返回true
func (*UserTCPConn) EverPossibleToSpliceWrite ¶ added in v1.2.5
func (c *UserTCPConn) EverPossibleToSpliceWrite() bool
func (*UserTCPConn) ReadFrom ¶
func (c *UserTCPConn) ReadFrom(r io.Reader) (written int64, err error)
func (*UserTCPConn) Upstream ¶ added in v1.2.5
func (c *UserTCPConn) Upstream() net.Conn
func (*UserTCPConn) WriteBuffers ¶
func (c *UserTCPConn) WriteBuffers(buffers [][]byte) (int64, error)
Click to show internal directories.
Click to hide internal directories.