Documentation ¶
Overview ¶
package trojan implements proxy.Client and proxy.Server with trojan protocol.
Index ¶
- Constants
- func GenerateOfficialDraftShareURL(dialconf *proxy.DialConf) string
- func GetAddrFrom(buf utils.ByteReader, ismux bool) (addr netLayer.Addr, err error)
- func SHA224(password string) (r [28]byte)
- func SHA224_hexString(password string) string
- func SHA224_hexStringBytes(password string) []byte
- func WriteAddrToBuf(target netLayer.Addr, buf *bytes.Buffer)
- type Client
- type ClientCreator
- type Server
- type ServerCreator
- type UDPConn
- type UserTCPConn
- func (c *UserTCPConn) CanSplice() (r bool, conn net.Conn)
- func (c *UserTCPConn) EverPossibleToSplice() bool
- func (uc *UserTCPConn) Read(p []byte) (int, error)
- func (c *UserTCPConn) ReadFrom(r io.Reader) (written int64, err error)
- func (uc *UserTCPConn) Write(p []byte) (int, error)
- func (c *UserTCPConn) WriteBuffers(buffers [][]byte) (int64, error)
Constants ¶
View Source
const ( ATypIP4 = 0x1 ATypDomain = 0x3 ATypIP6 = 0x4 Name = "trojan" )
View Source
const ( CmdConnect = 0x01 CmdUDPAssociate = 0x03 CmdMux = 0x7f //trojan-gfw 那个文档里并没有提及Mux, 这个定义作者似乎没有在任何文档中提及,所以这个是在trojan-go的源代码文件中找到的。 )
Variables ¶
This section is empty.
Functions ¶
func GetAddrFrom ¶
依照trojan协议的格式读取 地址的域名、ip、port信息
func SHA224_hexString ¶
func SHA224_hexStringBytes ¶
trojan 的前56字节 是 sha224的28字节 每字节 转义成 ascii的 表示16进制的 两个字符
Types ¶
type Client ¶
type Client struct { proxy.ProxyCommonStruct // contains filtered or unexported fields }
func (*Client) EstablishUDPChannel ¶
func (*Client) HasInnerMux ¶
type ClientCreator ¶
type ClientCreator struct{}
func (ClientCreator) NewClientFromURL ¶
type Server ¶
type Server struct { proxy.ProxyCommonStruct // contains filtered or unexported fields }
implements proxy.Server
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{}
func (ServerCreator) NewServer ¶
func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error)
func (ServerCreator) NewServerFromURL ¶
type UserTCPConn ¶
trojan比较简洁,这个 UserTCPConn 只是用于读取握手读取时读到的剩余的缓存。 实现 net.Conn, io.ReaderFrom, utils.MultiWriter, netLayer.Splicer
func (*UserTCPConn) EverPossibleToSplice ¶
func (c *UserTCPConn) EverPossibleToSplice() bool
func (*UserTCPConn) ReadFrom ¶
func (c *UserTCPConn) ReadFrom(r io.Reader) (written int64, err error)
func (*UserTCPConn) WriteBuffers ¶
func (c *UserTCPConn) WriteBuffers(buffers [][]byte) (int64, error)
Click to show internal directories.
Click to hide internal directories.