Files
v2ray_simple/netLayer/sockopt.go
e1732a364fed cc758dec66 全面修订代码;完成 grpcSimple包;使用 tag选择编译quic 和 grpc
grpcSimple包的服务端和客户端现在都已完成,且兼容v2ray等内核。
grpcSimple包 简洁、高效,更加科学。暂不支持multiMode。

若 grpc_full 给出,则使用grpc包,否则默认使用 grpcSimple包。
若 noquic给出,则不使用 quic,否则 默认使用 quic。

修复 ws early 失效问题;
2022-04-28 05:41:56 +08:00

39 lines
1.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)
}