Documentation ¶
Index ¶
- type ILimiter
- type IRequest
- type Listener
- type Request
- func (r *Request) Close() error
- func (r *Request) GetRequestId() string
- func (r *Request) LocalAddr() net.Addr
- func (r *Request) RemoteAddr() net.Addr
- func (r *Request) SetDeadline(t time.Time) error
- func (r *Request) SetKeepAlive(keepAlive bool) error
- func (r *Request) SetReadDeadline(t time.Time) error
- func (r *Request) SetWriteDeadline(t time.Time) error
- type ShadowsocksRDecorate
- func (ssrd *ShadowsocksRDecorate) Read(buf []byte) (n int, err error)
- func (ssrd *ShadowsocksRDecorate) ReadFrom() (data, uid []byte, addr net.Addr, err error)
- func (ssrd *ShadowsocksRDecorate) SetLimter(limiter ILimiter)
- func (ssrd *ShadowsocksRDecorate) UpdateUser(uid []byte)
- func (ssrd *ShadowsocksRDecorate) Write(buf []byte) (n int, err error)
- func (ssrd *ShadowsocksRDecorate) WriteTo(p, uid []byte, addr net.Addr) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Listener ¶
type Listener struct { Addr string Timeout time.Duration TCP *net.TCPListener UDP net.PacketConn context.Context }
Example ¶
listener := NewListener("127.0.0.1:1000", 5*time.Second) listener.ListenUDP(func(request *Request) { for { buf := make([]byte, 2048) _, _, err := request.ReadFrom(buf) if err != nil { if strings.Contains(err.Error(), " use of closed network connection") { println(err.Error()) return } log.Err(err) } log.Info(string(buf)) } }) listener.ListenTCP(func(request *Request) { buf := make([]byte, 2048) for { n, err := request.Read(buf) if err != nil { log.Err(err) } log.Info(string(buf[:n])) } }) osx.WaitSignal() println("close listener") listener.Close() osx.WaitSignal()
Output:
type Request ¶
type Request struct { ISStream bool net.Conn net.PacketConn RequestID string RequestTime time.Time Data interface{} }
func NewRequestWithTCP ¶
func NewRequestWithUDP ¶
func NewRequestWithUDP(con net.PacketConn) *Request
func (*Request) GetRequestId ¶
func (*Request) RemoteAddr ¶
func (*Request) SetKeepAlive ¶
type ShadowsocksRDecorate ¶
type ShadowsocksRDecorate struct { *Request UID int Host string Port int ObfsParam string ProtocolParam string Users map[string]string Overhead int ISLocal bool common.TrafficReport ILimiter *sync.Mutex // contains filtered or unexported fields }
func NewShadowsocksRDecorate ¶
func (*ShadowsocksRDecorate) Read ¶
func (ssrd *ShadowsocksRDecorate) Read(buf []byte) (n int, err error)
func (*ShadowsocksRDecorate) ReadFrom ¶
func (ssrd *ShadowsocksRDecorate) ReadFrom() (data, uid []byte, addr net.Addr, err error)
func (*ShadowsocksRDecorate) SetLimter ¶
func (ssrd *ShadowsocksRDecorate) SetLimter(limiter ILimiter)
func (*ShadowsocksRDecorate) UpdateUser ¶
func (ssrd *ShadowsocksRDecorate) UpdateUser(uid []byte)
Click to show internal directories.
Click to hide internal directories.