mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-10-08 18:20:47 +08:00

grpcSimple包的服务端和客户端现在都已完成,且兼容v2ray等内核。 grpcSimple包 简洁、高效,更加科学。暂不支持multiMode。 若 grpc_full 给出,则使用grpc包,否则默认使用 grpcSimple包。 若 noquic给出,则不使用 quic,否则 默认使用 quic。 修复 ws early 失效问题;
43 lines
766 B
Go
43 lines
766 B
Go
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
|
|
}
|