mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-10-07 09:41:07 +08:00
修订udp代码; dial配置 添加 fullcone 选项;默认为非fullcone
现在整个程序均通过了go test, main 也可以正常运行了。 Relay_UDP 函数添加流量计数; 发现之前 Relay函数的流量计数 在main.go里参数传反了,导致实际上计数的是上传而不是下载,已修复 对fullcone的情况做了特别考量。MsgConn的 Close函数在fullcone时不能随便被调用。 因此我添加了一个 CloseConnWithRaddr(raddr Addr) error 方法,以及 Fullcone() bool 方法 在utils包的init部分使用 rand 随机种子
This commit is contained in:
@@ -82,7 +82,11 @@ func NewServer() (proxy.Server, error) {
|
||||
}
|
||||
func (d *Server) Name() string { return name }
|
||||
|
||||
//因为dokodemo的单目标性质, 不会建立任何udp通道.
|
||||
func (s *Server) Handshake(underlay net.Conn) (io.ReadWriteCloser, netLayer.MsgConn, netLayer.Addr, error) {
|
||||
return underlay, nil, s.targetAddr, nil
|
||||
if s.targetAddr.IsUDP() {
|
||||
return nil, netLayer.UniTargetMsgConn{Conn: underlay}, s.targetAddr, nil
|
||||
} else {
|
||||
return underlay, nil, s.targetAddr, nil
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user