修订文档,将v2ray_simple中的proxy和adv子包引用转到cmd/verysimple中

v2ray_simple 包作为公共包,不应强制用户使用任何一种proxy
This commit is contained in:
e1732a364fed
2000-01-01 00:00:00 +00:00
parent f46acd08cf
commit ece4996342
9 changed files with 48 additions and 56 deletions
+18
View File
@@ -4,6 +4,13 @@ Package main 读取配置文件,然后进行代理转发, 并选择性运行 c
命令行参数请使用 --help / -h 查看详情,配置文件示例请参考 ../../examples/ .
如果一个命令行参数无法在标准配置中进行配置,那么它就属于高级/开发者选项,or 不推荐的选项,or 正在开发中的功能.
# Tags
提供 noquic,notun,gui 这几个 build tag。
若 noquic给出,则不引用 advLayer/quic,否则 默认引用 advLayer/quic。
quic大概占用 2MB 大小。
*/
package main
@@ -14,6 +21,17 @@ import (
"github.com/e1732a364fed/v2ray_simple/advLayer"
"github.com/e1732a364fed/v2ray_simple/netLayer"
_ "github.com/e1732a364fed/v2ray_simple/advLayer/grpcSimple"
_ "github.com/e1732a364fed/v2ray_simple/advLayer/ws"
_ "github.com/e1732a364fed/v2ray_simple/proxy/dokodemo"
_ "github.com/e1732a364fed/v2ray_simple/proxy/shadowsocks"
_ "github.com/e1732a364fed/v2ray_simple/proxy/simplesocks"
_ "github.com/e1732a364fed/v2ray_simple/proxy/socks5http" //该包自动引用 socks5 和 http
_ "github.com/e1732a364fed/v2ray_simple/proxy/trojan"
_ "github.com/e1732a364fed/v2ray_simple/proxy/vless"
_ "github.com/e1732a364fed/v2ray_simple/proxy/vmess"
)
const (
+3 -13
View File
@@ -3,7 +3,7 @@ Package v2ray_simple provides a simple way to set up a proxy.
# Structure 本项目结构
utils -> netLayer-> tlsLayer -> httpLayer -> advLayer -> proxy -> v2ray_simple -> cmd/verysimple
utils -> netLayer-> tlsLayer -> httpLayer -> advLayer -> proxy -> v2ray_simple -> machine -> cmd/verysimple
根项目 v2ray_simple 仅研究实际转发过程. 关于 代理的详细定义 请参考 proxy 子包的文档。
@@ -13,6 +13,8 @@ utils -> netLayer-> tlsLayer -> httpLayer -> advLayer -> proxy -> v2ray_simple -
ListenSer函数用于主要 代理的转发。内置了 lazy的转发逻辑。
使用方式可以阅读 tcp_test.go 和 udp_test.go
# Chain
具体 转发过程 的 调用链 是 ListenSer -> handleNewIncomeConnection ->
@@ -34,17 +36,5 @@ lazy 与 xtls类似,在一定条件下可以利用内层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 大小。
*/
package v2ray_simple
+1 -43
View File
@@ -21,17 +21,6 @@ import (
"github.com/e1732a364fed/v2ray_simple/proxy"
"github.com/e1732a364fed/v2ray_simple/tlsLayer"
"github.com/e1732a364fed/v2ray_simple/utils"
_ "github.com/e1732a364fed/v2ray_simple/advLayer/grpcSimple"
_ "github.com/e1732a364fed/v2ray_simple/advLayer/ws"
_ "github.com/e1732a364fed/v2ray_simple/proxy/dokodemo"
_ "github.com/e1732a364fed/v2ray_simple/proxy/shadowsocks"
_ "github.com/e1732a364fed/v2ray_simple/proxy/simplesocks"
_ "github.com/e1732a364fed/v2ray_simple/proxy/socks5http"
_ "github.com/e1732a364fed/v2ray_simple/proxy/trojan"
_ "github.com/e1732a364fed/v2ray_simple/proxy/vless"
_ "github.com/e1732a364fed/v2ray_simple/proxy/vmess"
)
// statistics
@@ -143,8 +132,6 @@ func ListenSer(inServer proxy.Server, defaultOutClient proxy.Client, env *proxy.
superSer := advs.(advLayer.SuperMuxServer)
// var newConnChan chan net.Conn
closer = superSer.StartListen(func(newConn net.Conn) {
iics := incomingInserverConnState{
wrappedConn: newConn,
@@ -157,41 +144,12 @@ func ListenSer(inServer proxy.Server, defaultOutClient proxy.Client, env *proxy.
handshakeInserver_and_passToOutClient(iics)
})
// newConnChan, closer = superSer.StartListen()
if closer == nil {
utils.Error("Failed in SuperMuxServer StartListen ")
return
}
// go func() {
// for {
// newConn, ok := <-newConnChan
// if !ok {
// if ce := utils.CanLogErr("Read chan from Super AdvLayer closed"); ce != nil {
// ce.Write(zap.String("advLayer", inServer.AdvancedLayer()))
// }
// if closer != nil {
// closer.Close()
// }
// return
// }
// iics := incomingInserverConnState{
// wrappedConn: newConn,
// inServer: inServer,
// defaultClient: defaultOutClient,
// routingEnv: env,
// GlobalInfo: gi,
// }
// iics.genID()
// go handshakeInserver_and_passToOutClient(iics)
// }
// }()
if ce := utils.CanLogInfo("Listening Super AdvLayer"); ce != nil {
ce.Write(
+1
View File
@@ -56,6 +56,7 @@ func (sc *StackCloser) Close() error {
return nil
}
// 非阻塞
func Listen(dev device.Device, tcpFunc func(netLayer.TCPRequestInfo), udpFunc func(netLayer.UDPRequestInfo)) (closer io.Closer, err error) {
s := stack.New(stack.Options{
+1
View File
@@ -100,6 +100,7 @@ type Server interface {
type ListenerServer interface {
Server
//非阻塞
StartListen(func(netLayer.TCPRequestInfo), func(netLayer.UDPRequestInfo)) io.Closer
}
+1
View File
@@ -162,6 +162,7 @@ func (m *Server) removeUDPByHash(hash netLayer.HashableAddr) {
m.Unlock()
}
// 非阻塞
func (s *Server) StartListen(_ func(netLayer.TCPRequestInfo), udpFunc func(netLayer.UDPRequestInfo)) io.Closer {
uc, err := net.ListenUDP("udp", s.LUA)
if err != nil {
+1
View File
@@ -193,6 +193,7 @@ func (s *Server) Stop() {
}
// 非阻塞
func (s *Server) StartListen(tcpFunc func(netLayer.TCPRequestInfo), udpFunc func(netLayer.UDPRequestInfo)) io.Closer {
s.stopped = false
+11
View File
@@ -12,6 +12,17 @@ import (
"github.com/e1732a364fed/v2ray_simple/netLayer"
"github.com/e1732a364fed/v2ray_simple/proxy"
"github.com/e1732a364fed/v2ray_simple/utils"
_ "github.com/e1732a364fed/v2ray_simple/advLayer/grpcSimple"
_ "github.com/e1732a364fed/v2ray_simple/advLayer/ws"
_ "github.com/e1732a364fed/v2ray_simple/proxy/dokodemo"
_ "github.com/e1732a364fed/v2ray_simple/proxy/shadowsocks"
_ "github.com/e1732a364fed/v2ray_simple/proxy/simplesocks"
_ "github.com/e1732a364fed/v2ray_simple/proxy/socks5http"
_ "github.com/e1732a364fed/v2ray_simple/proxy/trojan"
_ "github.com/e1732a364fed/v2ray_simple/proxy/vless"
_ "github.com/e1732a364fed/v2ray_simple/proxy/vmess"
)
func TestTCP_vless(t *testing.T) {
+11
View File
@@ -11,6 +11,17 @@ import (
"github.com/e1732a364fed/v2ray_simple/proxy/socks5"
"github.com/e1732a364fed/v2ray_simple/utils"
"github.com/miekg/dns"
_ "github.com/e1732a364fed/v2ray_simple/advLayer/grpcSimple"
_ "github.com/e1732a364fed/v2ray_simple/advLayer/ws"
_ "github.com/e1732a364fed/v2ray_simple/proxy/dokodemo"
_ "github.com/e1732a364fed/v2ray_simple/proxy/shadowsocks"
_ "github.com/e1732a364fed/v2ray_simple/proxy/simplesocks"
_ "github.com/e1732a364fed/v2ray_simple/proxy/socks5http"
_ "github.com/e1732a364fed/v2ray_simple/proxy/trojan"
_ "github.com/e1732a364fed/v2ray_simple/proxy/vless"
_ "github.com/e1732a364fed/v2ray_simple/proxy/vmess"
)
func TestUDP_vless(t *testing.T) {