优化 socks 解析流程

This commit is contained in:
2025-02-26 13:56:56 +08:00
parent b50dc3d91c
commit 7ee4ded08c
12 changed files with 301 additions and 104 deletions

View File

@@ -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()