suo5

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderKey           = "Content-Type"
	HeaderValueChecking = "application/plain"
	HeaderValueFull     = "application/octet-stream"
	HeaderValueHalf     = "application/x-binary"
)
View Source
const (
	ActionCreate    byte = 0x00
	ActionData      byte = 0x01
	ActionDelete    byte = 0x02
	ActionHeartbeat byte = 0x03
)

Variables

This section is empty.

Functions

func BuildBody added in v1.0.0

func BuildBody(m map[string][]byte) []byte

func Marshal added in v1.0.0

func Marshal(m map[string][]byte) []byte

定义一个最简的序列化协议,k,v 交替,每一项是len+data 其中 k 最长 255,v 最长 MaxUInt32

func NewActionCreate added in v1.0.0

func NewActionCreate(id, addr string, port uint16, redirect string) map[string][]byte

func NewActionData added in v1.0.0

func NewActionData(id string, data []byte, redirect string) map[string][]byte

func NewDelete added in v1.0.0

func NewDelete(id string, redirect string) map[string][]byte

func NewFullChunkedReadWriter added in v1.0.0

func NewFullChunkedReadWriter(id string, reqBody io.WriteCloser, serverResp io.ReadCloser) io.ReadWriteCloser

NewFullChunkedReadWriter 全双工读写流

func NewHalfChunkedReadWriter added in v1.0.0

func NewHalfChunkedReadWriter(ctx context.Context, id string, client *http.Client, method, target string,
	serverResp io.ReadCloser, baseHeader http.Header, redirect string) io.ReadWriteCloser

NewHalfChunkedReadWriter 半双工读写流, 用发送请求的方式模拟写

func NewHeartbeat added in v1.0.0

func NewHeartbeat(id string, redirect string) map[string][]byte

func NewHeartbeatRW added in v1.0.0

func NewHeartbeatRW(rw RawReadWriteCloser, id, redirect string) io.ReadWriteCloser

func NewRawClient added in v1.0.0

func NewRawClient(upstream string, timeout time.Duration) *rawhttp.Client

func NewSwitchableCookieJar added in v1.0.0

func NewSwitchableCookieJar(hintKey []string) http.CookieJar

func RandString added in v1.0.0

func RandString(n int) string

func Unmarshal added in v1.0.0

func Unmarshal(bs []byte) (map[string][]byte, error)

Types

type ConnectionType added in v1.0.0

type ConnectionType string
const (
	Undefined  ConnectionType = "undefined"
	AutoDuplex ConnectionType = "auto"
	FullDuplex ConnectionType = "full"
	HalfDuplex ConnectionType = "half"
)

type RawReadWriteCloser added in v1.0.0

type RawReadWriteCloser interface {
	io.ReadWriteCloser
	WriteRaw(p []byte) (n int, err error)
}

type Suo5Client

type Suo5Client struct {
	Proxy *url.URL
	Conf  *Suo5Conf
}

func (*Suo5Client) Dial

func (c *Suo5Client) Dial(network, address string) (net.Conn, error)

Dial 实现了Client接口

type Suo5Conf

type Suo5Conf struct {
	*Suo5Config
	// contains filtered or unexported fields
}

func NewConfFromURL

func NewConfFromURL(proxyURL *url.URL) (*Suo5Conf, error)

NewConfFromURL 从URL中解析用户名密码生成配置

type Suo5Config added in v1.0.0

type Suo5Config struct {
	Method           string         `json:"method"`
	Listen           string         `json:"listen"`
	Target           string         `json:"target"`
	NoAuth           bool           `json:"no_auth"`
	Username         string         `json:"username"`
	Password         string         `json:"password"`
	Mode             ConnectionType `json:"mode"`
	BufferSize       int            `json:"buffer_size"`
	Timeout          int            `json:"timeout"`
	Debug            bool           `json:"debug"`
	UpstreamProxy    string         `json:"upstream_proxy"`
	Upstream         func(ctx context.Context, network, address string) (net.Conn, error)
	RedirectURL      string   `json:"redirect_url"`
	RawHeader        []string `json:"raw_header"`
	DisableHeartbeat bool     `json:"disable_heartbeat"`
	DisableGzip      bool     `json:"disable_gzip"`
	EnableCookieJar  bool     `json:"enable_cookiejar"`
	ExcludeDomain    []string `json:"exclude_domain"`

	TestExit     string      `json:"-"`
	ExcludeGlobs []glob.Glob `json:"-"`
	Offset       int         `json:"-"`
	Header       http.Header `json:"-"`
}

func DefaultSuo5Config added in v1.0.0

func DefaultSuo5Config() *Suo5Config

func (*Suo5Config) HeaderString added in v1.0.0

func (s *Suo5Config) HeaderString() string

func (*Suo5Config) Parse added in v1.0.0

func (s *Suo5Config) Parse() error

type SwitchableCookieJar added in v1.0.0

type SwitchableCookieJar struct {
	http.CookieJar
	// contains filtered or unexported fields
}

func (*SwitchableCookieJar) Cookies added in v1.0.0

func (f *SwitchableCookieJar) Cookies(u *url.URL) []*http.Cookie

func (*SwitchableCookieJar) SetCookies added in v1.0.0

func (f *SwitchableCookieJar) SetCookies(u *url.URL, cookies []*http.Cookie)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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