socks5 - SOCKS Protocol Version 5 Library in Go. Full TCP/UDP and IPv4/IPv6 support

栏目: IT技术 · 发布时间: 5年前

内容简介:SOCKS Protocol Version 5 Library.Full TCP/UDP and IPv4/IPv6 support. Goals: KISS, less is more, small API, code is like the original protocol.

socks5

SOCKS Protocol Version 5 Library.

Full TCP/UDP and IPv4/IPv6 support. Goals: KISS, less is more, small API, code is like the original protocol.

Install

$ go get github.com/txthinking/socks5

Struct is like concept in protocol

  • Negotiation:
    • type NegotiationRequest struct
      func NewNegotiationRequest(methods []byte)
      func (r *NegotiationRequest) WriteTo(w *net.TCPConn)
      func NewNegotiationRequestFrom(r *net.TCPConn)
      
    • type NegotiationReply struct
      func NewNegotiationReply(method byte)
      func (r *NegotiationReply) WriteTo(w *net.TCPConn)
      func NewNegotiationReplyFrom(r *net.TCPConn)
      
  • User and password negotiation:
    • type UserPassNegotiationRequest struct
      func NewUserPassNegotiationRequest(username []byte, password []byte)
      func (r *UserPassNegotiationRequest) WriteTo(w *net.TCPConn)
      func NewUserPassNegotiationRequestFrom(r *net.TCPConn)
      
    • type UserPassNegotiationReply struct
      func NewUserPassNegotiationReply(status byte)
      func (r *UserPassNegotiationReply) WriteTo(w *net.TCPConn)
      func NewUserPassNegotiationReplyFrom(r *net.TCPConn)
      
  • Request:
    • type Request struct
      func NewRequest(cmd byte, atyp byte, dstaddr []byte, dstport []byte)
      func (r *Request) WriteTo(w *net.TCPConn)
      func NewRequestFrom(r *net.TCPConn)
      
  • Reply:
    • type Reply struct
      func NewReply(rep byte, atyp byte, bndaddr []byte, bndport []byte)
      func (r *Reply) WriteTo(w *net.TCPConn)
      func NewReplyFrom(r *net.TCPConn)
      
  • Datagram:
    • type Datagram struct
      func NewDatagram(atyp byte, dstaddr []byte, dstport []byte, data []byte)
      func NewDatagramFromBytes(bb []byte) (*Datagram, error)
      func (d *Datagram) Bytes() []byte
      

Advanced API

You can process client's request by yourself after reading *Request from client. Also, here is a advanced interfaces.

  • type Server struct
  • type Handler interface
    TCPHandle(*Server, *net.TCPConn, *Request) error
    UDPHandle(*Server, *net.UDPAddr, *Datagram) error
    

This is example:

s, _ := NewClassicServer(addr, ip, username, password, tcpTimeout, tcpDeadline, udpDeadline, udpSessionTime)
s.Run(Handler)
  • If you want a standard socks5 server, pass in nil
  • If you want to handle data by yourself, pass in a custom Handler

Users:


以上所述就是小编给大家介绍的《socks5 - SOCKS Protocol Version 5 Library in Go. Full TCP/UDP and IPv4/IPv6 support》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

机器消灭秘密

机器消灭秘密

安迪•格林伯格 (Andy Greenberg) / 王崧、王涛、唐禾 / 重庆出版社 / 2017-8-10 / 49.8

《机器消灭秘密》一书中,格林伯格深入研究并生动再现了那些拥有全能技术的网络安全魔术师,他们将任何企图染指个人隐私的所谓国家机密的保密性打得粉碎。这本精心组织的著作是对此题材感兴趣的读者的必读之书,即便现在你可能不感兴趣,将来也极有可能希望了解这些内容,因为任何人都会不可避免地置身其中。无论你是初涉电脑屏幕之后的虚拟战场的新生,还是经验丰富的维基解密观察家,本书都是不可多得的上乘之作,你总会在其中发......一起来看看 《机器消灭秘密》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具