Documentation ¶
Overview ¶
Package v2ray_simple provides a simple way to set up a proxy.
Structure 本项目结构 ¶
utils -> netLayer-> tlsLayer -> httpLayer -> advLayer -> proxy -> v2ray_simple -> cmd/verysimple
根项目 v2ray_simple 仅研究实际转发过程. 关于 代理的详细定义 请参考 proxy 子包的文档。
本项目是一个代理项目,最重要的事情就是 【如何转发流量】,所以主项目主要研究这个转发过程。
目前主要内容有:
ListenSer函数用于主要 代理的转发。内置了 lazy的转发逻辑。
Chain ¶
具体 转发过程 的 调用链 是 ListenSer -> handleNewIncomeConnection -> handshakeInserver_and_passToOutClient -> { handshakeInserver , passToOutClient -> [ ( checkfallback) -> dialClient_andRelay -> 「 dialClient ( -> dialInnerProxy ), netLayer.Relay / netLayer.RelayUDP 」 ] }
用 netLayer操纵路由,用tlsLayer嗅探tls,用httpLayer操纵回落,可选经过http头、高级层、innerMux, 都搞好后,进行 proxy 握手,然后就开始转发。
TLS Lazy Encryption - Lazy ¶
TLS Lazy Encryption 技术 可简称为 tls lazy encrypt, tls lazy 或者 lazy.
lazy 是一种 独特的 转发方式,所以也是在 本包中处理,而不是在proxy包中处理。 proxy包只负责定义,不负责实际转发。
lazy 与 xtls类似,在一定条件下可以利用内层tls加密直接传输数据,不在外面再包一层tls。
lazy与xtls的不同是,lazy不魔改tls包,所以是可以在 uTLS 的基础上 进行 lazy的,而且也没有 xtls的233漏洞。
目前lazy还在完善阶段。
Tags ¶
本包提供 noquic, grpc_full 这两个 build tag。
若 grpc_full 给出,则引用 advLayer/grpc 包,否则默认引用 advLayer/grpcSimple 包。
比较: grpcSimple 比 grpc 节省 大概 4MB 大小,而且支持回落到 h2c; 而 grpc包 支持 multiMode。
若 noquic给出,则不引用 advLayer/quic,否则 默认引用 advLayer/quic。 quic大概占用 2MB 大小。
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ActiveConnectionCount int32 AllDownloadBytesSinceStart uint64 AllUploadBytesSinceStart uint64 )
statistics
var (
//一个默认的 非 fullcone 的 direct Client
DirectClient, _ = proxy.ClientFromURL(proxy.DirectURL)
)
Functions ¶
func CanLazyEncrypt ¶ added in v1.2.2
func CanLazyEncrypt(x proxy.BaseInterface) bool
有TLS, network为tcp或者unix, 无AdvLayer. grpc 这种多路复用的链接是绝对无法开启 lazy的, ws 理论上也只有服务端发向客户端的链接 内嵌tls时可以lazy,但暂不考虑
func CanNetwork_tlsLazy ¶ added in v1.2.2
func ListenSer ¶
func ListenSer(inServer proxy.Server, defaultOutClient proxy.Client, env *proxy.RoutingEnv) (closer io.Closer)
ListenSer 函数 是本包 最重要的函数。可以 直接使用 本函数 来手动开启新的 自定义的 转发流程。 监听 inServer, 然后试图转发到一个 proxy.Client。如果env没给出,则会转发到 defaultOutClient。 若 env 不为 nil, 则会 进行分流或回落。具有env的情况下,可能会转发到 非 defaultOutClient 的其他 proxy.Client.
inServer and defaultOutClient must not be nil.
Use cases: refer to tcp_test.go, udp_test.go or cmd/verysimple.
non-blocking. closer used to stop listening. It means listening failed if closer == nil,
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package advLayer contains definitions and subpackages for Advanced Layer in VSI model.
|
Package advLayer contains definitions and subpackages for Advanced Layer in VSI model. |
grpcSimple
Package grpcSimple implements grpc tunnel without importing google.golang.org/grpc.
|
Package grpcSimple implements grpc tunnel without importing google.golang.org/grpc. |
quic
Package quic defines functions to listen and dial quic, with some customizable congestion settings.
|
Package quic defines functions to listen and dial quic, with some customizable congestion settings. |
ws
Package ws implements websocket for advLayer.
|
Package ws implements websocket for advLayer. |
cmd
|
|
verysimple
Package main 读取配置文件,然后进行代理转发, 并选择性运行 交互模式和 apiServer.
|
Package main 读取配置文件,然后进行代理转发, 并选择性运行 交互模式和 apiServer. |
package configAdapter provides methods to convert proxy.ListenConf and proxy.DialConf to some 3rd party formats.
|
package configAdapter provides methods to convert proxy.ListenConf and proxy.DialConf to some 3rd party formats. |
v2ray_v5
Package v2ray_v5 supports v2ray v5 config and convertion methods between vs standard toml config format See https://www.v2fly.org/v5/config/
|
Package v2ray_v5 supports v2ray v5 config and convertion methods between vs standard toml config format See https://www.v2fly.org/v5/config/ |
Package httpLayer provides methods for parsing and sending http request and response.
|
Package httpLayer provides methods for parsing and sending http request and response. |
Package netLayer contains definitions in network layer AND transport layer.
|
Package netLayer contains definitions in network layer AND transport layer. |
tproxy
Package tproxy listens tproxy and setup corresponding iptables for linux.
|
Package tproxy listens tproxy and setup corresponding iptables for linux. |
Package proxy defines necessary components for proxy.
|
Package proxy defines necessary components for proxy. |
dokodemo
Package dokodemo implements a dokodemo-door proxy.Server.
|
Package dokodemo implements a dokodemo-door proxy.Server. |
http
Package http implements http proxy for proxy.Server.
|
Package http implements http proxy for proxy.Server. |
shadowsocks
Package shadowsocks implements shadowsocks protocol.
|
Package shadowsocks implements shadowsocks protocol. |
simplesocks
Package simplesocks implements SimpleSocks (defined by trojan-go) protocol for proxy.Server and proxy.Client.
|
Package simplesocks implements SimpleSocks (defined by trojan-go) protocol for proxy.Server and proxy.Client. |
socks5
Package socks5 provies socks5 proxy for proxy.Client and proxy.Server.
|
Package socks5 provies socks5 proxy for proxy.Client and proxy.Server. |
socks5http
Package socks5http provides listening both socks5 and http at one port.
|
Package socks5http provides listening both socks5 and http at one port. |
tproxy
Package tproxy implements proxy.Server for tproxy.
|
Package tproxy implements proxy.Server for tproxy. |
trojan
Package trojan implements trojan protocol for proxy.Client and proxy.Server.
|
Package trojan implements trojan protocol for proxy.Client and proxy.Server. |
vless
Package vless implements vless v0/v1 for proxy.Client and proxy.Server.
|
Package vless implements vless v0/v1 for proxy.Client and proxy.Server. |
vmess
Package vmess implements vmess for proxy.Client and proxy.Server.
|
Package vmess implements vmess for proxy.Client and proxy.Server. |
Package tlsLayer provides facilities for tls, including uTls, sniffing and random certificate.
|
Package tlsLayer provides facilities for tls, including uTls, sniffing and random certificate. |
Package utils provides general utilities.
|
Package utils provides general utilities. |