mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-10-09 10:40:16 +08:00

grpcSimple包的服务端和客户端现在都已完成,且兼容v2ray等内核。 grpcSimple包 简洁、高效,更加科学。暂不支持multiMode。 若 grpc_full 给出,则使用grpc包,否则默认使用 grpcSimple包。 若 noquic给出,则不使用 quic,否则 默认使用 quic。 修复 ws early 失效问题;
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package netLayer
|
||
|
||
import (
|
||
"net"
|
||
"os"
|
||
)
|
||
|
||
//用于 listen和 dial 配置一些底层参数.
|
||
type Sockopt struct {
|
||
TProxy bool `toml:"tproxy"`
|
||
Somark int `toml:"mark"`
|
||
Device string `toml:"device"`
|
||
|
||
//fastopen 不予支持, 因为自己客户端在重重网关之下,不可能让层层网关都支持tcp fast open;
|
||
// 而自己的远程节点的话因为本来网速就很快, 也不需要fastopen,总之 因为木桶原理,慢的地方在我们层层网关, 所以fastopen 意义不大.
|
||
|
||
}
|
||
|
||
//net.TCPListener, net.UnixListener
|
||
type ListenerWithFile interface {
|
||
net.Listener
|
||
File() (f *os.File, err error)
|
||
}
|
||
|
||
//net.UnixConn, net.UDPConn, net.TCPConn, net.IPConn
|
||
type ConnWithFile interface {
|
||
net.Conn
|
||
File() (f *os.File, err error)
|
||
}
|
||
|
||
func SetSockOptForListener(tcplistener ListenerWithFile, sockopt *Sockopt, isudp bool, isipv6 bool) {
|
||
fileDescriptorSource, err := tcplistener.File()
|
||
if err != nil {
|
||
return
|
||
}
|
||
defer fileDescriptorSource.Close()
|
||
SetSockOpt(int(fileDescriptorSource.Fd()), sockopt, isudp, isipv6)
|
||
}
|