mirror of
https://github.com/ngrok/ngrok-operator.git
synced 2026-05-17 16:50:44 +00:00
604bda97e0
Before, this leaked one connection per tunnel dial, which made it very easy to run out of connections. On typical linux machines, it would mean you get whatever the ephemeral port range is of working proxy connections, which isn't a huge number. Under 65k. Anyway, this fixes it in the naive way by closing the connections after their respective copy is complete. This also adds a test that would have failed before, though it required some intrusive mocking changes meaning I can't actually run it on the old code. I also chose to remove the errgroup.WithContext since, well, the ctx wasn't respected in `io.Copy` anyway, so it didn't do anything other than give a sorta false sense of security. Oh, and while I was at mocking, I switched from `net.Dial` to `net.DialContext`. It's identical since ctx is a context.Background there, but maybe it'll nudge us to fix that too at some point.
11 lines
228 B
Go
11 lines
228 B
Go
//go:build tools
|
|
|
|
package main
|
|
|
|
import (
|
|
_ "github.com/golang/mock/mockgen"
|
|
_ "sigs.k8s.io/controller-runtime/tools/setup-envtest"
|
|
_ "sigs.k8s.io/controller-tools/cmd/controller-gen"
|
|
_ "sigs.k8s.io/kustomize/kustomize/v3"
|
|
)
|