From addac74b2ec0e63a741ccf503a66c7f5713a706d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Dec 2023 19:48:55 +0800 Subject: [PATCH 1/2] Bump golang.org/x/crypto from 0.14.0 to 0.17.0 (#9) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.17.0. - [Commits](https://github.com/golang/crypto/compare/v0.14.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 36ca40e..42bd3bd 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module aproxy go 1.21 -require golang.org/x/crypto v0.14.0 // indirect +require golang.org/x/crypto v0.17.0 diff --git a/go.sum b/go.sum index 886a236..c09097a 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,2 @@ -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= From 9deb7ca45e64abca3ebb752baa9497cfbf6d7bba Mon Sep 17 00:00:00 2001 From: Pieter C Date: Fri, 22 Mar 2024 09:43:02 +0100 Subject: [PATCH 2/2] Fix shutdown behaviour (#10) * Fix shutdown behaviour * Remove confusion log line --- aproxy.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/aproxy.go b/aproxy.go index ce75256..8885dbf 100644 --- a/aproxy.go +++ b/aproxy.go @@ -377,8 +377,8 @@ func main() { listenFlag := flag.String("listen", ":8443", "the address and port on which the server will listen") flag.Parse() listenAddr := *listenFlag - ctx := context.Background() - signal.NotifyContext(ctx, os.Interrupt) + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) + defer stop() listenConfig := new(net.ListenConfig) listener, err := listenConfig.Listen(ctx, "tcp", listenAddr) if err != nil { @@ -390,12 +390,16 @@ func main() { log.Fatalf("no upstearm proxy specified") } slog.Info(fmt.Sprintf("start forwarding to proxy %s", proxy)) - for { - conn, err := listener.Accept() - if err != nil { - slog.Error("failed to accept connection", "error", err) - continue + go func() { + for { + conn, err := listener.Accept() + if err != nil { + slog.Error("failed to accept connection", "error", err) + continue + } + go HandleConn(conn, proxy) } - go HandleConn(conn, proxy) - } + }() + <-ctx.Done() + stop() }