simplesocks

package
v1.1.9-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package simplesocks implements SimpleSocks protocol. See https://p4gefau1t.github.io/trojan-go/developer/simplesocks/

Index

Constants

View Source
const (
	// trojan-go 的代码里,这里依然叫做connect和associate,而实际上,因为通道已经建立,所以实际含义已经不同
	// 这些命令只用于指示承载数据的传输层协议,所以我们这里重命名一下。
	CmdTCP = 0x01
	CmdUDP = 0x03

	ATypIP4    = 0x1
	ATypDomain = 0x3
	ATypIP6    = 0x4

	Name = "simplesocks"
)

Variables

This section is empty.

Functions

func GetAddrFrom

func GetAddrFrom(buf utils.ByteReader) (addr netLayer.Addr, err error)

依照trojan协议的格式读取 地址的域名、ip、port信息

func WriteAddrToBuf

func WriteAddrToBuf(target netLayer.Addr, buf *bytes.Buffer)

Types

type Client

type Client struct {
	proxy.ProxyCommonStruct
}

func (*Client) EstablishUDPChannel

func (c *Client) EstablishUDPChannel(underlay net.Conn, target netLayer.Addr) (netLayer.MsgConn, error)

func (*Client) Handshake

func (c *Client) Handshake(underlay net.Conn, firstPayload []byte, target netLayer.Addr) (io.ReadWriteCloser, error)

func (*Client) Name

func (c *Client) Name() string

type ClientCreator

type ClientCreator struct{}

func (ClientCreator) NewClient

func (ClientCreator) NewClient(dc *proxy.DialConf) (proxy.Client, error)

func (ClientCreator) NewClientFromURL

func (ClientCreator) NewClientFromURL(u *url.URL) (proxy.Client, error)

type Server

type Server struct {
	proxy.ProxyCommonStruct
}

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) Name

func (*Server) Name() string

type ServerCreator

type ServerCreator struct{}

func (ServerCreator) NewServer

func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error)

func (ServerCreator) NewServerFromURL

func (ServerCreator) NewServerFromURL(u *url.URL) (proxy.Server, error)

type TCPConn

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

func (*TCPConn) CanSplice

func (c *TCPConn) CanSplice() (r bool, conn net.Conn)

func (*TCPConn) EverPossibleToSplice

func (c *TCPConn) EverPossibleToSplice() bool

func (*TCPConn) Read

func (uc *TCPConn) Read(p []byte) (int, error)

func (*TCPConn) ReadFrom

func (c *TCPConn) ReadFrom(r io.Reader) (written int64, err error)

func (*TCPConn) Write

func (uc *TCPConn) Write(p []byte) (int, error)

func (*TCPConn) WriteBuffers

func (c *TCPConn) WriteBuffers(buffers [][]byte) (int64, error)

type UDPConn

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

func NewUDPConn

func NewUDPConn(conn net.Conn, optionalReader io.Reader) (uc *UDPConn)

func (UDPConn) CloseConnWithRaddr

func (u UDPConn) CloseConnWithRaddr(raddr netLayer.Addr) error

func (UDPConn) Fullcone

func (u UDPConn) Fullcone() bool

func (UDPConn) ReadMsgFrom

func (u UDPConn) ReadMsgFrom() ([]byte, netLayer.Addr, error)

func (UDPConn) WriteMsgTo

func (u UDPConn) WriteMsgTo(bs []byte, addr netLayer.Addr) error

Jump to

Keyboard shortcuts

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