Documentation ¶
Index ¶
- Constants
- Variables
- func DebugLog(format string, args ...interface{})
- func ErrorLog(format string, args ...interface{})
- func InfoLog(format string, args ...interface{})
- func Now() int64
- func ReadJSON(filename string, v interface{}) (err error)
- func SHA1(data []byte) string
- func SetLogLevel(l int)
- func WarnLog(format string, args ...interface{})
- func WriteJSON(filename string, v interface{}) (err error)
- type BaseConn
- type Client
- type Conn
- type Dialer
- type DialerF
- type JSONFileAuth
- func (j *JSONFileAuth) AddUser(res http.ResponseWriter, req *http.Request)
- func (j *JSONFileAuth) BasicAuth(req *http.Request) (ok bool, err error)
- func (j *JSONFileAuth) ListUser(res http.ResponseWriter, req *http.Request)
- func (j *JSONFileAuth) RemoveUser(res http.ResponseWriter, req *http.Request)
- type NetDialer
- type PipedConn
- func (p *PipedConn) Close() (err error)
- func (p *PipedConn) LocalAddr() net.Addr
- func (p *PipedConn) Network() string
- func (p *PipedConn) RemoteAddr() net.Addr
- func (p *PipedConn) SetDeadline(t time.Time) error
- func (p *PipedConn) SetReadDeadline(t time.Time) error
- func (p *PipedConn) SetWriteDeadline(t time.Time) error
- func (p *PipedConn) String() string
- type Server
- type SocksProxy
- type SortedDialer
- type Statable
- type StringConn
- type TCPKeepAliveListener
- type WebsocketDialer
Constants ¶
const ( //CmdConnDial is cs protocol command for dial connection CmdConnDial = 0x10 //CmdConnBack is cs protocol command for dial connection back CmdConnBack = 0x20 //CmdConnData is cs protocol command for transfer data CmdConnData = 0x30 //CmdConnClose is cs protocol command for connection close CmdConnClose = 0x40 )
const ( //LogLevelDebug is debug log level LogLevelDebug = 40 //LogLevelInfo is info log level LogLevelInfo = 30 //LogLevelWarn is warn log level LogLevelWarn = 20 //LogLevelError is error log level LogLevelError = 10 )
const (
//DefaultBufferSize is default buffer size
DefaultBufferSize = 64 * 1024
)
Variables ¶
var BasePipe = os.Pipe
BasePipe is func to create os pipe
Functions ¶
Types ¶
type BaseConn ¶
type BaseConn struct { Err error // contains filtered or unexported fields }
BaseConn imple read/write raw connection by command mode
func NewBaseConn ¶
func NewBaseConn(raw io.ReadWriter, bufferSize int) (conn *BaseConn)
NewBaseConn will create new Conn by raw reader/writer and buffer size
type Client ¶
type Client struct { BufferSize int Dialer Dialer HTTPClient *http.Client // contains filtered or unexported fields }
Client is normal client for implement dark socket protocl
type Conn ¶
type Conn interface { ID() uint64 ReadCmd() (cmd []byte, err error) WriteCmd(cmd []byte) (w int, err error) Close() (err error) SetErr(err error) PreErr() (err error) }
Conn is interface for read/write raw connection by command mode
type Dialer ¶
type Dialer interface {
Dial(remote string) (raw io.ReadWriteCloser, err error)
}
Dialer is interface for dial raw connect by string
type DialerF ¶
type DialerF func(remote string) (raw io.ReadWriteCloser, err error)
DialerF is an the implementation of Dialer by func
type JSONFileAuth ¶
type JSONFileAuth struct { FileName string // contains filtered or unexported fields }
JSONFileAuth is the basic auth impl
func NewJSONFileAuth ¶
func NewJSONFileAuth(adimUser map[string]string, filename string) (auth *JSONFileAuth)
NewJSONFileAuth return new JSONFileAuth, it will read the users from json file
func (*JSONFileAuth) AddUser ¶
func (j *JSONFileAuth) AddUser(res http.ResponseWriter, req *http.Request)
AddUser will add user to json file
func (*JSONFileAuth) BasicAuth ¶
func (j *JSONFileAuth) BasicAuth(req *http.Request) (ok bool, err error)
BasicAuth will auth by http basic auth
func (*JSONFileAuth) ListUser ¶
func (j *JSONFileAuth) ListUser(res http.ResponseWriter, req *http.Request)
ListUser will list user as html page
func (*JSONFileAuth) RemoveUser ¶
func (j *JSONFileAuth) RemoveUser(res http.ResponseWriter, req *http.Request)
RemoveUser will remove user to json file
type PipedConn ¶
type PipedConn struct { io.Reader io.Writer Alias string // contains filtered or unexported fields }
PipedConn is connection piped read and write
func CreatePipeConn ¶
CreatePipeConn will create pipe connection
func (*PipedConn) RemoteAddr ¶
RemoteAddr is net.Conn impl
func (*PipedConn) SetDeadline ¶
SetDeadline is net.Conn impl
func (*PipedConn) SetReadDeadline ¶
SetReadDeadline is net.Conn impl
func (*PipedConn) SetWriteDeadline ¶
SetWriteDeadline is net.Conn impl
type Server ¶
Server is the main implementation for dark socks
type SocksProxy ¶
type SocksProxy struct { net.Listener Dialer func(uri string, raw io.ReadWriteCloser) (sid uint64, err error) HTTPUpstream string }
SocksProxy is an implementation of socks5 proxy
func NewSocksProxy ¶
func NewSocksProxy() (socks *SocksProxy)
NewSocksProxy will return new SocksProxy
type SortedDialer ¶
type SortedDialer struct { RateTolerance float32 SortDelay int64 // contains filtered or unexported fields }
SortedDialer will auto sort the dialer by used time/error rate
func NewSortedDialer ¶
func NewSortedDialer(dialers ...Dialer) (dialer *SortedDialer)
NewSortedDialer will new sorted dialer by sub dialer
func (*SortedDialer) Dial ¶
func (s *SortedDialer) Dial(remote string) (raw io.ReadWriteCloser, err error)
Dial impl the Dialer
func (*SortedDialer) Len ¶
func (s *SortedDialer) Len() int
Len is the number of elements in the collection.
func (*SortedDialer) Less ¶
func (s *SortedDialer) Less(i, j int) (r bool)
Less reports whether the element with index i should sort before the element with index j.
func (*SortedDialer) State ¶
func (s *SortedDialer) State() interface{}
State will return current dialer state
func (*SortedDialer) Swap ¶
func (s *SortedDialer) Swap(i, j int)
Swap swaps the elements with indexes i and j.
type Statable ¶
type Statable interface {
State() interface{}
}
Statable is interface for load object state
type StringConn ¶
type StringConn struct { Name string io.ReadWriteCloser }
StringConn is an ReadWriteCloser for return remote address info
func NewStringConn ¶
func NewStringConn(raw io.ReadWriteCloser) *StringConn
NewStringConn will return new StringConn
func (*StringConn) String ¶
func (s *StringConn) String() string
type TCPKeepAliveListener ¶
type TCPKeepAliveListener struct {
*net.TCPListener
}
TCPKeepAliveListener is normal tcp listner for set tcp connection keep alive
type WebsocketDialer ¶
type WebsocketDialer string
WebsocketDialer is an implementation of Dialer by websocket
func (WebsocketDialer) Dial ¶
func (w WebsocketDialer) Dial(remote string) (raw io.ReadWriteCloser, err error)
Dial dial to remote by websocket