ss

package
v0.0.0-...-277102e Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: GPL-3.0 Imports: 28 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckBasicConfig

func CheckBasicConfig(c *Config)

func CheckConfig

func CheckConfig(c *Config)

func CheckConn

func CheckConn(conn net.Conn) bool

CheckConn Check the Conn whether is still alive

func CheckLogFile

func CheckLogFile(c *Config)

func DupBuffer

func DupBuffer(b []byte) (b2 []byte)

func GetHeader

func GetHeader(host string, port int) (buf []byte, err error)

func GetInnerConn

func GetInnerConn(conn net.Conn) (c net.Conn, err error)

func GetNetTCPConn

func GetNetTCPConn(conn net.Conn) (c *net.TCPConn, err error)

func GetRandomBytes

func GetRandomBytes(len int) []byte

func ListenMultiSS

func ListenMultiSS(service string, c *Config) (lis net.Listener, err error)

func ListenRedir

func ListenRedir(address string, c *Config) (lis net.Listener, err error)

func ListenSS

func ListenSS(service string, c *Config) (lis net.Listener, err error)

func ListenSocks5

func ListenSocks5(address string, c *Config) (lis net.Listener, err error)

func ListenTCPTun

func ListenTCPTun(address string, c *Config) (lis net.Listener, err error)

func NewListener

func NewListener(lis *net.TCPListener, c *Config, handlers []listenHandler) *listener

func NewSSDialer

func NewSSDialer(c *Config) func(string) (net.Conn, error)

func NewTCPDialer

func NewTCPDialer() func(string) (net.Conn, error)

func ParseAddrWithMultipleBackends

func ParseAddrWithMultipleBackends(b []byte, configs []*Config) (*parseContext, error)

func Pipe

func Pipe(c1, c2 net.Conn, c *Config)

func PutHeader

func PutHeader(b []byte, host string, port int) (n int)

func PutRandomBytes

func PutRandomBytes(b []byte)

func SliceCopy

func SliceCopy(b []byte) []byte

func StoreServiceHandler

func StoreServiceHandler(addr string, handler listenHandler)

StoreServiceHandler stores the handler to services map with key addr

Types

type Acceptor

type Acceptor func(net.Conn) net.Conn

func GetShadowAcceptor

func GetShadowAcceptor(args map[string]interface{}) Acceptor

type Addr

type Addr interface {
	Host() string
	Port() string
	Header() []byte
	String() string
}

type Config

type Config struct {
	Nickname       string    `json:"nickname"`
	Type           string    `json:"type"`
	Localaddr      string    `json:"localaddr"`
	Localaddrs     []string  `json:"localaddrs"`
	Remoteaddr     string    `json:"remoteaddr"`
	Method         string    `json:"method"`
	Password       string    `json:"password"`
	Nonop          bool      `json:"nonop"`
	AllowHTTP      bool      `json:"allow_http"`
	UDPRelay       bool      `json:"udprelay"`
	Backend        *Config   `json:"backend"`
	Backends       []*Config `json:"backends"`
	Verbose        bool      `json:"verbose"`
	Debug          bool      `json:"debug"`
	LogFile        string    `json:"logfile"`
	Obfs           bool      `json:"obfs"`
	ObfsMethod     string    `json:"obfsmethod"`
	ObfsHost       []string  `json:"obfshost"`
	ObfsAlive      bool      `json:"obfsalive"`
	Limit          int       `json:"limit"`
	LimitPerConn   int       `json:"limitperconn"`
	LogHTTP        bool      `json:"loghttp"`
	Timeout        int       `json:"timeout"`
	FilterCapacity int       `json:"filtcap"`
	AutoProxy      bool      `json:"autoproxy"`
	ProxyList      string    `json:"proxylist"`
	BlackList      string    `json:"blacklist"`
	DumpList       bool      `json:"dumplist"`
	ChnList        string    `json:"chnlist"`
	UseMul         bool      `json:"usemul"`
	UseUDP         bool      `json:"useudp"`
	Direct         bool      `json:"direct"`
	MulConn        int       `json:"mulconn"`
	FakeTCPAddr    string    `json:"faketcpaddr"`
	Safe           bool      `json:"safe"`
	MITM           bool      `json:"mitm"`
	DataShard      int       `json:"datashard"`
	ParityShard    int       `json:"parityshard"`
	SSProxy        bool      `json:"ssproxy"`

	Vlogger *log.Logger
	Dlogger *log.Logger
	Logger  *log.Logger

	TargetMap map[string]string `json:"target_map"`
	Ivlen     int
	Any       interface{}
	Die       chan bool
	// contains filtered or unexported fields
}

