File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -214,8 +214,8 @@ func main() {
214
214
log .Fatal (err )
215
215
}
216
216
listenAddr := * listenFlag
217
- ctx := context .Background ()
218
- signal . NotifyContext ( ctx , os . Interrupt )
217
+ ctx , stop := signal . NotifyContext ( context .Background (), os . Interrupt )
218
+ defer stop ( )
219
219
listenConfig := new (net.ListenConfig )
220
220
listener , err := listenConfig .Listen (ctx , "tcp" , listenAddr )
221
221
if err != nil {
@@ -232,12 +232,16 @@ func main() {
232
232
} else {
233
233
logger .InfoContext (ctx , "start passthrough HTTPS connection" )
234
234
}
235
- for {
236
- conn , err := listener .Accept ()
237
- if err != nil {
238
- logger .ErrorContext (ctx , "failed to accept connection" , "error" , err )
239
- continue
235
+ go func () {
236
+ for {
237
+ conn , err := listener .Accept ()
238
+ if err != nil {
239
+ logger .ErrorContext (ctx , "failed to accept connection" , "error" , err )
240
+ continue
241
+ }
242
+ go HandleConn (conn , proxy )
240
243
}
241
- go HandleConn (ctx , conn .(* net.TCPConn ), forwarder )
242
- }
244
+ }()
245
+ <- ctx .Done ()
246
+ stop ()
243
247
}
You can’t perform that action at this time.
0 commit comments