ctrl

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 28 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 NewFullChunkedReadWriter

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

NewFullChunkedReadWriter 全双工读写流

func NewHalfChunkedReadWriter

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 NewHeartbeatRW added in v0.7.0

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

func NewSwitchableCookieJar added in v1.3.1

func NewSwitchableCookieJar(hintKey []string) http.CookieJar

func RandString

func RandString(n int) string

func Run

func Run(ctx context.Context, config *Suo5Config) error

Types

type ClientConnectCloseEvent

type ClientConnectCloseEvent struct {
	Conn net.Conn
}

type ClientConnectionEvent

type ClientConnectionEvent struct {
	Conn net.Conn
}

type ClientEventHandler

type ClientEventHandler struct {
	Inner                   server.Handler
	OnNewClientConnection   func(event *ClientConnectionEvent)
	OnClientConnectionClose func(event *ClientConnectCloseEvent)
}

func (*ClientEventHandler) Handle

func (e *ClientEventHandler) Handle(conn net.Conn) error

type ConnectedEvent

type ConnectedEvent struct {
	Mode ConnectionType `json:"mode"`
}

type ConnectionType

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

type RawReadWriteCloser added in v0.7.0

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

type Suo5Config

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"`
	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:"-"`
	OnRemoteConnected       func(e *ConnectedEvent)              `json:"-"`
	OnNewClientConnection   func(event *ClientConnectionEvent)   `json:"-"`
	OnClientConnectionClose func(event *ClientConnectCloseEvent) `json:"-"`
	GuiLog                  io.Writer                            `json:"-"`
}

func DefaultSuo5Config

func DefaultSuo5Config() *Suo5Config

func (*Suo5Config) HeaderString added in v1.3.0

func (s *Suo5Config) HeaderString() string

func (*Suo5Config) Parse added in v1.3.0

func (s *Suo5Config) Parse() error

type SwitchableCookieJar added in v1.3.1

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

func (*SwitchableCookieJar) Cookies added in v1.3.1

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

func (*SwitchableCookieJar) SetCookies added in v1.3.1

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

Jump to

Keyboard shortcuts

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