mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-10-14 21:06:03 +08:00
全面修订代码;完成 grpcSimple包;使用 tag选择编译quic 和 grpc
grpcSimple包的服务端和客户端现在都已完成,且兼容v2ray等内核。 grpcSimple包 简洁、高效,更加科学。暂不支持multiMode。 若 grpc_full 给出,则使用grpc包,否则默认使用 grpcSimple包。 若 noquic给出,则不使用 quic,否则 默认使用 quic。 修复 ws early 失效问题;
This commit is contained in:
42
advLayer/grpcSimple/timeouter.go
Normal file
42
advLayer/grpcSimple/timeouter.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package grpcSimple
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type timeouter struct {
|
||||
deadline *time.Timer
|
||||
|
||||
closeFunc func()
|
||||
}
|
||||
|
||||
func (g *timeouter) LocalAddr() net.Addr { return nil }
|
||||
func (g *timeouter) RemoteAddr() net.Addr { return nil }
|
||||
func (g *timeouter) SetReadDeadline(t time.Time) error { return g.SetDeadline(t) }
|
||||
func (g *timeouter) SetWriteDeadline(t time.Time) error { return g.SetDeadline(t) }
|
||||
|
||||
func (g *timeouter) SetDeadline(t time.Time) error {
|
||||
|
||||
var d time.Duration
|
||||
|
||||
if g.deadline != nil {
|
||||
|
||||
if t == (time.Time{}) {
|
||||
g.deadline.Stop()
|
||||
return nil
|
||||
}
|
||||
|
||||
g.deadline.Reset(d)
|
||||
return nil
|
||||
} else {
|
||||
if t == (time.Time{}) {
|
||||
return nil
|
||||
}
|
||||
d = time.Until(t)
|
||||
|
||||
}
|
||||
|
||||
g.deadline = time.AfterFunc(d, g.closeFunc)
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user