Skip to content

Commit ae7286e

Browse files
authored
Merge branch 'main' into feat-proxy-config
2 parents 8947bf7 + 9deb7ca commit ae7286e

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

aproxy.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ func main() {
246246
httpsProxy: httpsProxy,
247247
}
248248
listenAddr := *listenFlag
249-
ctx := context.Background()
250-
signal.NotifyContext(ctx, os.Interrupt)
249+
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
250+
defer stop()
251251
listenConfig := new(net.ListenConfig)
252252
listener, err := listenConfig.Listen(ctx, "tcp", listenAddr)
253253
if err != nil {
@@ -264,12 +264,16 @@ func main() {
264264
} else {
265265
logger.InfoContext(ctx, "start passthrough HTTPS connection")
266266
}
267-
for {
268-
conn, err := listener.Accept()
269-
if err != nil {
270-
logger.ErrorContext(ctx, "failed to accept connection", "error", err)
271-
continue
267+
go func() {
268+
for {
269+
conn, err := listener.Accept()
270+
if err != nil {
271+
logger.ErrorContext(ctx, "failed to accept connection", "error", err)
272+
continue
273+
}
274+
go HandleConn(conn, proxy)
272275
}
273-
go HandleConn(ctx, conn.(*net.TCPConn), forwarder)
274-
}
276+
}()
277+
<-ctx.Done()
278+
stop()
275279
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module aproxy
22

33
go 1.21
44

5-
require golang.org/x/crypto v0.14.0 // indirect
5+
require golang.org/x/crypto v0.17.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
2-
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
1+
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
2+
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=

0 commit comments

Comments
 (0)