vproxy

package module
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

vproxy Build Status

golang proxy, HTTP/HTTPS proxy server, HTTP/HTTPS 代理服务器

命令行:

-addr string
    代理服务器地 (format "0.0.0.0:8080")
-dataBufioSize int
    代理数据交换缓冲区大小,单位字节 (default 10240)
-idleConnTimeout int
    空闲连接超时时,单位毫秒 (default 0)
-linkPosterior
    支持连接式代理,如:http://111.222.333.444:8080/https://www.baidu.com/abc/file.zip
-log string
    日志文件(默认留空在控制台显示日志)  (format "./vproxy.txt")
-logLevel int
    日志级别,0)不记录 1)客户端IP 2)认证 3)访问的Host地址 4)路径 5)请求 6)响应 7)错误 (default 0)
-proxy string
    代理服务器的上级代理IP地址 (format "http://11.22.33.44:8888" or "socks5://admin:admin@11.22.33.44:1080")
-pwd string
    密码
-timeout int
    转发连接请求超时,单位毫秒 (default 300000)
-tlsCertFile string
    SSl证书文件
-tlsKeyFile string
    SSl密钥文件
-user string
    用户名

命令行例子:vproxy -addr 0.0.0.0:8080

列表:

type LogLevel int                                                                // 日志级别
const
    OriginAddr LogLevel    = iota+1                                              // 客户端。
    Authenticate                                                                 // 认证
    Host                                                                         // 访问的Host地址
    URI                                                                          // 路径
    Request                                                                      // 请求
    Response                                                                     // 响应
    Error                                                                        // 错误
)

type Proxy struct {                                                      // 代理
    LinkPosterior   bool                                                             // 支持连接后面的,如:http://192.168.2.31/http://www.baidu.com/
    DataBufioSize   int                                                              // 缓冲区大小
    Auth            func(username, password string) bool                             // 认证
    Addr        string                                                               // 代理IP地址
    Server      http.Server                                                          // 服务器
    DialContext func(ctx context.Context, network, address string) (net.Conn, error) // 拨号
    ErrorLog    *log.Logger                                                          // 日志
    ErrorLogLevel LogLevel                                                           // 日志级别
}
    func (p *Proxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)         // 处理
    func (p *Proxy) ListenAndServe() error                                       // 监听
    func (p *Proxy) Serve(l net.Listener) error                                  // 监听
    func (p *Proxy) Close() error                                                // 关闭代理

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogLevel

type LogLevel int
const (
	OriginAddr   LogLevel = iota + 1 // 登录 vproxy 每个请求的目标。
	Authenticate                     // 认证
	Host                             // 访问的Host地址
	URI                              // 路径
	Request                          // 显示报头解析
	Response                         // 日志写入到网络的所有数据
	Error                            // 非致命错误
)

type Proxy

type Proxy struct {
	// 这个支持单条连接。不要使用在浏览器中。
	// 支持:
	// http://192.168.2.31/http://www.baidu.com/
	// http://192.168.2.31/?url=http://www.baidu.com/
	LinkPosterior bool                                                                 // 支持连接后面的,如:http://192.168.2.31/http://www.baidu.com/
	DataBufioSize int                                                                  // 缓冲区大小
	Auth          func(username, password string) bool                                 // 认证
	Addr          string                                                               // 代理IP地址
	Server        http.Server                                                          // 服务器
	DialContext   func(ctx context.Context, network, address string) (net.Conn, error) // 拨号
	ErrorLog      *log.Logger                                                          // 日志
	ErrorLogLevel LogLevel                                                             // 日志级别

	Tr http.RoundTripper // 代理
	// contains filtered or unexported fields
}

func (*Proxy) Close

func (p *Proxy) Close() error

Close 关闭

返:
    error       错误

func (*Proxy) ListenAndServe added in v1.1.1

func (p *Proxy) ListenAndServe() error

ListenAndServe 开启监听

返:
    error       错误

func (*Proxy) Serve

func (p *Proxy) Serve(l net.Listener) error

Serve 开启监听

参:
    l net.Listener  监听对象
返:
    error           错误

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP 处理服务

rw http.ResponseWriter  响应
req *http.Request       请求

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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