Crazy sekai overturns the small pond

This commit is contained in:
世界
2024-10-21 23:38:34 +08:00
parent 253b41936e
commit 8304295c48
139 changed files with 2866 additions and 1559 deletions

View File

@@ -5,7 +5,6 @@ import (
"os"
"time"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/baderror"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
@@ -15,17 +14,15 @@ var _ net.Conn = (*GRPCConn)(nil)
type GRPCConn struct {
GunService
cancel common.ContextCancelCauseFunc
cache []byte
cache []byte
}
func NewGRPCConn(service GunService, cancel common.ContextCancelCauseFunc) *GRPCConn {
func NewGRPCConn(service GunService) *GRPCConn {
if client, isClient := service.(GunService_TunClient); isClient {
service = &clientConnWrapper{client}
}
return &GRPCConn{
GunService: service,
cancel: cancel,
}
}
@@ -38,7 +35,6 @@ func (c *GRPCConn) Read(b []byte) (n int, err error) {
hunk, err := c.Recv()
err = baderror.WrapGRPC(err)
if err != nil {
c.cancel(err)
return
}
n = copy(b, hunk.Data)
@@ -51,14 +47,12 @@ func (c *GRPCConn) Read(b []byte) (n int, err error) {
func (c *GRPCConn) Write(b []byte) (n int, err error) {
err = baderror.WrapGRPC(c.Send(&Hunk{Data: b}))
if err != nil {
c.cancel(err)
return
}
return len(b), nil
}
func (c *GRPCConn) Close() error {
c.cancel(net.ErrClosed)
return nil
}