socks5

package module
v0.0.0-...-21bd28b Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 5 Imported by: 0

README

go.socks5

这是在拥有特定场景情况下使用的socks5服务程序

  • 场景1:

    1. 有个只能 windows 连的 vpn
    2. 开个windows,把 socks5 代理服务一放上去
    3. 然后我在我的linux机器上用 socks5 代理上网
  • 这是 Makefile 内容

    1. 你可以执行 make 构建出所有目标机器的可执行文件

    2. 你可以执行 make linux 来只构建 linux amd64(x86_64) 架构的程序

      all: linux windows macos
          @echo builded
      
      windows:
          GOOS=windows GOARCH=amd64 go build -o bin/socks5-windows.exe cmd/main.go
      
      linux:
          GOOS=linux GOARCH=amd64 go build -o bin/socks5-linux cmd/main.go
      
      macos:
          GOOS=darwin GOARCH=amd64 go build -o bin/socks5-darwin cmd/main.go
      
  • 已实现部分

    1. 基于 tcp socket, 也仅实现了 tcp 代理
    2. 使用无验证方式,虽然协议中有各种验证方案
    3. 相比原始从 BV1qA4y1D74u 视频中增加了坑爆破访问,也就是一些小细节处。

Documentation

Index

Constants

View Source
const (
	IPv4Length = 4
	IPv6Length = 16
	PortLength = 2
)
View Source
const (
	SOCKS5_VERSION = 0x05
	REVERSED_FIELD = 0x00
)

Variables

View Source
var (
	// ErrorVersionNotSupported 不支持的协议版本
	ErrorVersionNotSupported = errors.New("protocal version not supported")

	// ErrorCommandNotSupported 不支持的指令
	ErrorCommandNotSupported = errors.New("request command not supported")

	// ErrorReservedFieldInvalid 不支持的保留字段
	ErrorReservedFieldInvalid = errors.New("invalid reserved field")

	// ErrorAddressTypeNotSupported 不支持的地址类型
	ErrorAddressTypeNotSupported = errors.New("address type not supported")
)

Functions

func NewServerAuthMessage

func NewServerAuthMessage(conn io.Writer, method Method) error

func WriteRequestFailureMessage

func WriteRequestFailureMessage(conn io.Writer, replyType ReplyType) error

func WriteRequestSuccessMessage

func WriteRequestSuccessMessage(conn io.Writer, ip net.IP, port uint16) error

Types

type AddressType

type AddressType = byte
const (
	TypeIPv4   AddressType = 0x01
	TypeDomain AddressType = 0x03
	TypeIPv6   AddressType = 0x04
)

type ClientAuthMessage

type ClientAuthMessage struct {
	Version  byte
	NMethods byte
	Methods  []Method
}

func NewClientAuthMessage

func NewClientAuthMessage(conn io.Reader) (*ClientAuthMessage, error)

type ClientRequestMessage

type ClientRequestMessage struct {
	// Version  byte
	Cmd      Command
	AddrType AddressType
	Address  string
	Port     uint16
}

func NewClientRequestMessage

func NewClientRequestMessage(conn io.Reader) (*ClientRequestMessage, error)

type Command

type Command = byte
const (
	CmdConnect Command = 0x01
	CmdBind    Command = 0x02
	CmdUDP     Command = 0x3
)

type Method

type Method = byte
const (
	MethodNoAuth       Method = 0x00
	MethodGSSAPI       Method = 0x01
	MethodPassword     Method = 0x02
	MethodNoAcceptable Method = 0xff
)

type ReplyType

type ReplyType = byte
const (
	ReplySuccess ReplyType = iota
	ReplyServerFailure
	ReplyConnectNotAllowed
	ReplyNetworkUnreachable
	ReplyHostUnreachable
	ReplyConnectionRefused
	ReplyTTLException
	ReplyCommandNotSupported
	ReplyAddressTypeNotSupported
)

type Server

type Server interface {
	Run() error
}

type Socks5Server

type Socks5Server struct {
	IP   string
	Port int
}

func (*Socks5Server) Run

func (s *Socks5Server) Run() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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