func ReadConfig

func ReadConfig(path string) (configs []*Config, err error)

func (*Config) CallOnClosed

func (c *Config) CallOnClosed(f cb)

func (*Config) Close

func (c *Config) Close() error

func (*Config) Log

func (c *Config) Log(v ...interface{})

func (*Config) LogD

func (c *Config) LogD(v ...interface{})

func (*Config) LogV

func (c *Config) LogV(v ...interface{})

type Conn

type Conn interface {
	utils.Conn
	GetCfg() *Config
	SetDst(Addr)
	GetDst() Addr
	GetHost() string
}

func DecayRemainConn

func DecayRemainConn(conn Conn) Conn

func DialObfs

func DialObfs(target string, c *Config) (conn Conn, err error)

func DialSSWithOptions

func DialSSWithOptions(opt *DialOptions) (conn Conn, err error)

func DialTCPConn

func DialTCPConn(address string, cfg *cfg) (Conn, error)

func DialUDP

func DialUDP(c *Config) (conn Conn, err error)

func DialWsConn

func DialWsConn(address, host string, cfg *cfg) (Conn, error)

func GetConn

func GetConn(conn net.Conn) (c Conn)

type ConnPool

type ConnPool struct {
	// contains filtered or unexported fields
}

func NewConnPool

func NewConnPool() *ConnPool

func (*ConnPool) Close

func (p *ConnPool) Close() (err error)

func (*ConnPool) Get

func (p *ConnPool) Get() (conn Conn, err error)

func (*ConnPool) GetNonblock

func (p *ConnPool) GetNonblock() (conn Conn, err error)

func (*ConnPool) Put

func (p *ConnPool) Put(conn Conn) (err error)

type DebugConn

type DebugConn struct {
	Conn
	// contains filtered or unexported fields
}

func NewDebugConn

func NewDebugConn(conn Conn, c *Config) *DebugConn

func (*DebugConn) Read

func (c *DebugConn) Read(b []byte) (n int, err error)

func (*DebugConn) Write

func (c *DebugConn) Write(b []byte) (n int, err error)

type DialOptions

type DialOptions struct {
	RawHeader []byte
	Data      []byte
	C         *Config
	Target    string
	Timeout   int
}

type DstAddr

type DstAddr struct {
	// contains filtered or unexported fields
}

func (*DstAddr) Header

func (d *DstAddr) Header() []byte

func (*DstAddr) Host

func (d *DstAddr) Host() string

func (*DstAddr) Port

func (d *DstAddr) Port() string

func (*DstAddr) String

func (d *DstAddr) String() string

type HttpLogConn

type HttpLogConn struct {
	Conn
	// contains filtered or unexported fields
}

func NewHttpLogConn

func NewHttpLogConn(conn Conn, c *Config) *HttpLogConn

func (*HttpLogConn) Close

func (conn *HttpLogConn) Close() error

func (*HttpLogConn) Read

func (conn *HttpLogConn) Read(b []byte) (n int, err error)

func (*HttpLogConn) Write

func (conn *HttpLogConn) Write(b []byte) (n int, err error)

type LimitConn

type LimitConn struct {
	Conn
	Rlimiters []*Limiter
	Wlimiters []*Limiter
}

func GetLimitConn

func GetLimitConn(conn net.Conn) (l *LimitConn, err error)

func (*LimitConn) Read

func (c *LimitConn) Read(b []byte) (n int, err error)

func (*LimitConn) Write

func (c *LimitConn) Write(b []byte) (n int, err error)

