优化 socks 解析流程
This commit is contained in:
@@ -8,12 +8,12 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func ConnChan(ctx context.Context, ls net.Listener) chan net.Conn {
|
||||
func ChanConnAccept(ctx context.Context, ls net.Listener) chan net.Conn {
|
||||
connCh := make(chan net.Conn)
|
||||
go func() {
|
||||
for {
|
||||
conn, err := ls.Accept()
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, net.ErrClosed) {
|
||||
slog.Error("接受连接失败", err)
|
||||
// 临时错误重试连接
|
||||
var ne net.Error
|
||||
@@ -35,7 +35,7 @@ func ConnChan(ctx context.Context, ls net.Listener) chan net.Conn {
|
||||
return connCh
|
||||
}
|
||||
|
||||
func WaitChan(ctx context.Context, wg *CountWaitGroup) chan struct{} {
|
||||
func ChanWgWait(ctx context.Context, wg *CountWaitGroup) chan struct{} {
|
||||
ch := make(chan struct{})
|
||||
go func() {
|
||||
wg.Wait()
|
||||
|
||||
Reference in New Issue
Block a user