mirror of
https://github.com/fosrl/gerbil.git
synced 2026-09-08 07:01:30 +02:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81624509f8 | ||
|
|
0058f0c7ee | ||
|
|
a29075b8bd | ||
|
|
b72f0ab05f | ||
|
|
551eb18e61 | ||
|
|
2eb4090c20 | ||
|
|
2297266a39 | ||
|
|
5d70c76bfc | ||
|
|
c63be17369 | ||
|
|
939fbd5d2c | ||
|
|
94594f40a5 | ||
|
|
e1b47b69aa | ||
|
|
654a3c777a | ||
|
|
6f1851639a | ||
|
|
74629a97f7 | ||
|
|
5c697afcac | ||
|
|
6a26078f9e | ||
|
|
f17612c5d9 | ||
|
|
e25e5766df | ||
|
|
2264c1c7b4 | ||
|
|
904199121d | ||
|
|
5b92bdeb1c | ||
|
|
daecacbd8e | ||
|
|
8efce78d94 | ||
|
|
c29e6ec535 | ||
|
|
0a1496e8de | ||
|
|
4f325dd92f | ||
|
|
8328a4751a | ||
|
|
860ba69a88 | ||
|
|
e1c9836dc1 | ||
|
|
d611eb2022 |
36
.github/dependabot.yml
vendored
36
.github/dependabot.yml
vendored
@@ -1,40 +1,32 @@
|
|||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: "gomod"
|
- package-ecosystem: "gomod"
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
open-pull-requests-limit: 1
|
||||||
groups:
|
groups:
|
||||||
dev-patch-updates:
|
go-dependencies:
|
||||||
dependency-type: "development"
|
patterns:
|
||||||
update-types:
|
- "*"
|
||||||
- "patch"
|
|
||||||
dev-minor-updates:
|
|
||||||
dependency-type: "development"
|
|
||||||
update-types:
|
|
||||||
- "minor"
|
|
||||||
prod-patch-updates:
|
|
||||||
dependency-type: "production"
|
|
||||||
update-types:
|
|
||||||
- "patch"
|
|
||||||
prod-minor-updates:
|
|
||||||
dependency-type: "production"
|
|
||||||
update-types:
|
|
||||||
- "minor"
|
|
||||||
|
|
||||||
- package-ecosystem: "docker"
|
- package-ecosystem: "docker"
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
open-pull-requests-limit: 1
|
||||||
groups:
|
groups:
|
||||||
patch-updates:
|
docker-dependencies:
|
||||||
update-types:
|
patterns:
|
||||||
- "patch"
|
- "*"
|
||||||
minor-updates:
|
|
||||||
update-types:
|
|
||||||
- "minor"
|
|
||||||
|
|
||||||
- package-ecosystem: "github-actions"
|
- package-ecosystem: "github-actions"
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
|
open-pull-requests-limit: 1
|
||||||
|
groups:
|
||||||
|
github-actions-dependencies:
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
|
|||||||
14
.github/workflows/cicd.yml
vendored
14
.github/workflows/cicd.yml
vendored
@@ -36,16 +36,16 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
|
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||||
with:
|
with:
|
||||||
registry: docker.io
|
registry: docker.io
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
@@ -57,7 +57,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||||
with:
|
with:
|
||||||
go-version: 1.26
|
go-version: 1.26
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Login in to GHCR
|
- name: Login in to GHCR
|
||||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -156,7 +156,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Upload artifacts from /bin
|
- name: Upload artifacts from /bin
|
||||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||||
with:
|
with:
|
||||||
name: binaries
|
name: binaries
|
||||||
path: bin/
|
path: bin/
|
||||||
|
|||||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -14,14 +14,14 @@ jobs:
|
|||||||
runs-on: amd64-runner
|
runs-on: amd64-runner
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Read go version
|
- name: Read go version
|
||||||
id: goversion
|
id: goversion
|
||||||
run: echo "version=$(cat .go-version)" >> $GITHUB_OUTPUT
|
run: echo "version=$(cat .go-version)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||||
with:
|
with:
|
||||||
go-version: ${{ steps.goversion.outputs.version }}
|
go-version: ${{ steps.goversion.outputs.version }}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ COPY . .
|
|||||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /gerbil
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /gerbil
|
||||||
|
|
||||||
# Start a new stage from scratch
|
# Start a new stage from scratch
|
||||||
FROM alpine:3.23 AS runner
|
FROM alpine:3.24 AS runner
|
||||||
|
|
||||||
RUN apk add --no-cache iptables iproute2
|
RUN apk add --no-cache iptables iproute2
|
||||||
|
|
||||||
|
|||||||
45
go.mod
45
go.mod
@@ -4,16 +4,16 @@ go 1.26.0
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/prometheus/client_golang v1.23.2
|
github.com/prometheus/client_golang v1.24.1
|
||||||
github.com/vishvananda/netlink v1.3.1
|
github.com/vishvananda/netlink v1.3.1
|
||||||
go.opentelemetry.io/otel v1.44.0
|
go.opentelemetry.io/otel v1.46.0
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.44.0
|
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.46.0
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.44.0
|
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.46.0
|
||||||
go.opentelemetry.io/otel/metric v1.44.0
|
go.opentelemetry.io/otel/metric v1.46.0
|
||||||
go.opentelemetry.io/otel/sdk v1.44.0
|
go.opentelemetry.io/otel/sdk v1.46.0
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.44.0
|
go.opentelemetry.io/otel/sdk/metric v1.46.0
|
||||||
golang.org/x/crypto v0.52.0
|
golang.org/x/crypto v0.55.0
|
||||||
golang.org/x/sync v0.20.0
|
golang.org/x/sync v0.22.0
|
||||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6
|
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,30 +21,29 @@ require (
|
|||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/go-logr/logr v1.4.3 // indirect
|
github.com/go-logr/logr v1.4.4 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/google/go-cmp v0.7.0 // indirect
|
github.com/google/go-cmp v0.7.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 // indirect
|
||||||
github.com/josharian/native v1.1.0 // indirect
|
github.com/josharian/native v1.1.0 // indirect
|
||||||
github.com/mdlayher/genetlink v1.3.2 // indirect
|
github.com/mdlayher/genetlink v1.3.2 // indirect
|
||||||
github.com/mdlayher/netlink v1.7.2 // indirect
|
github.com/mdlayher/netlink v1.7.2 // indirect
|
||||||
github.com/mdlayher/socket v0.4.1 // indirect
|
github.com/mdlayher/socket v0.4.1 // indirect
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/prometheus/client_model v0.6.2 // indirect
|
github.com/prometheus/client_model v0.6.2 // indirect
|
||||||
github.com/prometheus/common v0.66.1 // indirect
|
github.com/prometheus/common v0.70.1 // indirect
|
||||||
github.com/prometheus/procfs v0.16.1 // indirect
|
github.com/prometheus/procfs v0.21.1 // indirect
|
||||||
github.com/vishvananda/netns v0.0.5 // indirect
|
github.com/vishvananda/netns v0.0.5 // indirect
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.44.0 // indirect
|
go.opentelemetry.io/otel/trace v1.46.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
|
go.opentelemetry.io/proto/otlp v1.11.0 // indirect
|
||||||
go.yaml.in/yaml/v2 v2.4.2 // indirect
|
golang.org/x/net v0.58.0 // indirect
|
||||||
golang.org/x/net v0.55.0 // indirect
|
golang.org/x/sys v0.47.0 // indirect
|
||||||
golang.org/x/sys v0.45.0 // indirect
|
golang.org/x/text v0.41.0 // indirect
|
||||||
golang.org/x/text v0.37.0 // indirect
|
|
||||||
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b // indirect
|
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 // indirect
|
||||||
google.golang.org/grpc v1.81.1 // indirect
|
google.golang.org/grpc v1.83.1 // indirect
|
||||||
google.golang.org/protobuf v1.36.11 // indirect
|
google.golang.org/protobuf v1.36.12 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
121
go.sum
121
go.sum
@@ -4,11 +4,9 @@ github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1x
|
|||||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
|
||||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
@@ -17,16 +15,12 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
|||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 h1:5VipnvEpbqr2gA2VbM+nYVbkIF28c5ZQfqCBQ5g2xfk=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 h1:/Tnpcb2E0Pz/tN9s3bfEY2Q8ePCEX9iuS+cneUwncnw=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0/go.mod h1:Hyl3n6Twe1hvtd9XUXDec4pTvgMSEixRuQKPTMH2bNs=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0/go.mod h1:zOBXOsUaBSjKgmH4OGzV1esUpR3oUSCPYVd2cUBjKYY=
|
||||||
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
||||||
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk=
|
||||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
|
||||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||||
github.com/mdlayher/genetlink v1.3.2 h1:KdrNKe+CTu+IbZnm/GVUMXSqBBLqcGpRDa0xkQy56gw=
|
github.com/mdlayher/genetlink v1.3.2 h1:KdrNKe+CTu+IbZnm/GVUMXSqBBLqcGpRDa0xkQy56gw=
|
||||||
@@ -41,76 +35,69 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
|
|||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
|
||||||
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
|
|
||||||
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
|
|
||||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
||||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||||
github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
|
github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY=
|
||||||
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
|
github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
|
||||||
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
|
github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
|
||||||
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
|
github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
|
||||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
|
||||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
|
||||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
|
||||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
|
||||||
github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW6bV0=
|
github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW6bV0=
|
||||||
github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4=
|
github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4=
|
||||||
github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY=
|
github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY=
|
||||||
github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
|
github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||||
go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU=
|
go.opentelemetry.io/otel v1.46.0 h1:FHt5/CDyVxi/8IM1CH7VE/rRgq3kLHa2mSTVMO8AWyc=
|
||||||
go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc=
|
go.opentelemetry.io/otel v1.46.0/go.mod h1:Gj3SEScelsNC45tp4nSxRYlS+f5iez7W8XPMCt905kE=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.44.0 h1:SUplec5dp06reu1zaXmOXdvqH398taqrDXqUl99jxSc=
|
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.46.0 h1:qkDYCAFiZXLcs1L4aY+tP2wguQ4kURANqHOQMA2et2s=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.44.0/go.mod h1:ho2g4N+ane+swq5I/VBkKWnRDY4kUINH3FuqyZqX/Ug=
|
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.46.0/go.mod h1:tkipS4DRzmpAmvg+Gw4++O1IdDq6TVDnvnYU6cmbQVs=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.44.0 h1:RuynHbfU8JUEw7DyONgkVYg2SVtsoF28y0LGIr69jgA=
|
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.46.0 h1:AP23h/mFgb/lc7tdck1Kfn9qxsM8TAeNPCU5C3pzaps=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.44.0/go.mod h1:qZF+/lBs71APw8mlnEZcqZHMzqrYrsFiJOv83lX1OGo=
|
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.46.0/go.mod h1:K4EqCe1b4kGk5WR690ntg9LaBfsPoV32FwthbyoptuA=
|
||||||
go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc=
|
go.opentelemetry.io/otel/metric v1.46.0 h1:yBnkXvgV7AXFILZc5K6IZe/CBFF3OS7BJ8ov6/lj0K8=
|
||||||
go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo=
|
go.opentelemetry.io/otel/metric v1.46.0/go.mod h1:iPmdWqifKUdzziPkvvzIJXITl56fQx2mGM/DHLB3/2o=
|
||||||
go.opentelemetry.io/otel/metric/x v0.66.0 h1:YkCrx1zLOChi9ZcZ6euupOcsgzbVlec7D/xoEU1+cTA=
|
go.opentelemetry.io/otel/metric/x v0.68.0 h1:TA/cBT23D3MnxYPwHL7YFOdYGdx0A0v+s7Mzotpd1dU=
|
||||||
go.opentelemetry.io/otel/metric/x v0.66.0/go.mod h1:d1+BDj9t96do0/1LoU1ayfCv79ZgNE41qbhBvnMOBZk=
|
go.opentelemetry.io/otel/metric/x v0.68.0/go.mod h1:agudOmvWhwUTjgibWDzxD2PoWYnpw5Ht5jISYOD2Hd4=
|
||||||
go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58=
|
go.opentelemetry.io/otel/sdk v1.46.0 h1:h5CNQQjEbuQXY/JfZtgt3i7HVFV3aHPO2OAwO2eTYPI=
|
||||||
go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0=
|
go.opentelemetry.io/otel/sdk v1.46.0/go.mod h1:GAERFXFt5SYCEB+YiKUbMBeza6UaDH7GmGOZEfh2gSM=
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI=
|
go.opentelemetry.io/otel/sdk/metric v1.46.0 h1:0piZ26EG4RBfebb2jhDH6ERCYHoVWduc3kLgPCwSnSE=
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
|
go.opentelemetry.io/otel/sdk/metric v1.46.0/go.mod h1:I1PbKrdVc8Qu8HYVDNtqVIwLwjNrhsV/uFuxfwg8mO4=
|
||||||
go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
|
go.opentelemetry.io/otel/trace v1.46.0 h1:OULy7ccdJnZtJ0UDYFOIGaCmiWzJ8Vi2G/Rsu60qs1c=
|
||||||
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
|
go.opentelemetry.io/otel/trace v1.46.0/go.mod h1:J7GAXweO77XSFkB/rmAqk9D6ihszhFjLU+d9WuUxDLI=
|
||||||
go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
|
go.opentelemetry.io/proto/otlp v1.11.0 h1:5rrYs0Ykyj50sdU/JU0x8etU+LubXWb+gED6TbEdMIk=
|
||||||
go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
|
go.opentelemetry.io/proto/otlp v1.11.0/go.mod h1:SmVizdCOAm3XBtG1g1NnOdhW6jtddT72hLMhv8VwA8E=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
|
go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ=
|
||||||
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
|
go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
|
||||||
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
|
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
||||||
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
|
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||||
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
|
golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M=
|
||||||
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
|
golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis=
|
||||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
|
||||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
|
||||||
|
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||||
|
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
|
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||||
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||||
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
|
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
|
||||||
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
|
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
|
||||||
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b h1:J1CaxgLerRR5lgx3wnr6L04cJFbWoceSK9JWBdglINo=
|
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b h1:J1CaxgLerRR5lgx3wnr6L04cJFbWoceSK9JWBdglINo=
|
||||||
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b/go.mod h1:tqur9LnfstdR9ep2LaJT4lFUl0EjlHtge+gAjmsHUG4=
|
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b/go.mod h1:tqur9LnfstdR9ep2LaJT4lFUl0EjlHtge+gAjmsHUG4=
|
||||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 h1:CawjfCvYQH2OU3/TnxLx97WDSUDRABfT18pCOYwc2GE=
|
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 h1:CawjfCvYQH2OU3/TnxLx97WDSUDRABfT18pCOYwc2GE=
|
||||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6/go.mod h1:3rxYc4HtVcSG9gVaTs2GEBdehh+sYPOwKtyUWEOTb80=
|
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6/go.mod h1:3rxYc4HtVcSG9gVaTs2GEBdehh+sYPOwKtyUWEOTb80=
|
||||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa h1:Kjn0N0tCrDgiAFW+lGO4JZ3ck44CehvJQMAwj9QF0G8=
|
google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 h1:ax2KzoSRIZU/M0cIxri3pKxy99vniH1PVxWC6si/eZI=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa/go.mod h1:q4lMZS6kskjT5HvCPrnnypcDPVJqT/f4nfxmkE7gryY=
|
google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688/go.mod h1:1RJ9BQGyNdZwkGc1eTqkErfRZ6RJyYPHZo73BZ1vQqI=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa h1:mZHHdPZl0dbGHCflZgAq/Q468DWVFcU2whhB2KAo8fk=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 h1:cYNAzI2sUwhmCcoj9TxvihSrqsxt6uIkj3rDRhSDmW4=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA=
|
||||||
google.golang.org/grpc v1.81.1 h1:VnnIIZ88UzOOKLukQi+ImGz8O1Wdp8nAGGnvOfEIWQQ=
|
google.golang.org/grpc v1.83.1 h1:HIO0+BEtBP6soyqvqC8sNUjZ7bTs+0hFQuFF+RAy++Y=
|
||||||
google.golang.org/grpc v1.81.1/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I=
|
google.golang.org/grpc v1.83.1/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ=
|
||||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
||||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ var (
|
|||||||
udpPacketSizeBytes observability.Histogram
|
udpPacketSizeBytes observability.Histogram
|
||||||
holePunchEventsTotal observability.Counter
|
holePunchEventsTotal observability.Counter
|
||||||
proxyMappingActive observability.UpDownCounter
|
proxyMappingActive observability.UpDownCounter
|
||||||
|
relayUDPConnectionsActive observability.UpDownCounter
|
||||||
sessionRebuiltTotal observability.Counter
|
sessionRebuiltTotal observability.Counter
|
||||||
commPatternActive observability.UpDownCounter
|
commPatternActive observability.UpDownCounter
|
||||||
proxyCleanupRemovedTotal observability.Counter
|
proxyCleanupRemovedTotal observability.Counter
|
||||||
@@ -342,6 +343,11 @@ func createInstruments() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
relayUDPConnectionsActive, err = newUpDownCounter("gerbil_relay_udp_connections_active",
|
||||||
|
"Number of open per-peer outbound UDP sockets held by the relay connection pool", "ifname")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
sessionRebuiltTotal, err = newCounter("gerbil_session_rebuilt_total",
|
sessionRebuiltTotal, err = newCounter("gerbil_session_rebuilt_total",
|
||||||
"Count of sessions rebuilt from communication patterns", "ifname")
|
"Count of sessions rebuilt from communication patterns", "ifname")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -711,6 +717,13 @@ func RecordSession(ifname string, delta int64) {
|
|||||||
activeSessions.Add(context.Background(), delta, observability.Labels{"ifname": ifname})
|
activeSessions.Add(context.Background(), delta, observability.Labels{"ifname": ifname})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RecordUDPConnection(ifname string, delta int64) {
|
||||||
|
if relayUDPConnectionsActive == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
relayUDPConnectionsActive.Add(context.Background(), delta, observability.Labels{"ifname": ifname})
|
||||||
|
}
|
||||||
|
|
||||||
func RecordSessionRebuilt(ifname string) {
|
func RecordSessionRebuilt(ifname string) {
|
||||||
if sessionRebuiltTotal == nil {
|
if sessionRebuiltTotal == nil {
|
||||||
return
|
return
|
||||||
|
|||||||
270
main.go
270
main.go
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
@@ -11,10 +12,12 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -46,6 +49,7 @@ var (
|
|||||||
doTrafficShaping bool
|
doTrafficShaping bool
|
||||||
bandwidthLimit string
|
bandwidthLimit string
|
||||||
ifbName string // IFB device name for ingress traffic shaping
|
ifbName string // IFB device name for ingress traffic shaping
|
||||||
|
disableFirewall bool
|
||||||
)
|
)
|
||||||
|
|
||||||
type WgConfig struct {
|
type WgConfig struct {
|
||||||
@@ -102,6 +106,144 @@ type UpdateDestinationsRequest struct {
|
|||||||
Destinations []relay.PeerDestination `json:"destinations"`
|
Destinations []relay.PeerDestination `json:"destinations"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pangolinDestHeader carries the downstream host:port (reachable over the
|
||||||
|
// WireGuard interface) that a /router request should be rewritten to,
|
||||||
|
// optionally prefixed with a scheme (e.g. "https://100.96.128.1:443"). It is
|
||||||
|
// stripped before the request is forwarded.
|
||||||
|
const pangolinDestHeader = "p-dest-header"
|
||||||
|
|
||||||
|
// pangolinHostHeader optionally carries the Host header value that should be
|
||||||
|
// sent to the destination, when it differs from pangolinDestHeader (e.g. the
|
||||||
|
// target's configured IP/hostname rather than the WireGuard routing
|
||||||
|
// address). It is stripped before the request is forwarded. When absent,
|
||||||
|
// the destination from pangolinDestHeader is used as the Host header, same
|
||||||
|
// as before.
|
||||||
|
const pangolinHostHeader = "p-dest-host-header"
|
||||||
|
|
||||||
|
// splitDestHeader separates an optional "scheme://" prefix from a
|
||||||
|
// pangolinDestHeader value, defaulting to "http" when none is present.
|
||||||
|
func splitDestHeader(dest string) (scheme, host string) {
|
||||||
|
if s, rest, ok := strings.Cut(dest, "://"); ok {
|
||||||
|
return s, rest
|
||||||
|
}
|
||||||
|
return "http", dest
|
||||||
|
}
|
||||||
|
|
||||||
|
// hostname strips an optional ":port" suffix from a host header value.
|
||||||
|
func hostname(hostport string) string {
|
||||||
|
if h, _, err := net.SplitHostPort(hostport); err == nil {
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
return hostport
|
||||||
|
}
|
||||||
|
|
||||||
|
// routerSNIContextKey carries the TLS ServerName (SNI) that
|
||||||
|
// routerTransport's DialTLSContext should present, since we dial the
|
||||||
|
// WireGuard destination IP but the remote end typically terminates TLS
|
||||||
|
// based on the original hostname (pangolinHostHeader), not that IP.
|
||||||
|
type routerSNIContextKey struct{}
|
||||||
|
|
||||||
|
// routerTransport is routerProxy's RoundTripper. It mirrors
|
||||||
|
// http.DefaultTransport except for TLS dials, where it sets the SNI from
|
||||||
|
// routerSNIContextKey instead of letting it default to the dial address
|
||||||
|
// (the WireGuard IP), which the destination's TLS termination won't have a
|
||||||
|
// matching certificate/route for.
|
||||||
|
var routerTransport = &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
DialTLSContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
|
serverName := hostname(addr)
|
||||||
|
if sni, ok := ctx.Value(routerSNIContextKey{}).(string); ok && sni != "" {
|
||||||
|
serverName = sni
|
||||||
|
}
|
||||||
|
dialer := &tls.Dialer{Config: &tls.Config{ServerName: serverName}}
|
||||||
|
return dialer.DialContext(ctx, network, addr)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// logDebugRequest dumps a request's destination, headers, and body at debug
|
||||||
|
// level for troubleshooting (e.g. verifying an auth header made it through
|
||||||
|
// the proxy chain intact). It reads and restores req.Body so the request can
|
||||||
|
// still be sent afterward. Header values (including secrets like API keys)
|
||||||
|
// are logged as-is - only intended to be enabled for local troubleshooting.
|
||||||
|
func logDebugRequest(label string, req *http.Request) {
|
||||||
|
var headerLines strings.Builder
|
||||||
|
for name, values := range req.Header {
|
||||||
|
for _, v := range values {
|
||||||
|
fmt.Fprintf(&headerLines, "\n %s: %s", name, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body := []byte("<empty>")
|
||||||
|
if req.Body != nil {
|
||||||
|
data, err := io.ReadAll(req.Body)
|
||||||
|
req.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("%s: failed to read body for logging: %v", label, err)
|
||||||
|
} else {
|
||||||
|
body = data
|
||||||
|
}
|
||||||
|
req.Body = io.NopCloser(bytes.NewReader(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Debug("%s: %s %s://%s%s headers:%s\nbody: %s", label, req.Method, req.URL.Scheme, req.Host, req.URL.RequestURI(), headerLines.String(), body)
|
||||||
|
}
|
||||||
|
|
||||||
|
// routerProxy forwards /router/* requests from the Pangolin AI gateway to a
|
||||||
|
// destination on the WireGuard network, as named by pangolinDestHeader.
|
||||||
|
// Used for proxying AI chat completion requests (incl. streaming) to
|
||||||
|
// providers reachable only from a site.
|
||||||
|
var routerProxy = &httputil.ReverseProxy{
|
||||||
|
Rewrite: func(pr *httputil.ProxyRequest) {
|
||||||
|
scheme, dest := splitDestHeader(pr.In.Header.Get(pangolinDestHeader))
|
||||||
|
|
||||||
|
pr.Out.URL.Scheme = scheme
|
||||||
|
pr.Out.URL.Host = dest
|
||||||
|
pr.Out.URL.Path = strings.TrimPrefix(pr.In.URL.Path, "/router")
|
||||||
|
if !strings.HasPrefix(pr.Out.URL.Path, "/") {
|
||||||
|
pr.Out.URL.Path = "/" + pr.Out.URL.Path
|
||||||
|
}
|
||||||
|
pr.Out.URL.RawPath = ""
|
||||||
|
pr.Out.Host = dest
|
||||||
|
if hostOverride := pr.In.Header.Get(pangolinHostHeader); hostOverride != "" {
|
||||||
|
pr.Out.Host = hostOverride
|
||||||
|
ctx := context.WithValue(pr.Out.Context(), routerSNIContextKey{}, hostname(hostOverride))
|
||||||
|
pr.Out = pr.Out.WithContext(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
pr.Out.Header.Del(pangolinDestHeader)
|
||||||
|
pr.Out.Header.Del(pangolinHostHeader)
|
||||||
|
|
||||||
|
logger.Debug("Router proxy: %s %s -> %s (Host: %s)", pr.In.Method, pr.In.URL.Path, pr.Out.URL.String(), pr.Out.Host)
|
||||||
|
logDebugRequest("Router outbound request", pr.Out)
|
||||||
|
},
|
||||||
|
Transport: routerTransport,
|
||||||
|
// Flush written bytes to the client immediately rather than buffering,
|
||||||
|
// which is required for SSE-based streaming chat completions.
|
||||||
|
FlushInterval: -1,
|
||||||
|
ErrorHandler: func(w http.ResponseWriter, r *http.Request, err error) {
|
||||||
|
logger.Error("Router proxy error for %s: %v", r.URL.Path, err)
|
||||||
|
http.Error(w, "Bad gateway", http.StatusBadGateway)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleRouter(w http.ResponseWriter, r *http.Request) {
|
||||||
|
dest := r.Header.Get(pangolinDestHeader)
|
||||||
|
hostOverride := r.Header.Get(pangolinHostHeader)
|
||||||
|
logger.Debug("Router request received: %s %s dest=%s host=%s remote=%s", r.Method, r.URL.Path, dest, hostOverride, r.RemoteAddr)
|
||||||
|
|
||||||
|
if dest == "" {
|
||||||
|
http.Error(w, fmt.Sprintf("Missing %s header", pangolinDestHeader), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, host := splitDestHeader(dest)
|
||||||
|
if _, _, err := net.SplitHostPort(host); err != nil {
|
||||||
|
http.Error(w, "Invalid destination", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
routerProxy.ServeHTTP(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
// httpMetricsMiddleware wraps HTTP handlers with metrics tracking
|
// httpMetricsMiddleware wraps HTTP handlers with metrics tracking
|
||||||
func httpMetricsMiddleware(endpoint string, handler http.HandlerFunc) http.HandlerFunc {
|
func httpMetricsMiddleware(endpoint string, handler http.HandlerFunc) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -131,6 +273,16 @@ func (w *responseWriterWrapper) WriteHeader(statusCode int) {
|
|||||||
w.ResponseWriter.WriteHeader(statusCode)
|
w.ResponseWriter.WriteHeader(statusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unwrap exposes the underlying ResponseWriter so http.ResponseController
|
||||||
|
// (used by httputil.ReverseProxy's streaming Flush, and by Hijack/Push
|
||||||
|
// callers) can see through this wrapper to the real http.Flusher etc.
|
||||||
|
// Without this, ReverseProxy's flushes on /router/* silently no-op and
|
||||||
|
// streamed responses (e.g. SSE) get buffered until the response completes
|
||||||
|
// instead of being forwarded incrementally.
|
||||||
|
func (w *responseWriterWrapper) Unwrap() http.ResponseWriter {
|
||||||
|
return w.ResponseWriter
|
||||||
|
}
|
||||||
|
|
||||||
func parseLogLevel(level string) logger.LogLevel {
|
func parseLogLevel(level string) logger.LogLevel {
|
||||||
switch strings.ToUpper(level) {
|
switch strings.ToUpper(level) {
|
||||||
case "DEBUG":
|
case "DEBUG":
|
||||||
@@ -149,8 +301,6 @@ func parseLogLevel(level string) logger.LogLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
go monitorMemory(1024 * 1024 * 512) // trigger if memory usage exceeds 512MB
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
wgconfig WgConfig
|
wgconfig WgConfig
|
||||||
@@ -196,6 +346,7 @@ func main() {
|
|||||||
proxyProtocolStr := os.Getenv("PROXY_PROTOCOL")
|
proxyProtocolStr := os.Getenv("PROXY_PROTOCOL")
|
||||||
doTrafficShapingStr := os.Getenv("DO_TRAFFIC_SHAPING")
|
doTrafficShapingStr := os.Getenv("DO_TRAFFIC_SHAPING")
|
||||||
bandwidthLimitStr := os.Getenv("BANDWIDTH_LIMIT")
|
bandwidthLimitStr := os.Getenv("BANDWIDTH_LIMIT")
|
||||||
|
disableFirewallStr := os.Getenv("DISABLE_FIREWALL")
|
||||||
|
|
||||||
// Read metrics env vars (defaults applied by DefaultMetricsConfig; these override defaults).
|
// Read metrics env vars (defaults applied by DefaultMetricsConfig; these override defaults).
|
||||||
metricsEnabled = true // default
|
metricsEnabled = true // default
|
||||||
@@ -316,6 +467,13 @@ func main() {
|
|||||||
flag.BoolVar(&doTrafficShaping, "do-traffic-shaping", false, "Whether to set up traffic shaping rules for peers (requires tc command and root privileges)")
|
flag.BoolVar(&doTrafficShaping, "do-traffic-shaping", false, "Whether to set up traffic shaping rules for peers (requires tc command and root privileges)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if disableFirewallStr != "" {
|
||||||
|
disableFirewall = strings.ToLower(disableFirewallStr) == "true"
|
||||||
|
}
|
||||||
|
if disableFirewallStr == "" {
|
||||||
|
flag.BoolVar(&disableFirewall, "disable-firewall", false, "Disable WireGuard firewall rules to allow all inbound traffic on the interface")
|
||||||
|
}
|
||||||
|
|
||||||
if bandwidthLimitStr != "" {
|
if bandwidthLimitStr != "" {
|
||||||
bandwidthLimit = bandwidthLimitStr
|
bandwidthLimit = bandwidthLimitStr
|
||||||
}
|
}
|
||||||
@@ -335,6 +493,15 @@ func main() {
|
|||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
// Heap profiles are dumped into the configured config directory (the same
|
||||||
|
// directory as the config file, or /var/config as a fallback for remote-config
|
||||||
|
// setups) so they land on the volume the operator actually has mounted.
|
||||||
|
heapDir := "/var/config/heap"
|
||||||
|
if configFile != "" {
|
||||||
|
heapDir = filepath.Join(filepath.Dir(configFile), "heap")
|
||||||
|
}
|
||||||
|
go monitorMemory(1024*1024*512, heapDir) // trigger if memory usage exceeds 512MB
|
||||||
|
|
||||||
// Derive IFB device name from the WireGuard interface name (Linux limit: 15 chars)
|
// Derive IFB device name from the WireGuard interface name (Linux limit: 15 chars)
|
||||||
ifbName = "ifb_" + interfaceName
|
ifbName = "ifb_" + interfaceName
|
||||||
if len(ifbName) > 15 {
|
if len(ifbName) > 15 {
|
||||||
@@ -412,9 +579,12 @@ func main() {
|
|||||||
logger.Fatal("You must provide either a config file or a remote config URL, not both")
|
logger.Fatal("You must provide either a config file or a remote config URL, not both")
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up the reomte config URL for backwards compatibility
|
// clean up the remote config URL for backwards compatibility
|
||||||
|
remoteConfigURL = strings.TrimRight(remoteConfigURL, "/")
|
||||||
remoteConfigURL = strings.TrimSuffix(remoteConfigURL, "/gerbil/get-config")
|
remoteConfigURL = strings.TrimSuffix(remoteConfigURL, "/gerbil/get-config")
|
||||||
remoteConfigURL = strings.TrimSuffix(remoteConfigURL, "/")
|
remoteConfigURL = strings.TrimSuffix(remoteConfigURL, "/gerbil/receive-bandwidth")
|
||||||
|
remoteConfigURL = strings.TrimSuffix(remoteConfigURL, "/gerbil")
|
||||||
|
remoteConfigURL = strings.TrimRight(remoteConfigURL, "/")
|
||||||
|
|
||||||
var key wgtypes.Key
|
var key wgtypes.Key
|
||||||
// if generateAndSaveKeyTo is provided, generate a private key and save it to the file. if the file already exists, load the key from the file
|
// if generateAndSaveKeyTo is provided, generate a private key and save it to the file. if the file already exists, load the key from the file
|
||||||
@@ -551,6 +721,7 @@ func main() {
|
|||||||
http.HandleFunc("/update-destinations", httpMetricsMiddleware("update_destinations", handleUpdateDestinations))
|
http.HandleFunc("/update-destinations", httpMetricsMiddleware("update_destinations", handleUpdateDestinations))
|
||||||
http.HandleFunc("/update-local-snis", httpMetricsMiddleware("update_local_snis", handleUpdateLocalSNIs))
|
http.HandleFunc("/update-local-snis", httpMetricsMiddleware("update_local_snis", handleUpdateLocalSNIs))
|
||||||
http.HandleFunc("/healthz", httpMetricsMiddleware("healthz", handleHealthz))
|
http.HandleFunc("/healthz", httpMetricsMiddleware("healthz", handleHealthz))
|
||||||
|
http.HandleFunc("/router/", httpMetricsMiddleware("router", handleRouter))
|
||||||
|
|
||||||
// Register metrics endpoint only for Prometheus backend.
|
// Register metrics endpoint only for Prometheus backend.
|
||||||
// OTel backend pushes to a collector; no /metrics endpoint needed.
|
// OTel backend pushes to a collector; no /metrics endpoint needed.
|
||||||
@@ -732,7 +903,9 @@ func ensureWireguardInterface(wgconfig WgConfig) error {
|
|||||||
logger.Warn("Failed to ensure MSS clamping: %v", err)
|
logger.Warn("Failed to ensure MSS clamping: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ensureWireguardFirewall(); err != nil {
|
if disableFirewall {
|
||||||
|
logger.Warn("Firewall disabled: all inbound traffic on %s will be allowed", interfaceName)
|
||||||
|
} else if err := ensureWireguardFirewall(wgconfig.IpAddress); err != nil {
|
||||||
logger.Warn("Failed to ensure WireGuard firewall rules: %v", err)
|
logger.Warn("Failed to ensure WireGuard firewall rules: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -908,11 +1081,18 @@ func ensureMSSClamping() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureWireguardFirewall() error {
|
func ensureWireguardFirewall(localIpAddress string) error {
|
||||||
// Rules to enforce:
|
// Rules to enforce:
|
||||||
// 1. Allow established/related connections (responses to our outbound traffic)
|
// 1. Allow established/related connections (responses to our outbound traffic)
|
||||||
// 2. Allow ICMP ping packets
|
// 2. Allow ICMP ping packets
|
||||||
// 3. Drop all other inbound traffic from peers
|
// 3. Allow inbound traffic to ports 80/443 on the local IP only (for Traefik)
|
||||||
|
// 4. Drop all other inbound traffic from peers
|
||||||
|
|
||||||
|
// Strip any CIDR suffix so we're left with just the host IP
|
||||||
|
localIp := localIpAddress
|
||||||
|
if ip, _, err := net.ParseCIDR(localIpAddress); err == nil {
|
||||||
|
localIp = ip.String()
|
||||||
|
}
|
||||||
|
|
||||||
// Define the rules we want to ensure exist
|
// Define the rules we want to ensure exist
|
||||||
rules := [][]string{
|
rules := [][]string{
|
||||||
@@ -932,6 +1112,24 @@ func ensureWireguardFirewall() error {
|
|||||||
"--icmp-type", "8",
|
"--icmp-type", "8",
|
||||||
"-j", "ACCEPT",
|
"-j", "ACCEPT",
|
||||||
},
|
},
|
||||||
|
// Allow inbound HTTP to the local IP only (for Traefik)
|
||||||
|
{
|
||||||
|
"-A", "INPUT",
|
||||||
|
"-i", interfaceName,
|
||||||
|
"-p", "tcp",
|
||||||
|
"--dport", "80",
|
||||||
|
"-d", localIp,
|
||||||
|
"-j", "ACCEPT",
|
||||||
|
},
|
||||||
|
// Allow inbound HTTPS to the local IP only (for Traefik)
|
||||||
|
{
|
||||||
|
"-A", "INPUT",
|
||||||
|
"-i", interfaceName,
|
||||||
|
"-p", "tcp",
|
||||||
|
"--dport", "443",
|
||||||
|
"-d", localIp,
|
||||||
|
"-j", "ACCEPT",
|
||||||
|
},
|
||||||
// Drop all other inbound traffic from WireGuard interface
|
// Drop all other inbound traffic from WireGuard interface
|
||||||
{
|
{
|
||||||
"-A", "INPUT",
|
"-A", "INPUT",
|
||||||
@@ -1493,6 +1691,24 @@ func calculatePeerBandwidth() ([]PeerBandwidth, error) {
|
|||||||
return peerBandwidths, nil
|
return peerBandwidths, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// defaultBandwidthReportBatchSize caps how many peer bandwidth readings are
|
||||||
|
// sent in a single POST. Reporting every peer in one request grows unbounded
|
||||||
|
// with fleet size and can exceed the remote server's request body limit,
|
||||||
|
// which surfaces as "413 Payload Too Large" and silently drops that whole
|
||||||
|
// report cycle. Overridable via GERBIL_BANDWIDTH_BATCH_SIZE.
|
||||||
|
const defaultBandwidthReportBatchSize = 250
|
||||||
|
|
||||||
|
var bandwidthReportBatchSize = loadBandwidthReportBatchSize()
|
||||||
|
|
||||||
|
func loadBandwidthReportBatchSize() int {
|
||||||
|
if v := os.Getenv("GERBIL_BANDWIDTH_BATCH_SIZE"); v != "" {
|
||||||
|
if n, err := strconv.Atoi(v); err == nil && n > 0 {
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultBandwidthReportBatchSize
|
||||||
|
}
|
||||||
|
|
||||||
func reportPeerBandwidth(apiURL string) error {
|
func reportPeerBandwidth(apiURL string) error {
|
||||||
bandwidths, err := calculatePeerBandwidth()
|
bandwidths, err := calculatePeerBandwidth()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1501,26 +1717,47 @@ func reportPeerBandwidth(apiURL string) error {
|
|||||||
return fmt.Errorf("failed to calculate peer bandwidth: %v", err)
|
return fmt.Errorf("failed to calculate peer bandwidth: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonData, err := json.Marshal(bandwidths)
|
if len(bandwidths) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var batchErrs []error
|
||||||
|
for start := 0; start < len(bandwidths); start += bandwidthReportBatchSize {
|
||||||
|
end := start + bandwidthReportBatchSize
|
||||||
|
if end > len(bandwidths) {
|
||||||
|
end = len(bandwidths)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := sendPeerBandwidthBatch(apiURL, bandwidths[start:end]); err != nil {
|
||||||
|
metrics.RecordBandwidthReport("error")
|
||||||
|
batchErrs = append(batchErrs, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
metrics.RecordBandwidthReport("success")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(batchErrs) > 0 {
|
||||||
|
return fmt.Errorf("failed to report %d bandwidth batch(es): %w", len(batchErrs), errors.Join(batchErrs...))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendPeerBandwidthBatch(apiURL string, batch []PeerBandwidth) error {
|
||||||
|
jsonData, err := json.Marshal(batch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
metrics.RecordBandwidthReport("error")
|
|
||||||
return fmt.Errorf("failed to marshal bandwidth data: %v", err)
|
return fmt.Errorf("failed to marshal bandwidth data: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := http.Post(apiURL, "application/json", bytes.NewBuffer(jsonData))
|
resp, err := http.Post(apiURL, "application/json", bytes.NewBuffer(jsonData))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
metrics.RecordBandwidthReport("error")
|
|
||||||
return fmt.Errorf("failed to send bandwidth data: %v", err)
|
return fmt.Errorf("failed to send bandwidth data: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
metrics.RecordBandwidthReport("error")
|
|
||||||
return fmt.Errorf("API returned non-OK status: %s", resp.Status)
|
return fmt.Errorf("API returned non-OK status: %s", resp.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record successful bandwidth report
|
|
||||||
metrics.RecordBandwidthReport("success")
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1549,7 +1786,7 @@ func notifyPeerChange(action, publicKey string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func monitorMemory(limit uint64) {
|
func monitorMemory(limit uint64, heapDir string) {
|
||||||
var m runtime.MemStats
|
var m runtime.MemStats
|
||||||
for {
|
for {
|
||||||
runtime.ReadMemStats(&m)
|
runtime.ReadMemStats(&m)
|
||||||
@@ -1565,8 +1802,9 @@ func monitorMemory(limit uint64) {
|
|||||||
// Record memory spike metric
|
// Record memory spike metric
|
||||||
metrics.RecordMemorySpike(severity)
|
metrics.RecordMemorySpike(severity)
|
||||||
|
|
||||||
f, err := os.Create(fmt.Sprintf("/var/config/heap/heap-spike-%d.pprof", time.Now().Unix()))
|
if err := os.MkdirAll(heapDir, 0o755); err != nil {
|
||||||
if err != nil {
|
log.Println("could not create heap profile directory:", err)
|
||||||
|
} else if f, err := os.Create(filepath.Join(heapDir, fmt.Sprintf("heap-spike-%d.pprof", time.Now().Unix()))); err != nil {
|
||||||
log.Println("could not create profile:", err)
|
log.Println("could not create profile:", err)
|
||||||
} else {
|
} else {
|
||||||
pprof.WriteHeapProfile(f)
|
pprof.WriteHeapProfile(f)
|
||||||
|
|||||||
119
proxy/proxy.go
119
proxy/proxy.go
@@ -11,9 +11,11 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/fosrl/gerbil/internal/metrics"
|
"github.com/fosrl/gerbil/internal/metrics"
|
||||||
@@ -21,6 +23,46 @@ import (
|
|||||||
"github.com/patrickmn/go-cache"
|
"github.com/patrickmn/go-cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// defaultMaxSNIConnections caps the number of concurrent client connections
|
||||||
|
// the SNI proxy will accept. Without a cap, a burst of connections (a
|
||||||
|
// scanner sweep, a client reconnect storm) spawns unbounded goroutines each
|
||||||
|
// holding copy buffers and sockets, exhausting container memory faster than
|
||||||
|
// GC/backpressure can catch up.
|
||||||
|
// Sized conservatively since each connection now holds up to two pooled
|
||||||
|
// 32KB copy buffers once the buffer pool is actually honored (see
|
||||||
|
// bufferedReader/bufferedWriter below). Overridable via
|
||||||
|
// GERBIL_MAX_SNI_CONNECTIONS.
|
||||||
|
const defaultMaxSNIConnections = 4096
|
||||||
|
|
||||||
|
var maxSNIConnections = loadMaxSNIConnections()
|
||||||
|
|
||||||
|
func loadMaxSNIConnections() int64 {
|
||||||
|
if v := os.Getenv("GERBIL_MAX_SNI_CONNECTIONS"); v != "" {
|
||||||
|
if n, err := strconv.ParseInt(v, 10, 64); err == nil && n > 0 {
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultMaxSNIConnections
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaultMaxSNIConnectionsPerIP caps concurrent connections from a single
|
||||||
|
// source IP, independent of the global maxSNIConnections budget. Without
|
||||||
|
// this, one noisy/misbehaving client (or a single scanning host) can
|
||||||
|
// consume the entire global budget and lock out every other customer
|
||||||
|
// sharing this proxy. Overridable via GERBIL_MAX_SNI_CONNECTIONS_PER_IP.
|
||||||
|
const defaultMaxSNIConnectionsPerIP = 256
|
||||||
|
|
||||||
|
var maxSNIConnectionsPerIP = loadMaxSNIConnectionsPerIP()
|
||||||
|
|
||||||
|
func loadMaxSNIConnectionsPerIP() int64 {
|
||||||
|
if v := os.Getenv("GERBIL_MAX_SNI_CONNECTIONS_PER_IP"); v != "" {
|
||||||
|
if n, err := strconv.ParseInt(v, 10, 64); err == nil && n > 0 {
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultMaxSNIConnectionsPerIP
|
||||||
|
}
|
||||||
|
|
||||||
// RouteRecord represents a routing configuration
|
// RouteRecord represents a routing configuration
|
||||||
type RouteRecord struct {
|
type RouteRecord struct {
|
||||||
Hostname string
|
Hostname string
|
||||||
@@ -76,6 +118,18 @@ type SNIProxy struct {
|
|||||||
|
|
||||||
// Buffer pool for connection piping
|
// Buffer pool for connection piping
|
||||||
bufferPool *sync.Pool
|
bufferPool *sync.Pool
|
||||||
|
|
||||||
|
// activeConnections tracks concurrent client connections so
|
||||||
|
// acceptConnections can enforce maxSNIConnections.
|
||||||
|
activeConnections atomic.Int64
|
||||||
|
|
||||||
|
// perIPConnections tracks concurrent connections per source IP (map[string]*atomic.Int64)
|
||||||
|
// so acceptConnections can enforce maxSNIConnectionsPerIP and stop one
|
||||||
|
// client from starving the rest. Entries are removed once a given IP's
|
||||||
|
// count returns to zero, so this stays bounded by currently-connected
|
||||||
|
// distinct IPs (itself bounded by maxSNIConnections) rather than growing
|
||||||
|
// with every IP ever seen.
|
||||||
|
perIPConnections sync.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
type activeTunnel struct {
|
type activeTunnel struct {
|
||||||
@@ -458,8 +512,46 @@ func (p *SNIProxy) acceptConnections() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.activeConnections.Load() >= maxSNIConnections {
|
||||||
|
logger.Debug("Max concurrent SNI connections (%d) reached, rejecting connection from %s", maxSNIConnections, conn.RemoteAddr())
|
||||||
|
metrics.RecordSNIConnection("rejected_max_connections")
|
||||||
|
conn.Close()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
remoteHost, _, err := net.SplitHostPort(conn.RemoteAddr().String())
|
||||||
|
if err != nil {
|
||||||
|
remoteHost = conn.RemoteAddr().String()
|
||||||
|
}
|
||||||
|
|
||||||
|
counterVal, _ := p.perIPConnections.LoadOrStore(remoteHost, new(atomic.Int64))
|
||||||
|
perIPCounter := counterVal.(*atomic.Int64)
|
||||||
|
if perIPCounter.Load() >= maxSNIConnectionsPerIP {
|
||||||
|
logger.Debug("Max concurrent SNI connections per IP (%d) reached for %s, rejecting connection", maxSNIConnectionsPerIP, remoteHost)
|
||||||
|
metrics.RecordSNIConnection("rejected_per_ip_limit")
|
||||||
|
conn.Close()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
perIPCounter.Add(1)
|
||||||
|
|
||||||
|
p.activeConnections.Add(1)
|
||||||
|
metrics.RecordSNIActiveConnection(1)
|
||||||
p.wg.Add(1)
|
p.wg.Add(1)
|
||||||
go p.handleConnection(conn)
|
go func() {
|
||||||
|
defer func() {
|
||||||
|
if perIPCounter.Add(-1) == 0 {
|
||||||
|
// Best-effort cleanup: only remove the map entry if it
|
||||||
|
// still holds this exact counter (a concurrent new
|
||||||
|
// connection from the same IP may have already bumped
|
||||||
|
// it back up via LoadOrStore, or replaced it after a
|
||||||
|
// prior race). Undercounting in that narrow race window
|
||||||
|
// just means one connection isn't rate-limited briefly,
|
||||||
|
// never unbounded growth.
|
||||||
|
p.perIPConnections.CompareAndDelete(remoteHost, counterVal)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
p.handleConnection(conn)
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,6 +599,10 @@ func (p *SNIProxy) extractSNI(conn net.Conn) (string, io.Reader, error) {
|
|||||||
func (p *SNIProxy) handleConnection(clientConn net.Conn) {
|
func (p *SNIProxy) handleConnection(clientConn net.Conn) {
|
||||||
defer p.wg.Done()
|
defer p.wg.Done()
|
||||||
defer clientConn.Close()
|
defer clientConn.Close()
|
||||||
|
defer func() {
|
||||||
|
p.activeConnections.Add(-1)
|
||||||
|
metrics.RecordSNIActiveConnection(-1)
|
||||||
|
}()
|
||||||
|
|
||||||
metrics.RecordSNIConnection("accepted")
|
metrics.RecordSNIConnection("accepted")
|
||||||
|
|
||||||
@@ -793,6 +889,23 @@ func (p *SNIProxy) selectStickyEndpoint(clientAddr string, endpoints []string) s
|
|||||||
return endpoints[index]
|
return endpoints[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bufferedReader hides any io.WriterTo the wrapped reader implements (e.g.
|
||||||
|
// io.MultiReader, used by peekClientHello to replay the buffered
|
||||||
|
// ClientHello ahead of the raw connection). Without this, io.CopyBuffer
|
||||||
|
// bypasses the caller-supplied buffer entirely and lets WriteTo drive its
|
||||||
|
// own, uncapped allocations - defeating the point of bufferPool.
|
||||||
|
type bufferedReader struct {
|
||||||
|
io.Reader
|
||||||
|
}
|
||||||
|
|
||||||
|
// bufferedWriter hides any io.ReaderFrom the wrapped writer implements (e.g.
|
||||||
|
// *net.TCPConn's splice/sendfile fast path). Without this, io.CopyBuffer
|
||||||
|
// bypasses the caller-supplied buffer here too, so each copy allocates and
|
||||||
|
// manages its own buffer regardless of what's pooled.
|
||||||
|
type bufferedWriter struct {
|
||||||
|
io.Writer
|
||||||
|
}
|
||||||
|
|
||||||
// pipe handles bidirectional data transfer between connections
|
// pipe handles bidirectional data transfer between connections
|
||||||
func (p *SNIProxy) pipe(hostname string, clientConn, targetConn net.Conn, clientReader io.Reader) {
|
func (p *SNIProxy) pipe(hostname string, clientConn, targetConn net.Conn, clientReader io.Reader) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
@@ -821,7 +934,7 @@ func (p *SNIProxy) pipe(hostname string, clientConn, targetConn net.Conn, client
|
|||||||
p.bufferPool.Put(bufPtr)
|
p.bufferPool.Put(bufPtr)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
bytesCopied, err := io.CopyBuffer(targetConn, clientReader, *bufPtr)
|
bytesCopied, err := io.CopyBuffer(bufferedWriter{targetConn}, bufferedReader{clientReader}, *bufPtr)
|
||||||
metrics.RecordProxyBytesTransmitted("client_to_target", bytesCopied)
|
metrics.RecordProxyBytesTransmitted("client_to_target", bytesCopied)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
logger.Debug("Copy client->target error: %v", err)
|
logger.Debug("Copy client->target error: %v", err)
|
||||||
@@ -841,7 +954,7 @@ func (p *SNIProxy) pipe(hostname string, clientConn, targetConn net.Conn, client
|
|||||||
p.bufferPool.Put(bufPtr)
|
p.bufferPool.Put(bufPtr)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
bytesCopied, err := io.CopyBuffer(clientConn, targetConn, *bufPtr)
|
bytesCopied, err := io.CopyBuffer(bufferedWriter{clientConn}, bufferedReader{targetConn}, *bufPtr)
|
||||||
metrics.RecordProxyBytesTransmitted("target_to_client", bytesCopied)
|
metrics.RecordProxyBytesTransmitted("target_to_client", bytesCopied)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
logger.Debug("Copy target->client error: %v", err)
|
logger.Debug("Copy target->client error: %v", err)
|
||||||
|
|||||||
115
relay/relay.go
115
relay/relay.go
@@ -10,8 +10,11 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/fosrl/gerbil/internal/metrics"
|
"github.com/fosrl/gerbil/internal/metrics"
|
||||||
@@ -60,8 +63,31 @@ type PeerDestination struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DestinationConn struct {
|
type DestinationConn struct {
|
||||||
conn *net.UDPConn
|
conn *net.UDPConn
|
||||||
lastUsed time.Time
|
// lastUsed is unix nanoseconds, read/written via atomic ops since it's
|
||||||
|
// touched from packet workers and the response goroutine concurrently
|
||||||
|
// with no lock, and is also scanned for LRU eviction below.
|
||||||
|
lastUsed atomic.Int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaultMaxUDPConnections caps the number of concurrent per-peer outbound
|
||||||
|
// UDP sockets the relay will keep open in s.connections. Without a cap, a
|
||||||
|
// burst of peer churn creates sockets faster than the 5-minute idle cleanup
|
||||||
|
// can reap them, exhausting the host's ephemeral port range or fd ulimit.
|
||||||
|
// That surfaces as "dial udp ...: resource temporarily unavailable" on every
|
||||||
|
// subsequent packet and pegs the CPU logging the flood (outage 2026-07-03,
|
||||||
|
// recurrence 2026-07-05). Overridable via GERBIL_MAX_UDP_CONNECTIONS.
|
||||||
|
const defaultMaxUDPConnections = 8192
|
||||||
|
|
||||||
|
var maxUDPConnections = loadMaxUDPConnections()
|
||||||
|
|
||||||
|
func loadMaxUDPConnections() int64 {
|
||||||
|
if v := os.Getenv("GERBIL_MAX_UDP_CONNECTIONS"); v != "" {
|
||||||
|
if n, err := strconv.ParseInt(v, 10, 64); err == nil && n > 0 {
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultMaxUDPConnections
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type for storing WireGuard handshake information
|
// Type for storing WireGuard handshake information
|
||||||
@@ -172,10 +198,13 @@ type UDPProxyServer struct {
|
|||||||
conn *net.UDPConn
|
conn *net.UDPConn
|
||||||
proxyMappings sync.Map // map[string]ProxyMapping where key is "ip:port"
|
proxyMappings sync.Map // map[string]ProxyMapping where key is "ip:port"
|
||||||
connections sync.Map // map[string]*DestinationConn where key is destination "ip:port"
|
connections sync.Map // map[string]*DestinationConn where key is destination "ip:port"
|
||||||
privateKey wgtypes.Key
|
// connectionCount mirrors len(connections) without an O(n) sync.Map walk,
|
||||||
packetChan chan Packet
|
// so the cap check in getOrCreateConnection is cheap on the hot path.
|
||||||
ctx context.Context
|
connectionCount atomic.Int64
|
||||||
cancel context.CancelFunc
|
privateKey wgtypes.Key
|
||||||
|
packetChan chan Packet
|
||||||
|
ctx context.Context
|
||||||
|
cancel context.CancelFunc
|
||||||
|
|
||||||
// Session tracking for WireGuard peers
|
// Session tracking for WireGuard peers
|
||||||
// Key format: "senderIndex:receiverIndex"
|
// Key format: "senderIndex:receiverIndex"
|
||||||
@@ -862,10 +891,17 @@ func (s *UDPProxyServer) getOrCreateConnection(destAddr *net.UDPAddr, remoteAddr
|
|||||||
// Check if we have an existing connection
|
// Check if we have an existing connection
|
||||||
if conn, ok := s.connections.Load(key); ok {
|
if conn, ok := s.connections.Load(key); ok {
|
||||||
destConn := conn.(*DestinationConn)
|
destConn := conn.(*DestinationConn)
|
||||||
destConn.lastUsed = time.Now()
|
destConn.lastUsed.Store(time.Now().UnixNano())
|
||||||
return destConn.conn, nil
|
return destConn.conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enforce a hard cap on concurrent sockets so a burst of peer churn can't
|
||||||
|
// exhaust the host's ephemeral ports/fds. Evict the least-recently-used
|
||||||
|
// connection to make room instead of growing unbounded.
|
||||||
|
if s.connectionCount.Load() >= maxUDPConnections {
|
||||||
|
s.evictLRUConnection()
|
||||||
|
}
|
||||||
|
|
||||||
// Create new connection
|
// Create new connection
|
||||||
newConn, err := net.DialUDP("udp", nil, destAddr)
|
newConn, err := net.DialUDP("udp", nil, destAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -873,11 +909,17 @@ func (s *UDPProxyServer) getOrCreateConnection(destAddr *net.UDPAddr, remoteAddr
|
|||||||
return nil, fmt.Errorf("failed to create UDP connection: %v", err)
|
return nil, fmt.Errorf("failed to create UDP connection: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the new connection
|
destConn := &DestinationConn{conn: newConn}
|
||||||
s.connections.Store(key, &DestinationConn{
|
destConn.lastUsed.Store(time.Now().UnixNano())
|
||||||
conn: newConn,
|
|
||||||
lastUsed: time.Now(),
|
// Store the new connection. If another goroutine raced us and already
|
||||||
})
|
// created one for this key, close ours and use theirs instead.
|
||||||
|
if existing, loaded := s.connections.LoadOrStore(key, destConn); loaded {
|
||||||
|
newConn.Close()
|
||||||
|
return existing.(*DestinationConn).conn, nil
|
||||||
|
}
|
||||||
|
s.connectionCount.Add(1)
|
||||||
|
metrics.RecordUDPConnection(relayIfname, 1)
|
||||||
|
|
||||||
// Start a goroutine to handle responses
|
// Start a goroutine to handle responses
|
||||||
go s.handleResponses(newConn, destAddr, remoteAddr)
|
go s.handleResponses(newConn, destAddr, remoteAddr)
|
||||||
@@ -885,6 +927,33 @@ func (s *UDPProxyServer) getOrCreateConnection(destAddr *net.UDPAddr, remoteAddr
|
|||||||
return newConn, nil
|
return newConn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// evictLRUConnection closes and removes the least-recently-used destination
|
||||||
|
// connection so a new one can be created under the concurrent connection cap.
|
||||||
|
func (s *UDPProxyServer) evictLRUConnection() {
|
||||||
|
var oldestKey interface{}
|
||||||
|
var oldestConn *DestinationConn
|
||||||
|
var oldestTime int64
|
||||||
|
|
||||||
|
s.connections.Range(func(key, value interface{}) bool {
|
||||||
|
destConn := value.(*DestinationConn)
|
||||||
|
lu := destConn.lastUsed.Load()
|
||||||
|
if oldestKey == nil || lu < oldestTime {
|
||||||
|
oldestKey = key
|
||||||
|
oldestConn = destConn
|
||||||
|
oldestTime = lu
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
if oldestKey != nil {
|
||||||
|
s.connections.Delete(oldestKey)
|
||||||
|
oldestConn.conn.Close()
|
||||||
|
s.connectionCount.Add(-1)
|
||||||
|
metrics.RecordUDPConnection(relayIfname, -1)
|
||||||
|
metrics.RecordProxyCleanupRemoved(relayIfname, "conn_evicted", 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *UDPProxyServer) handleResponses(conn *net.UDPConn, destAddr *net.UDPAddr, remoteAddr *net.UDPAddr) {
|
func (s *UDPProxyServer) handleResponses(conn *net.UDPConn, destAddr *net.UDPAddr, remoteAddr *net.UDPAddr) {
|
||||||
buffer := make([]byte, 1500)
|
buffer := make([]byte, 1500)
|
||||||
for {
|
for {
|
||||||
@@ -936,22 +1005,32 @@ func (s *UDPProxyServer) handleResponses(conn *net.UDPConn, destAddr *net.UDPAdd
|
|||||||
|
|
||||||
// Add a cleanup method to periodically remove idle connections
|
// Add a cleanup method to periodically remove idle connections
|
||||||
func (s *UDPProxyServer) cleanupIdleConnections() {
|
func (s *UDPProxyServer) cleanupIdleConnections() {
|
||||||
ticker := time.NewTicker(5 * time.Minute)
|
// Ticker interval and idle threshold were previously 5min/10min, meaning
|
||||||
|
// a socket could sit open for up to 15 minutes after going idle. Under a
|
||||||
|
// reconnect/churn burst that lag is enough to exhaust ephemeral ports
|
||||||
|
// before cleanup catches up, so both are tightened here.
|
||||||
|
ticker := time.NewTicker(1 * time.Minute)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
cleanupStart := time.Now()
|
cleanupStart := time.Now()
|
||||||
now := time.Now()
|
now := time.Now().UnixNano()
|
||||||
|
removed := int64(0)
|
||||||
s.connections.Range(func(key, value interface{}) bool {
|
s.connections.Range(func(key, value interface{}) bool {
|
||||||
destConn := value.(*DestinationConn)
|
destConn := value.(*DestinationConn)
|
||||||
if now.Sub(destConn.lastUsed) > 10*time.Minute {
|
if now-destConn.lastUsed.Load() > int64(5*time.Minute) {
|
||||||
destConn.conn.Close()
|
destConn.conn.Close()
|
||||||
s.connections.Delete(key)
|
s.connections.Delete(key)
|
||||||
metrics.RecordProxyCleanupRemoved(relayIfname, "conn", 1)
|
removed++
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
if removed > 0 {
|
||||||
|
s.connectionCount.Add(-removed)
|
||||||
|
metrics.RecordUDPConnection(relayIfname, -removed)
|
||||||
|
metrics.RecordProxyCleanupRemoved(relayIfname, "conn", removed)
|
||||||
|
}
|
||||||
metrics.RecordProxyIdleCleanupDuration(relayIfname, "conn", time.Since(cleanupStart).Seconds())
|
metrics.RecordProxyIdleCleanupDuration(relayIfname, "conn", time.Since(cleanupStart).Seconds())
|
||||||
case <-s.ctx.Done():
|
case <-s.ctx.Done():
|
||||||
return
|
return
|
||||||
@@ -1113,6 +1192,10 @@ func (s *UDPProxyServer) clearConnectionsForWGIP(wgIP string) {
|
|||||||
for _, key := range keysToDelete {
|
for _, key := range keysToDelete {
|
||||||
s.connections.Delete(key)
|
s.connections.Delete(key)
|
||||||
}
|
}
|
||||||
|
if len(keysToDelete) > 0 {
|
||||||
|
s.connectionCount.Add(-int64(len(keysToDelete)))
|
||||||
|
metrics.RecordUDPConnection(relayIfname, -int64(len(keysToDelete)))
|
||||||
|
}
|
||||||
|
|
||||||
logger.Info("Cleared %d connections for WG IP: %s", len(keysToDelete), wgIP)
|
logger.Info("Cleared %d connections for WG IP: %s", len(keysToDelete), wgIP)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user