func (*LimitConn) WriteBuffers

func (c *LimitConn) WriteBuffers(b [][]byte) (n int, err error)

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

func NewLimiter

func NewLimiter(limit int) *Limiter

func (*Limiter) GetLimit

func (l *Limiter) GetLimit() int

func (*Limiter) GetTotalBytes

func (l *Limiter) GetTotalBytes() int64

func (*Limiter) SetLimit

func (l *Limiter) SetLimit(limit int)

func (*Limiter) Update

func (l *Limiter) Update(nbytes int)

type MultiUDPConn

type MultiUDPConn struct {
	net.PacketConn
	// contains filtered or unexported fields
}

func ListenMultiUDP

func ListenMultiUDP(c *Config) (*MultiUDPConn, error)

func NewMultiUDPConn

func NewMultiUDPConn(conn net.PacketConn, c *Config) *MultiUDPConn

func (*MultiUDPConn) ReadFrom

func (c *MultiUDPConn) ReadFrom(b []byte) (n int, addr net.Addr, err error)

func (*MultiUDPConn) RemoveAddr

func (c *MultiUDPConn) RemoveAddr(addr net.Addr)

func (*MultiUDPConn) WriteTo

func (c *MultiUDPConn) WriteTo(b []byte, addr net.Addr) (n int, err error)

type ObfsConn

type ObfsConn struct {
	RemainConn
	// contains filtered or unexported fields
}

func NewObfsConn

func NewObfsConn(conn Conn) *ObfsConn

func (*ObfsConn) Close

func (c *ObfsConn) Close() (err error)

func (*ObfsConn) Read

func (c *ObfsConn) Read(b []byte) (n int, err error)

func (*ObfsConn) Write

func (c *ObfsConn) Write(b []byte) (n int, err error)

func (*ObfsConn) WriteBuffers

func (c *ObfsConn) WriteBuffers(b [][]byte) (n int, err error)

type RemainConn

type RemainConn struct {
	Conn
	// contains filtered or unexported fields
}

func GetRemainConn

func GetRemainConn(conn net.Conn) (r *RemainConn, err error)

func (*RemainConn) Read

func (c *RemainConn) Read(b []byte) (n int, err error)

func (*RemainConn) Write

func (c *RemainConn) Write(b []byte) (n int, err error)

func (*RemainConn) WriteBuffers

func (c *RemainConn) WriteBuffers(b [][]byte) (n int, err error)

type SimpleHTTPConn

type SimpleHTTPConn struct {
	Conn
	// contains filtered or unexported fields
}

func (*SimpleHTTPConn) Close

func (conn *SimpleHTTPConn) Close() error

func (*SimpleHTTPConn) Read

func (conn *SimpleHTTPConn) Read(b []byte) (n int, err error)

func (*SimpleHTTPConn) Write

func (conn *SimpleHTTPConn) Write(b []byte) (n int, err error)

func (*SimpleHTTPConn) WriteBuffers

func (conn *SimpleHTTPConn) WriteBuffers(bufs [][]byte) (n int, err error)

type SimpleTLSConn

type SimpleTLSConn struct {
	Conn
	// contains filtered or unexported fields
}

func (*SimpleTLSConn) Read

func (conn *SimpleTLSConn) Read(b []byte) (n int, err error)

func (*SimpleTLSConn) Write

func (conn *SimpleTLSConn) Write(b []byte) (n int, err error)

func (*SimpleTLSConn) WriteBuffers

func (conn *SimpleTLSConn) WriteBuffers(b [][]byte) (n int, err error)

type SockAddr

type SockAddr struct {
	// contains filtered or unexported fields
}

func ParseAddr

func ParseAddr(b []byte) (addr *SockAddr, data []byte, err error)

func (*SockAddr) Header

func (s *SockAddr) Header() []byte

func (*SockAddr) Host

func (s *SockAddr) Host() string

func (*SockAddr) Port

func (s *SockAddr) Port() string

func (*SockAddr) PortNum

func (s *SockAddr) PortNum() int

func (*SockAddr) String

