File tree Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -246,8 +246,8 @@ func main() {
246
246
httpsProxy : httpsProxy ,
247
247
}
248
248
listenAddr := * listenFlag
249
- ctx := context .Background ()
250
- signal . NotifyContext ( ctx , os . Interrupt )
249
+ ctx , stop := signal . NotifyContext ( context .Background (), os . Interrupt )
250
+ defer stop ( )
251
251
listenConfig := new (net.ListenConfig )
252
252
listener , err := listenConfig .Listen (ctx , "tcp" , listenAddr )
253
253
if err != nil {
@@ -264,12 +264,16 @@ func main() {
264
264
} else {
265
265
logger .InfoContext (ctx , "start passthrough HTTPS connection" )
266
266
}
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 )
272
275
}
273
- go HandleConn (ctx , conn .(* net.TCPConn ), forwarder )
274
- }
276
+ }()
277
+ <- ctx .Done ()
278
+ stop ()
275
279
}
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ module aproxy
2
2
3
3
go 1.21
4
4
5
- require golang.org/x/crypto v0.14.0 // indirect
5
+ require golang.org/x/crypto v0.17.0
Original file line number Diff line number Diff line change 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 =
You can’t perform that action at this time.
0 commit comments