func (s *SockAddr) String() string

type SsConn

type SsConn struct {
	Conn
	// contains filtered or unexported fields
}

func GetSsConn

func GetSsConn(conn net.Conn) (c *SsConn, err error)

func (*SsConn) Close

func (c *SsConn) Close() error

func (*SsConn) GetConfig

func (c *SsConn) GetConfig() *Config

func (*SsConn) Read

func (c *SsConn) Read(b []byte) (n int, err error)

func (*SsConn) Write

func (c *SsConn) Write(b []byte) (n int, err error)

func (*SsConn) WriteBuffers

func (c *SsConn) WriteBuffers(bufs [][]byte) (n int, err error)

func (*SsConn) Xu0s

func (c *SsConn) Xu0s()

func (*SsConn) Xu1s

func (c *SsConn) Xu1s()

type TCPConn

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

func DialTCP

func DialTCP(address string, cfg *cfg) (*TCPConn, error)

func GetTCPConn

func GetTCPConn(conn net.Conn) (c *TCPConn, err error)

func (*TCPConn) GetCfg

func (ctx *TCPConn) GetCfg() *Config

func (*TCPConn) GetDst

func (ctx *TCPConn) GetDst() Addr

func (*TCPConn) GetHost

func (ctx *TCPConn) GetHost() string

func (*TCPConn) SetDst

func (ctx *TCPConn) SetDst(dst Addr)

func (*TCPConn) SetHost

func (ctx *TCPConn) SetHost(host string)

type UDPConn

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

func ListenUDP

func ListenUDP(c *Config) (*UDPConn, error)

func NewUDPConn1

func NewUDPConn1(conn utils.UDPConn, c *Config) *UDPConn

func NewUDPConn2

func NewUDPConn2(conn net.Conn, c *Config) *UDPConn

func NewUDPConn3

func NewUDPConn3(conn net.PacketConn, c *Config) *UDPConn

func (*UDPConn) Close

func (c *UDPConn) Close() error

func (*UDPConn) GetCfg

func (c *UDPConn) GetCfg() *Config

func (*UDPConn) GetDst

func (ctx *UDPConn) GetDst() Addr

func (*UDPConn) GetHost

func (ctx *UDPConn) GetHost() string

func (*UDPConn) LocalAddr

func (c *UDPConn) LocalAddr() net.Addr

func (*UDPConn) Read

func (c *UDPConn) Read(b []byte) (n int, err error)

func (*UDPConn) ReadFrom

func (c *UDPConn) ReadFrom(b []byte) (n int, addr net.Addr, err error)

func (*UDPConn) RemoteAddr

func (c *UDPConn) RemoteAddr() net.Addr

func (*UDPConn) SetDeadline

func (c *UDPConn) SetDeadline(t time.Time) error

func (*UDPConn) SetDst

func (ctx *UDPConn) SetDst(dst Addr)

func (*UDPConn) SetHost

func (ctx *UDPConn) SetHost(host string)

func (*UDPConn) SetReadDeadline

func (c *UDPConn) SetReadDeadline(t time.Time) error

func (*UDPConn) SetWriteDeadline

func (c *UDPConn) SetWriteDeadline(t time.Time) error

func (*UDPConn) Write

func (c *UDPConn) Write(b []byte) (n int, err error)

func (*UDPConn) WriteBuffers

func (c *UDPConn) WriteBuffers(bufs [][]byte) (n int, err error)

func (*UDPConn) WriteTo

func (c *UDPConn) WriteTo(b []byte, addr net.Addr) (n int, err error)

type UDPTProxyConn

type UDPTProxyConn struct {
	*net.UDPConn
}

func NewUDPTProxyConn

func NewUDPTProxyConn(conn *net.UDPConn) (*UDPTProxyConn, error)

func (*UDPTProxyConn) Read

func (conn *UDPTProxyConn) Read(b []byte) (n int, err error)

func (*UDPTProxyConn) ReadFrom

func (conn *UDPTProxyConn) ReadFrom(b []byte) (n int, addr net.Addr, err error)

Jump to

Keyboard shortcuts

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