mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2025-07-06 17:09:24 +00:00
Compare commits
34 Commits
Author | SHA1 | Date | |
---|---|---|---|
00b1661ef9
|
|||
10c199109a
|
|||
b5fe362183 | |||
95e7742c56
|
|||
680aeefeab
|
|||
15136359ae | |||
64011f9e99
|
|||
f020abc228
|
|||
24b05c0015 | |||
f2da841307
|
|||
5bb5c974dd
|
|||
159c30f2f0
|
|||
1539ba1987
|
|||
4492f77d87 | |||
aaf8a3b163
|
|||
c37642c6c1
|
|||
f3a6f27e99
|
|||
f167424e4f
|
|||
789cc6939e
|
|||
b57beded8f
|
|||
d29e238beb
|
|||
5d3dcb4b8e
|
|||
71a0f37abb | |||
c8d6da5ebd
|
|||
7caf4ad4a8 | |||
d13ea29071 | |||
b11f15ecfe | |||
454f65f087
|
|||
1988241b98
|
|||
901345a337
|
|||
0c14419e7e | |||
db111642d2 | |||
d5b1373e17 | |||
ba8a2ec494 |
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@ -31,16 +31,16 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: install go
|
- name: install go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v2
|
uses: github/codeql-action/init@v3
|
||||||
with:
|
with:
|
||||||
languages: go
|
languages: go
|
||||||
|
|
||||||
@ -49,4 +49,4 @@ jobs:
|
|||||||
make build
|
make build
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2
|
uses: github/codeql-action/analyze@v3
|
||||||
|
14
.github/workflows/main.yml
vendored
14
.github/workflows/main.yml
vendored
@ -8,17 +8,19 @@ on:
|
|||||||
- '*'
|
- '*'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
|
concurrency: ${{ github.ref_name }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
make: ["lint", "test"]
|
make: ["lint", "unit-test", "integration-test"]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: install go
|
- name: install go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
@ -33,11 +35,11 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
goosarch: [linux-amd64]
|
goosarch: [linux-amd64]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: install go
|
- name: install go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
cache: true
|
cache: true
|
||||||
@ -61,7 +63,7 @@ jobs:
|
|||||||
sha256sum whatismyip-$RELEASE_VERSION-${{matrix.goosarch}}.tar.gz > whatismyip-$RELEASE_VERSION-${{matrix.goosarch}}.tar.gz.sha256
|
sha256sum whatismyip-$RELEASE_VERSION-${{matrix.goosarch}}.tar.gz > whatismyip-$RELEASE_VERSION-${{matrix.goosarch}}.tar.gz.sha256
|
||||||
|
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
body_path: changelog.txt
|
body_path: changelog.txt
|
||||||
files: |
|
files: |
|
||||||
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
whatismyip
|
49
.golangci.yaml
Normal file
49
.golangci.yaml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
run:
|
||||||
|
timeout: 10m
|
||||||
|
issues:
|
||||||
|
max-same-issues: 0
|
||||||
|
linters:
|
||||||
|
disable-all: true
|
||||||
|
enable:
|
||||||
|
- goimports
|
||||||
|
- ineffassign
|
||||||
|
- nakedret
|
||||||
|
- revive
|
||||||
|
- staticcheck
|
||||||
|
- stylecheck
|
||||||
|
- unconvert
|
||||||
|
- unparam
|
||||||
|
- unused
|
||||||
|
linters-settings:
|
||||||
|
staticcheck:
|
||||||
|
checks:
|
||||||
|
- all
|
||||||
|
revive:
|
||||||
|
ignore-generated-header: true
|
||||||
|
severity: warning
|
||||||
|
confidence: 0.8
|
||||||
|
rules:
|
||||||
|
- name: blank-imports
|
||||||
|
- name: context-as-argument
|
||||||
|
- name: context-keys-type
|
||||||
|
- name: dot-imports
|
||||||
|
- name: error-return
|
||||||
|
- name: error-strings
|
||||||
|
- name: error-naming
|
||||||
|
- name: exported
|
||||||
|
- name: increment-decrement
|
||||||
|
- name: var-naming
|
||||||
|
- name: var-declaration
|
||||||
|
- name: package-comments
|
||||||
|
- name: range
|
||||||
|
- name: receiver-naming
|
||||||
|
- name: time-naming
|
||||||
|
- name: unexported-return
|
||||||
|
- name: indent-error-flow
|
||||||
|
- name: errorf
|
||||||
|
- name: empty-block
|
||||||
|
- name: superfluous-else
|
||||||
|
- name: unused-parameter
|
||||||
|
- name: unreachable-code
|
||||||
|
- name: redefines-builtin-id
|
33
Dockerfile
33
Dockerfile
@ -1,22 +1,29 @@
|
|||||||
FROM golang:1.21-alpine as builder
|
FROM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
ARG ARG_VERSION
|
ARG ARG_VERSION
|
||||||
ENV VERSION $ARG_VERSION
|
ENV VERSION=$ARG_VERSION
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
COPY go.mod .
|
||||||
|
COPY go.sum .
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod/ go mod download -x
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN apk add make git upx && make build VERSION=$VERSION \
|
FROM builder AS build-dev-app
|
||||||
|
# hadolint ignore=DL3018
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod/ apk --no-cache add make && make build
|
||||||
|
|
||||||
|
FROM builder AS build-prod-app
|
||||||
|
# hadolint ignore=DL3018
|
||||||
|
RUN apk --no-cache update && apk add --no-cache ca-certificates make upx \
|
||||||
|
&& update-ca-certificates \
|
||||||
|
&& make build \
|
||||||
&& upx --best --lzma whatismyip
|
&& upx --best --lzma whatismyip
|
||||||
|
|
||||||
# Build final image
|
FROM scratch AS dev
|
||||||
FROM scratch
|
COPY --from=build-dev-app /app/whatismyip /usr/bin/
|
||||||
|
ENTRYPOINT ["whatismyip"]
|
||||||
WORKDIR /app
|
|
||||||
|
FROM scratch AS prod
|
||||||
COPY --from=builder /app/whatismyip /usr/bin/
|
COPY --from=build-prod-app /app/whatismyip /usr/bin/
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
ENTRYPOINT ["whatismyip"]
|
ENTRYPOINT ["whatismyip"]
|
||||||
|
2
LICENSE
2
LICENSE
@ -176,7 +176,7 @@
|
|||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
Copyright 2021 Daniel Carrillo
|
Copyright 2024 Daniel Carrillo
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
42
Makefile
42
Makefile
@ -5,39 +5,40 @@ DOCKER_URL ?= dcarrillo/whatismyip
|
|||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: unit-test integration-test
|
test: unit-test integration-test
|
||||||
|
|
||||||
.PHONY: unit-test
|
|
||||||
unit-test:
|
unit-test:
|
||||||
go test -count=1 -race -short -cover ./...
|
go test -count=1 -race -short -cover ./...
|
||||||
|
|
||||||
.PHONY: integration-test
|
|
||||||
integration-test:
|
integration-test:
|
||||||
go test -count=1 -v ./integration-tests
|
go test -count=1 -v ./integration-tests
|
||||||
|
|
||||||
.PHONY: install-tools
|
|
||||||
install-tools:
|
install-tools:
|
||||||
@command golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
@command golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin; \
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@command $(GOPATH)/revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
go get -u github.com/mgechev/revive; \
|
||||||
|
fi
|
||||||
|
|
||||||
@command $(GOPATH)/shadow > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
@command $(GOPATH)/shadow > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest; \
|
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest; \
|
||||||
fi
|
fi
|
||||||
.PHONY: lint
|
|
||||||
lint: install-tools
|
lint: install-tools
|
||||||
gofmt -l . && test -z $$(gofmt -l .)
|
gofmt -l . && test -z $$(gofmt -l .)
|
||||||
golangci-lint run
|
golangci-lint run
|
||||||
shadow ./...
|
shadow ./...
|
||||||
|
|
||||||
.PHONY: build
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 go build -ldflags="-s -w -X 'github.com/dcarrillo/whatismyip/internal/core.Version=${VERSION}'" -o whatismyip ./cmd
|
CGO_ENABLED=0 go build -ldflags="-s -w -X 'github.com/dcarrillo/whatismyip/internal/core.Version=${VERSION}'" -o whatismyip ./cmd
|
||||||
|
|
||||||
.PHONY: docker-build
|
docker-build-dev:
|
||||||
docker-build:
|
docker build --target=dev --build-arg=ARG_VERSION="${VERSION}" --tag ${DOCKER_URL}:${VERSION} .
|
||||||
docker build --build-arg=ARG_VERSION="${VERSION}" --tag ${DOCKER_URL}:${VERSION} .
|
|
||||||
|
|
||||||
.PHONY: docker-push
|
docker-build-prod:
|
||||||
docker-push: docker-build
|
docker build --target=prod --build-arg=ARG_VERSION="${VERSION}" --tag ${DOCKER_URL}:${VERSION} .
|
||||||
|
|
||||||
|
docker-push: docker-build-prod
|
||||||
ifneq (,$(findstring devel-,$(VERSION)))
|
ifneq (,$(findstring devel-,$(VERSION)))
|
||||||
@echo "VERSION is set to ${VERSION}, I can't push devel builds"
|
@echo "VERSION is set to ${VERSION}, I can't push devel builds"
|
||||||
exit 1
|
exit 1
|
||||||
@ -47,12 +48,17 @@ else
|
|||||||
docker push ${DOCKER_URL}:latest
|
docker push ${DOCKER_URL}:latest
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: docker-run
|
docker-run: docker-build-dev
|
||||||
docker-run: docker-build
|
|
||||||
docker run --tty --interactive --rm \
|
docker run --tty --interactive --rm \
|
||||||
-v ${PWD}/test/GeoIP2-City-Test.mmdb:/tmp/GeoIP2-City-Test.mmdb:ro \
|
--publish 8080:8080/tcp \
|
||||||
-v ${PWD}/test/GeoLite2-ASN-Test.mmdb:/tmp/GeoLite2-ASN-Test.mmdb:ro -p 8080:8080 \
|
--publish 8081:8081/tcp \
|
||||||
${DOCKER_URL}:${VERSION} \
|
--publish 8081:8081/udp \
|
||||||
-geoip2-city /tmp/GeoIP2-City-Test.mmdb \
|
--volume ${PWD}/test:/test \
|
||||||
-geoip2-asn /tmp/GeoLite2-ASN-Test.mmdb \
|
${DOCKER_URL}:${VERSION} \
|
||||||
-trusted-header X-Real-IP
|
-geoip2-city /test/GeoIP2-City-Test.mmdb \
|
||||||
|
-geoip2-asn /test/GeoLite2-ASN-Test.mmdb \
|
||||||
|
-trusted-header X-Real-PortReal-IP \
|
||||||
|
-tls-bind :8081 \
|
||||||
|
-tls-crt /test/server.pem \
|
||||||
|
-tls-key /test/server.key \
|
||||||
|
-enable-http3
|
||||||
|
90
README.md
90
README.md
@ -9,11 +9,13 @@
|
|||||||
- [What is my IP address](#what-is-my-ip-address)
|
- [What is my IP address](#what-is-my-ip-address)
|
||||||
- [Features](#features)
|
- [Features](#features)
|
||||||
- [Endpoints](#endpoints)
|
- [Endpoints](#endpoints)
|
||||||
|
- [DNS discovery](#dns-discovery)
|
||||||
- [Build](#build)
|
- [Build](#build)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [Run a default TCP server](#run-a-default-tcp-server)
|
- [Run a default TCP server](#run-a-default-tcp-server)
|
||||||
- [Run a TLS (HTTP/2) server only](#run-a-tls-http2-server-only)
|
- [Run a default TCP server with geo information enabled](#run-a-default-tco-server-with-geo-information-enabled)
|
||||||
|
- [Run a TLS (HTTP/2) and enable "what is my DNS" with geo information](#run-a-tls-http2-and-enable-what-is-my-dns-with-geo-information)
|
||||||
- [Run an HTTP/3 server](#run-an-http3-server)
|
- [Run an HTTP/3 server](#run-an-http3-server)
|
||||||
- [Run a default TCP server with a custom template and trust a pair of custom headers set by an upstream proxy](#run-a-default-tcp-server-with-a-custom-template-and-trust-a-pair-of-custom-headers-set-by-an-upstream-proxy)
|
- [Run a default TCP server with a custom template and trust a pair of custom headers set by an upstream proxy](#run-a-default-tcp-server-with-a-custom-template-and-trust-a-pair-of-custom-headers-set-by-an-upstream-proxy)
|
||||||
- [Download](#download)
|
- [Download](#download)
|
||||||
@ -21,10 +23,14 @@
|
|||||||
- [Run a container locally using test databases](#run-a-container-locally-using-test-databases)
|
- [Run a container locally using test databases](#run-a-container-locally-using-test-databases)
|
||||||
- [From Docker Hub](#from-docker-hub)
|
- [From Docker Hub](#from-docker-hub)
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Since version 3.0.0, geodb database is not mandatory, not adding the flags will disable the geo feature.
|
||||||
|
> Since version 2.3.0, the application includes an optional client [DNS discovery](#dns-discovery)
|
||||||
|
|
||||||
Just another "what is my IP address" service, including geolocation, TCP open port checking, and headers information. Written in go with high performance in mind,
|
Just another "what is my IP address" service, including geolocation, TCP open port checking, and headers information. Written in go with high performance in mind,
|
||||||
it uses [gin](https://github.com/gin-gonic/gin) which uses [httprouter](https://github.com/julienschmidt/httprouter) a lightweight high performance HTTP multiplexer.
|
it uses [gin](https://github.com/gin-gonic/gin) which uses [httprouter](https://github.com/julienschmidt/httprouter) a lightweight high performance HTTP multiplexer.
|
||||||
|
|
||||||
Take a look at [ifconfig.es](https://ifconfig.es) a live site using `whatismyip`
|
Take a look at [ifconfig.es](https://ifconfig.es) a live site using `whatismyip` and the `DNS discovery` enabled.
|
||||||
|
|
||||||
Get your public IP easily from the command line:
|
Get your public IP easily from the command line:
|
||||||
|
|
||||||
@ -36,10 +42,18 @@ curl -6 ifconfig.es
|
|||||||
::1
|
::1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Get the IP of your DNS provider:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -L dns.ifconfig.es
|
||||||
|
2a04:e4c0:47::67 (Spain / OPENDNS)
|
||||||
|
```
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- TLS and HTTP/2.
|
- TLS and HTTP/2.
|
||||||
- Experimental HTTP/3 support. HTTP/3 requires a TLS server running (`-tls-bind`), as HTTP/3 starts as a TLS connection that then gets upgraded to UDP. The UDP port is the same as the one used for the TLS server.
|
- Experimental HTTP/3 support. HTTP/3 requires a TLS server running (`-tls-bind`), as HTTP/3 starts as a TLS connection that then gets upgraded to UDP. The UDP port is the same as the one used for the TLS server.
|
||||||
|
- Beta DNS discovery: A best-effort approach to discovering the DNS server that is resolving the client's requests.
|
||||||
- Can run behind a proxy by trusting a custom header (usually `X-Real-IP`) to figure out the source IP address. It also supports a custom header to resolve the client port, if the proxy can only add a header for the IP (for example a fixed header from CDNs) the client port is shown as unknown.
|
- Can run behind a proxy by trusting a custom header (usually `X-Real-IP`) to figure out the source IP address. It also supports a custom header to resolve the client port, if the proxy can only add a header for the IP (for example a fixed header from CDNs) the client port is shown as unknown.
|
||||||
- IPv4 and IPv6.
|
- IPv4 and IPv6.
|
||||||
- Geolocation info including ASN. This feature is possible thanks to [maxmind](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?lang=en) GeoLite2 databases. In order to use these databases, a license key is needed. Please visit Maxmind site for further instructions and get a free license.
|
- Geolocation info including ASN. This feature is possible thanks to [maxmind](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?lang=en) GeoLite2 databases. In order to use these databases, a license key is needed. Please visit Maxmind site for further instructions and get a free license.
|
||||||
@ -69,10 +83,41 @@ curl -6 ifconfig.es
|
|||||||
- https://ifconfig.es/headers
|
- https://ifconfig.es/headers
|
||||||
- https://ifconfig.es/<header_name>
|
- https://ifconfig.es/<header_name>
|
||||||
- https://ifconfig.es/scan/tcp/<port_number>
|
- https://ifconfig.es/scan/tcp/<port_number>
|
||||||
|
- https://dns.ifconfig.es
|
||||||
|
|
||||||
|
## DNS discovery
|
||||||
|
|
||||||
|
The DNS discovery works by forcing the client to make a request to `<uuid>.dns.ifconfig.es` this DNS request is handled by a microdns server
|
||||||
|
included in the `whatismyip` binary. In order to run the discovery server, a configuration file in the following form has to be created:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
domain: dns.example.com
|
||||||
|
redirect_port: ":8000"
|
||||||
|
resource_records:
|
||||||
|
- "1800 IN SOA xns.example.com. hostmaster.example.com. 1 10000 2400 604800 1800"
|
||||||
|
- "3600 IN NS xns.example.com."
|
||||||
|
ipv4:
|
||||||
|
- "127.0.0.2"
|
||||||
|
ipv6:
|
||||||
|
- "aaa:aaa:aaa:aaaa::1"
|
||||||
|
```
|
||||||
|
|
||||||
|
The DNS authority for example.com has delegated the subdomain zone `dns.example.com` to the server running the `whatismyip` service.
|
||||||
|
|
||||||
|
The client can request the URL `dns.example.com` by following the redirection `curl -L dns.example.com`.
|
||||||
|
|
||||||
|
To avoid the redirection, you can provide a valid URL, for example, for the real [ifconfig.es](https://ifconfig.es):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl $(uuidgen).dns.ifconfig.es
|
||||||
|
|
||||||
|
curl $(cat /proc/sys/kernel/random/uuid).dns.ifconfig.es
|
||||||
|
```
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
Golang >= 1.19 is required.
|
Golang >= 1.22 is required.
|
||||||
|
|
||||||
`make build`
|
`make build`
|
||||||
|
|
||||||
@ -81,44 +126,53 @@ Golang >= 1.19 is required.
|
|||||||
```text
|
```text
|
||||||
Usage of whatismyip:
|
Usage of whatismyip:
|
||||||
-bind string
|
-bind string
|
||||||
Listening address (see https://pkg.go.dev/net?#Listen) (default ":8080")
|
Listening address (see https://pkg.go.dev/net?#Listen) (default ":8080")
|
||||||
-enable-http3
|
-enable-http3
|
||||||
Enable HTTP/3 protocol. HTTP/3 requires --tls-bind set, as HTTP/3 starts as a TLS connection that then gets upgraded to UDP. The UDP port is the same as the one used for the TLS server.
|
Enable HTTP/3 protocol. HTTP/3 requires --tls-bind set, as HTTP/3 starts as a TLS connection that then gets upgraded to UDP. The UDP port is the same as the one used for the TLS server.
|
||||||
-enable-secure-headers
|
-enable-secure-headers
|
||||||
Add sane security-related headers to every response
|
Add sane security-related headers to every response
|
||||||
-geoip2-asn string
|
-geoip2-asn string
|
||||||
Path to GeoIP2 ASN database
|
Path to GeoIP2 ASN database. Enables ASN information. (--geoip2-city becomes mandatory)
|
||||||
-geoip2-city string
|
-geoip2-city string
|
||||||
Path to GeoIP2 city database
|
Path to GeoIP2 city database. Enables geo information (--geoip2-asn becomes mandatory)
|
||||||
|
-resolver string
|
||||||
|
Path to the resolver configuration. It actually enables the resolver for DNS client discovery.
|
||||||
-template string
|
-template string
|
||||||
Path to template file
|
Path to the template file
|
||||||
-tls-bind string
|
-tls-bind string
|
||||||
Listening address for TLS (see https://pkg.go.dev/net?#Listen)
|
Listening address for TLS (see https://pkg.go.dev/net?#Listen)
|
||||||
-tls-crt string
|
-tls-crt string
|
||||||
When using TLS, path to certificate file
|
When using TLS, path to certificate file
|
||||||
-tls-key string
|
-tls-key string
|
||||||
When using TLS, path to private key file
|
When using TLS, path to private key file
|
||||||
-trusted-header string
|
-trusted-header string
|
||||||
Trusted request header for remote IP (e.g. X-Real-IP). When using this feature if -trusted-port-header is not set the client port is shown as 'unknown'
|
Trusted request header for remote IP (e.g. X-Real-IP). When using this feature if -trusted-port-header is not set the client port is shown as 'unknown'
|
||||||
-trusted-port-header string
|
-trusted-port-header string
|
||||||
Trusted request header for remote client port (e.g. X-Real-Port). When this parameter is set -trusted-header becomes mandatory
|
Trusted request header for remote client port (e.g. X-Real-Port). When this parameter is set -trusted-header becomes mandatory
|
||||||
-version
|
-version
|
||||||
Output version information and exit
|
Output version information and exit
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Run a default TCP server
|
### Run a default TCP server
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./whatismyip
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run a default TCP server with geo information enabled
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./whatismyip -geoip2-city ./test/GeoIP2-City-Test.mmdb -geoip2-asn ./test/GeoLite2-ASN-Test.mmdb
|
./whatismyip -geoip2-city ./test/GeoIP2-City-Test.mmdb -geoip2-asn ./test/GeoLite2-ASN-Test.mmdb
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run a TLS (HTTP/2) server only
|
### Run a TLS (HTTP/2) and enable "what is my DNS" with geo information
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./whatismyip -geoip2-city ./test/GeoIP2-City-Test.mmdb -geoip2-asn ./test/GeoLite2-ASN-Test.mmdb \
|
./whatismyip -geoip2-city ./test/GeoIP2-City-Test.mmdb -geoip2-asn ./test/GeoLite2-ASN-Test.mmdb \
|
||||||
-bind "" -tls-bind :8081 -tls-crt ./test/server.pem -tls-key ./test/server.key
|
-bind "" -tls-bind :8081 -tls-crt ./test/server.pem -tls-key ./test/server.key \
|
||||||
|
-resolver ./test/resolver.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run an HTTP/3 server
|
### Run an HTTP/3 server
|
||||||
@ -137,7 +191,7 @@ Usage of whatismyip:
|
|||||||
|
|
||||||
## Download
|
## Download
|
||||||
|
|
||||||
Download the latest version from https://github.com/dcarrillo/whatismyip/releases
|
Download the latest version from [github](https://github.com/dcarrillo/whatismyip/releases)
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
|
@ -4,34 +4,57 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"slices"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/dcarrillo/whatismyip/internal/httputils"
|
"github.com/dcarrillo/whatismyip/internal/httputils"
|
||||||
"github.com/dcarrillo/whatismyip/internal/setting"
|
"github.com/dcarrillo/whatismyip/internal/setting"
|
||||||
|
"github.com/dcarrillo/whatismyip/resolver"
|
||||||
"github.com/dcarrillo/whatismyip/server"
|
"github.com/dcarrillo/whatismyip/server"
|
||||||
|
"github.com/dcarrillo/whatismyip/service"
|
||||||
"github.com/gin-contrib/secure"
|
"github.com/gin-contrib/secure"
|
||||||
|
"github.com/patrickmn/go-cache"
|
||||||
|
|
||||||
"github.com/dcarrillo/whatismyip/models"
|
|
||||||
"github.com/dcarrillo/whatismyip/router"
|
"github.com/dcarrillo/whatismyip/router"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
o, err := setting.Setup(os.Args[1:])
|
o, err := setting.Setup(os.Args[1:])
|
||||||
if err == flag.ErrHelp || err == setting.ErrVersion {
|
if err != nil {
|
||||||
fmt.Print(o)
|
if err == flag.ErrHelp || err == setting.ErrVersion {
|
||||||
os.Exit(0)
|
fmt.Print(o)
|
||||||
} else if err != nil {
|
os.Exit(0)
|
||||||
|
}
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
models.Setup(setting.App.GeodbPath.City, setting.App.GeodbPath.ASN)
|
servers := []server.Server{}
|
||||||
engine := setupEngine()
|
engine := setupEngine()
|
||||||
router.SetupTemplate(engine)
|
|
||||||
router.Setup(engine)
|
|
||||||
|
|
||||||
whatismyip := server.Setup(context.Background(), engine.Handler())
|
if setting.App.Resolver.Domain != "" {
|
||||||
|
store := cache.New(1*time.Minute, 10*time.Minute)
|
||||||
|
dnsEngine := resolver.Setup(store)
|
||||||
|
nameServer := server.NewDNSServer(context.Background(), dnsEngine.Handler())
|
||||||
|
servers = append(servers, nameServer)
|
||||||
|
engine.Use(router.GetDNSDiscoveryHandler(store, setting.App.Resolver.Domain, setting.App.Resolver.RedirectPort))
|
||||||
|
}
|
||||||
|
|
||||||
|
var geoSvc *service.Geo
|
||||||
|
if setting.App.GeodbPath.City != "" || setting.App.GeodbPath.ASN != "" {
|
||||||
|
if geoSvc, err = service.NewGeo(context.Background(), setting.App.GeodbPath.City, setting.App.GeodbPath.ASN); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
router.SetupTemplate(engine)
|
||||||
|
router.Setup(engine, geoSvc)
|
||||||
|
servers = slices.Concat(servers, setupHTTPServers(context.Background(), engine.Handler()))
|
||||||
|
|
||||||
|
whatismyip := server.Setup(servers, geoSvc)
|
||||||
whatismyip.Run()
|
whatismyip.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +64,7 @@ func setupEngine() *gin.Engine {
|
|||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
}
|
}
|
||||||
engine := gin.New()
|
engine := gin.New()
|
||||||
engine.Use(gin.LoggerWithFormatter(httputils.GetLogFormatter))
|
engine.Use(gin.LoggerWithFormatter(httputils.GetLogFormatter), gin.Recovery())
|
||||||
engine.Use(gin.Recovery())
|
|
||||||
if setting.App.EnableSecureHeaders {
|
if setting.App.EnableSecureHeaders {
|
||||||
engine.Use(secure.New(secure.Config{
|
engine.Use(secure.New(secure.Config{
|
||||||
BrowserXssFilter: true,
|
BrowserXssFilter: true,
|
||||||
@ -55,3 +77,23 @@ func setupEngine() *gin.Engine {
|
|||||||
|
|
||||||
return engine
|
return engine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setupHTTPServers(ctx context.Context, handler http.Handler) []server.Server {
|
||||||
|
var servers []server.Server
|
||||||
|
|
||||||
|
if setting.App.BindAddress != "" {
|
||||||
|
tcpServer := server.NewTCPServer(ctx, &handler)
|
||||||
|
servers = append(servers, tcpServer)
|
||||||
|
}
|
||||||
|
|
||||||
|
if setting.App.TLSAddress != "" {
|
||||||
|
tlsServer := server.NewTLSServer(ctx, &handler)
|
||||||
|
servers = append(servers, tlsServer)
|
||||||
|
if setting.App.EnableHTTP3 {
|
||||||
|
quicServer := server.NewQuicServer(ctx, tlsServer)
|
||||||
|
servers = append(servers, quicServer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return servers
|
||||||
|
}
|
||||||
|
112
go.mod
112
go.mod
@ -1,72 +1,77 @@
|
|||||||
module github.com/dcarrillo/whatismyip
|
module github.com/dcarrillo/whatismyip
|
||||||
|
|
||||||
go 1.21.3
|
go 1.24
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gin-contrib/secure v0.0.1
|
github.com/docker/docker v26.1.5+incompatible
|
||||||
github.com/gin-gonic/gin v1.9.1
|
github.com/gin-contrib/secure v1.1.1
|
||||||
github.com/oschwald/maxminddb-golang v1.12.0
|
github.com/gin-gonic/gin v1.10.0
|
||||||
github.com/quic-go/quic-go v0.40.1
|
github.com/google/uuid v1.6.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/miekg/dns v1.1.64
|
||||||
github.com/testcontainers/testcontainers-go v0.27.0
|
github.com/oschwald/maxminddb-golang v1.13.1
|
||||||
golang.org/x/net v0.19.0
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
|
github.com/quic-go/quic-go v0.50.0
|
||||||
|
github.com/stretchr/testify v1.10.0
|
||||||
|
github.com/testcontainers/testcontainers-go v0.31.0
|
||||||
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
dario.cat/mergo v1.0.0 // indirect
|
dario.cat/mergo v1.0.0 // indirect
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
|
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
|
||||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||||
github.com/Microsoft/hcsshim v0.11.4 // indirect
|
github.com/Microsoft/hcsshim v0.11.7 // indirect
|
||||||
github.com/bytedance/sonic v1.10.2 // indirect
|
github.com/bytedance/sonic v1.13.1 // indirect
|
||||||
|
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||||
github.com/chenzhuoyu/iasm v0.9.1 // indirect
|
github.com/containerd/containerd v1.7.27 // indirect
|
||||||
github.com/containerd/containerd v1.7.11 // indirect
|
|
||||||
github.com/containerd/log v0.1.0 // indirect
|
github.com/containerd/log v0.1.0 // indirect
|
||||||
|
github.com/containerd/platforms v0.2.1 // indirect
|
||||||
github.com/cpuguy83/dockercfg v0.3.1 // indirect
|
github.com/cpuguy83/dockercfg v0.3.1 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/docker/distribution v2.8.2+incompatible // indirect
|
github.com/distribution/reference v0.6.0 // indirect
|
||||||
github.com/docker/docker v24.0.7+incompatible // indirect
|
github.com/docker/go-connections v0.5.0 // indirect
|
||||||
github.com/docker/go-connections v0.4.0 // indirect
|
|
||||||
github.com/docker/go-units v0.5.0 // indirect
|
github.com/docker/go-units v0.5.0 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||||
|
github.com/gin-contrib/sse v1.0.0 // indirect
|
||||||
|
github.com/go-logr/logr v1.4.2 // indirect
|
||||||
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.16.0 // indirect
|
github.com/go-playground/validator/v10 v10.25.0 // indirect
|
||||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||||
github.com/goccy/go-json v0.10.2 // indirect
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e // indirect
|
||||||
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 // indirect
|
|
||||||
github.com/google/uuid v1.4.0 // indirect
|
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.16.5 // indirect
|
github.com/klauspost/compress v1.17.11 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||||
github.com/kr/pretty v0.3.1 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/leodido/go-urn v1.2.4 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||||
github.com/magiconair/properties v1.8.7 // indirect
|
github.com/magiconair/properties v1.8.7 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/moby/docker-image-spec v1.3.1 // indirect
|
||||||
github.com/moby/patternmatcher v0.6.0 // indirect
|
github.com/moby/patternmatcher v0.6.0 // indirect
|
||||||
github.com/moby/sys/sequential v0.5.0 // indirect
|
github.com/moby/sys/sequential v0.5.0 // indirect
|
||||||
|
github.com/moby/sys/user v0.3.0 // indirect
|
||||||
|
github.com/moby/sys/userns v0.1.0 // indirect
|
||||||
github.com/moby/term v0.5.0 // indirect
|
github.com/moby/term v0.5.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/morikuni/aec v1.0.0 // indirect
|
github.com/morikuni/aec v1.0.0 // indirect
|
||||||
github.com/onsi/ginkgo/v2 v2.13.2 // indirect
|
github.com/onsi/ginkgo/v2 v2.23.0 // indirect
|
||||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||||
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
|
github.com/opencontainers/image-spec v1.1.0 // indirect
|
||||||
github.com/opencontainers/runc v1.1.9 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
|
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||||
github.com/quic-go/qpack v0.4.0 // indirect
|
github.com/quic-go/qpack v0.5.1 // indirect
|
||||||
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.10.0 // indirect
|
|
||||||
github.com/shirou/gopsutil/v3 v3.23.11 // indirect
|
|
||||||
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
||||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||||
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||||
@ -74,17 +79,24 @@ require (
|
|||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||||
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||||
go.uber.org/mock v0.4.0 // indirect
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
|
||||||
golang.org/x/arch v0.6.0 // indirect
|
go.opentelemetry.io/otel v1.29.0 // indirect
|
||||||
golang.org/x/crypto v0.17.0 // indirect
|
go.opentelemetry.io/otel/metric v1.29.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect
|
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
|
||||||
golang.org/x/mod v0.14.0 // indirect
|
go.opentelemetry.io/otel/trace v1.29.0 // indirect
|
||||||
golang.org/x/sys v0.15.0 // indirect
|
go.uber.org/mock v0.5.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/arch v0.15.0 // indirect
|
||||||
golang.org/x/tools v0.16.1 // indirect
|
golang.org/x/crypto v0.36.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
|
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
|
||||||
google.golang.org/grpc v1.59.0 // indirect
|
golang.org/x/mod v0.24.0 // indirect
|
||||||
google.golang.org/protobuf v1.32.0 // indirect
|
golang.org/x/net v0.37.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
golang.org/x/sync v0.12.0 // indirect
|
||||||
gotest.tools/v3 v3.5.1 // indirect
|
golang.org/x/sys v0.31.0 // indirect
|
||||||
|
golang.org/x/text v0.23.0 // indirect
|
||||||
|
golang.org/x/time v0.8.0 // indirect
|
||||||
|
golang.org/x/tools v0.31.0 // indirect
|
||||||
|
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
|
||||||
|
google.golang.org/grpc v1.67.3 // indirect
|
||||||
|
google.golang.org/protobuf v1.36.5 // indirect
|
||||||
)
|
)
|
||||||
|
273
go.sum
273
go.sum
@ -4,27 +4,26 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9
|
|||||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
|
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
|
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||||
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||||
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||||
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
|
github.com/Microsoft/hcsshim v0.11.7 h1:vl/nj3Bar/CvJSYo7gIQPyRWc9f3c6IeSNavBTSZNZQ=
|
||||||
github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w=
|
github.com/Microsoft/hcsshim v0.11.7/go.mod h1:MV8xMfmECjl5HdO7U/3/hFVnkmSBjAjmA09d4bExKcU=
|
||||||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
github.com/bytedance/sonic v1.13.1 h1:Jyd5CIvdFnkOWuKXr+wm4Nyk2h0yAFsr8ucJgEasO3g=
|
||||||
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
|
github.com/bytedance/sonic v1.13.1/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||||
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
|
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||||
github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
|
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||||
|
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
|
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
|
||||||
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
|
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
|
github.com/containerd/containerd v1.7.27 h1:yFyEyojddO3MIGVER2xJLWoCIn+Up4GaHFquP7hsFII=
|
||||||
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
|
github.com/containerd/containerd v1.7.27/go.mod h1:xZmPnl75Vc+BLGt4MIfu6bp+fy03gdHAn9bz+FreFR0=
|
||||||
github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0=
|
|
||||||
github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
|
|
||||||
github.com/containerd/containerd v1.7.11 h1:lfGKw3eU35sjV0aG2eYZTiwFEY1pCzxdzicHP3SZILw=
|
|
||||||
github.com/containerd/containerd v1.7.11/go.mod h1:5UluHxHTX2rdvYuZ5OJTC5m/KJNs0Zs9wVoJm9zf5ZE=
|
|
||||||
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
|
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
|
||||||
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
|
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
|
||||||
|
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
|
||||||
|
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
|
||||||
github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E=
|
github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E=
|
||||||
github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc=
|
github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
@ -33,128 +32,127 @@ github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
|
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
|
||||||
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
||||||
github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM=
|
github.com/docker/docker v26.1.5+incompatible h1:NEAxTwEjxV6VbBMBoGG3zPqbiJosIApZjxlbrG9q3/g=
|
||||||
github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
github.com/docker/docker v26.1.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||||
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
|
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
|
||||||
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
|
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
|
||||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
github.com/gin-contrib/secure v0.0.1 h1:DMMx3xXDY+MLA9kzIPHksyzC5/V5J6014c/WAmdS2gQ=
|
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||||
github.com/gin-contrib/secure v0.0.1/go.mod h1:6kseOBFrSR3Is/kM1jDhCg/WsXAMvKJkuPvG9dGph/c=
|
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
github.com/gin-contrib/secure v1.1.1 h1:q1AGANrYRhJYYHZCF0VH/NVvP0uOSMXmXbsaqWRgIEQ=
|
||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/secure v1.1.1/go.mod h1:4IhY8OTLEAI3R7qZF1ya4y75WowL8MJ09i2Kunl83HE=
|
||||||
github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do=
|
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||||
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
|
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||||
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
|
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||||
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
|
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||||
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
|
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||||
|
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
|
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-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
||||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM=
|
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY=
|
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
github.com/go-playground/validator/v10 v10.16.0 h1:x+plE831WK4vaKHO/jpgUGsvLKIqRRkz6M78GuJAfGE=
|
github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=
|
||||||
github.com/go-playground/validator/v10 v10.16.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
|
||||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
|
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
|
||||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
|
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
|
||||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
|
||||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
|
||||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 h1:dHLYa5D8/Ta0aLR2XcPsrkpAgGeFs6thhMcQK0oQ0n8=
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
|
||||||
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
||||||
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms=
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI=
|
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||||
github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
|
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||||
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
|
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/miekg/dns v1.1.64 h1:wuZgD9wwCE6XMT05UU/mlSko71eRSXEAm2EbjQXLKnQ=
|
||||||
|
github.com/miekg/dns v1.1.64/go.mod h1:Dzw9769uoKVaLuODMDZz9M6ynFU6Em65csPuoi8G0ck=
|
||||||
|
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
||||||
|
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||||
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
|
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
|
||||||
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
|
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
|
||||||
github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc=
|
github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc=
|
||||||
github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo=
|
github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo=
|
||||||
|
github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo=
|
||||||
|
github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs=
|
||||||
|
github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g=
|
||||||
|
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
|
||||||
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
|
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
|
||||||
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
|
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
|
||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
|
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
|
||||||
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
|
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
|
||||||
github.com/onsi/ginkgo/v2 v2.13.2 h1:Bi2gGVkfn6gQcjNjZJVO8Gf0FHzMPf2phUei9tejVMs=
|
github.com/onsi/ginkgo/v2 v2.23.0 h1:FA1xjp8ieYDzlgS5ABTpdUDB7wtngggONc8a7ku2NqQ=
|
||||||
github.com/onsi/ginkgo/v2 v2.13.2/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM=
|
github.com/onsi/ginkgo/v2 v2.23.0/go.mod h1:zXTP6xIp3U8aVuXN8ENK9IXRaTjFnpVB9mGmaSRvxnM=
|
||||||
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
|
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
|
||||||
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
|
github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
|
||||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||||
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI=
|
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
|
||||||
github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
|
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
|
||||||
github.com/opencontainers/runc v1.1.9 h1:XR0VIHTGce5eWPkaPesqTBrhW2yAcaraWfsEalNwQLM=
|
github.com/oschwald/maxminddb-golang v1.13.1 h1:G3wwjdN9JmIK2o/ermkHM+98oX5fS+k5MbwsmL4MRQE=
|
||||||
github.com/opencontainers/runc v1.1.9/go.mod h1:CbUumNnWCuTGFukNXahoo/RFBZvDAgRh/smNYNOhA50=
|
github.com/oschwald/maxminddb-golang v1.13.1/go.mod h1:K4pgV9N/GcK694KSTmVSDTODk4IsCNThNdTmnaBZ/F8=
|
||||||
github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs=
|
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||||
github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY=
|
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||||
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
|
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
||||||
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
|
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
||||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||||
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
|
||||||
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
|
||||||
github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs=
|
github.com/quic-go/quic-go v0.50.0 h1:3H/ld1pa3CYhkcc20TPIyG1bNsdhn9qZBGN3b9/UyUo=
|
||||||
github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
|
github.com/quic-go/quic-go v0.50.0/go.mod h1:Vim6OmUvlYdwBhXP9ZVrtGmCMWa3wEqhq3NgYrI8b4E=
|
||||||
github.com/quic-go/quic-go v0.40.1 h1:X3AGzUNFs0jVuO3esAGnTfvdgvL4fq655WaOi1snv1Q=
|
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
|
||||||
github.com/quic-go/quic-go v0.40.1/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c=
|
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4=
|
||||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM=
|
||||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
|
||||||
github.com/shirou/gopsutil/v3 v3.23.11 h1:i3jP9NjCPUz7FiZKxlMnODZkdSIp2gnzfrvsu9CuWEQ=
|
|
||||||
github.com/shirou/gopsutil/v3 v3.23.11/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM=
|
|
||||||
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
||||||
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
||||||
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
||||||
@ -164,107 +162,116 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
|
|||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
|
||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/testcontainers/testcontainers-go v0.27.0 h1:IeIrJN4twonTDuMuBNQdKZ+K97yd7VrmNGu+lDpYcDk=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/testcontainers/testcontainers-go v0.27.0/go.mod h1:+HgYZcd17GshBUZv9b+jKFJ198heWPQq3KQIp2+N+7U=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/testcontainers/testcontainers-go v0.31.0 h1:W0VwIhcEVhRflwL9as3dhY6jXjVCA27AkmbnZ+UTh3U=
|
||||||
|
github.com/testcontainers/testcontainers-go v0.31.0/go.mod h1:D2lAoA0zUFiSY+eAflqK5mcUx/A5hrrORaEQrd0SefI=
|
||||||
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
||||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||||
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
||||||
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
|
||||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
|
||||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
|
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
|
||||||
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||||
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk=
|
||||||
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8=
|
||||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw=
|
||||||
golang.org/x/arch v0.6.0 h1:S0JTfE48HbRj80+4tbvZDYsJ3tGv6BUU3XxyZ7CirAc=
|
go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8=
|
||||||
golang.org/x/arch v0.6.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU=
|
||||||
|
go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc=
|
||||||
|
go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.29.0 h1:vkqKjk7gwhS8VaWb0POZKmIEDimRCMsopNYnriHyryo=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.29.0/go.mod h1:pM8Dx5WKnvxLCb+8lG1PRNIDxu9g9b9g59Qr7hfAAok=
|
||||||
|
go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4=
|
||||||
|
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
||||||
|
go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I=
|
||||||
|
go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
|
||||||
|
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
|
||||||
|
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
|
||||||
|
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
||||||
|
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||||
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b h1:kLiC65FbiHWFAOu+lxwNPujcsl8VYyTYYEZnsOO1WK4=
|
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
|
||||||
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
|
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
|
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
|
||||||
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
|
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
|
||||||
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
|
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
|
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
|
||||||
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
|
||||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||||
|
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
|
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
|
||||||
|
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
|
||||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=
|
golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU=
|
||||||
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
|
golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4=
|
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 h1:CkkIfIt50+lT6NHAVoRYEyAvQGFM7xEwXUUywFvEb3Q=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
|
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576/go.mod h1:1R3kvZ1dtP3+4p4d3G8uJ8rFk/fWlScl38vanWACI08=
|
||||||
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 h1:TqExAhdPaB60Ux47Cn0oLV07rGnxZzIsaRhQaqS666A=
|
||||||
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8/go.mod h1:lcTa1sDdWEIHMWlITnIczmw5w60CF9ffkb8Z+DVmmjA=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/grpc v1.67.3 h1:OgPcDAFKHnH8X3O4WcO4XUc8GRDeKsKReqbQtiCj7N8=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/grpc v1.67.3/go.mod h1:YGaHCc6Oap+FzBJTZLBzkGSYt/cvGPFTPxkn7QfSU8s=
|
||||||
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
||||||
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
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 h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
|
||||||
gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
|
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
|
gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY=
|
||||||
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
|
gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
|
||||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
|
||||||
|
@ -6,83 +6,75 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
validator "github.com/dcarrillo/whatismyip/internal/validator/uuid"
|
||||||
"github.com/dcarrillo/whatismyip/router"
|
"github.com/dcarrillo/whatismyip/router"
|
||||||
"github.com/quic-go/quic-go"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/quic-go/quic-go/http3"
|
"github.com/quic-go/quic-go/http3"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/testcontainers/testcontainers-go"
|
"github.com/stretchr/testify/require"
|
||||||
|
tc "github.com/testcontainers/testcontainers-go"
|
||||||
"github.com/testcontainers/testcontainers-go/wait"
|
"github.com/testcontainers/testcontainers-go/wait"
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildContainer() testcontainers.ContainerRequest {
|
func customDialContext() func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
_, filename, _, _ := runtime.Caller(0)
|
return func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
dir := filepath.Dir(filename)
|
dialer := &net.Dialer{
|
||||||
|
Resolver: &net.Resolver{
|
||||||
|
PreferGo: true,
|
||||||
|
Dial: func(ctx context.Context, _, _ string) (net.Conn, error) {
|
||||||
|
d := net.Dialer{}
|
||||||
|
return d.DialContext(ctx, "udp", "127.0.0.1:53531")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
req := testcontainers.ContainerRequest{
|
return dialer.DialContext(ctx, network, addr)
|
||||||
FromDockerfile: testcontainers.FromDockerfile{
|
|
||||||
Context: "../",
|
|
||||||
Dockerfile: "Dockerfile",
|
|
||||||
},
|
|
||||||
Cmd: []string{
|
|
||||||
"-geoip2-city", "/GeoIP2-City-Test.mmdb",
|
|
||||||
"-geoip2-asn", "/GeoLite2-ASN-Test.mmdb",
|
|
||||||
"-bind", ":8000",
|
|
||||||
"-tls-bind", ":8001",
|
|
||||||
"-tls-crt", "/server.pem",
|
|
||||||
"-tls-key", "/server.key",
|
|
||||||
"-trusted-header", "X-Real-IP",
|
|
||||||
"-enable-secure-headers",
|
|
||||||
"-enable-http3",
|
|
||||||
},
|
|
||||||
ExposedPorts: []string{"8000:8000", "8001:8001", "8001:8001/udp"},
|
|
||||||
WaitingFor: wait.ForHTTP("/geo").
|
|
||||||
WithTLS(true, &tls.Config{InsecureSkipVerify: true}).
|
|
||||||
WithPort("8001"),
|
|
||||||
Files: []testcontainers.ContainerFile{
|
|
||||||
{
|
|
||||||
HostFilePath: filepath.Join(dir, "/../test/GeoIP2-City-Test.mmdb"),
|
|
||||||
ContainerFilePath: "/GeoIP2-City-Test.mmdb",
|
|
||||||
FileMode: 0644,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
HostFilePath: filepath.Join(dir, "/../test/GeoLite2-ASN-Test.mmdb"),
|
|
||||||
ContainerFilePath: "/GeoLite2-ASN-Test.mmdb",
|
|
||||||
FileMode: 0644,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
HostFilePath: filepath.Join(dir, "/../test/server.pem"),
|
|
||||||
ContainerFilePath: "/server.pem",
|
|
||||||
FileMode: 0644,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
HostFilePath: filepath.Join(dir, "/../test/server.key"),
|
|
||||||
ContainerFilePath: "/server.key",
|
|
||||||
FileMode: 0644,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return req
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func initContainer(t assert.TestingT, request testcontainers.ContainerRequest) func() {
|
func testWhatIsMyDNS(t *testing.T) {
|
||||||
ctx := context.Background()
|
t.Run("RequestDNSDiscovery", func(t *testing.T) {
|
||||||
|
http.DefaultTransport.(*http.Transport).DialContext = customDialContext()
|
||||||
|
req, err := http.NewRequest("GET", "http://localhost:8000", nil)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
req.Host = "dns.example.com"
|
||||||
|
client := &http.Client{
|
||||||
|
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
|
||||||
|
return http.ErrUseLastResponse
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
|
resp, err := client.Do(req)
|
||||||
ContainerRequest: request,
|
assert.NoError(t, err)
|
||||||
Started: true,
|
assert.Equal(t, http.StatusFound, resp.StatusCode)
|
||||||
|
u, err := resp.Location()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.True(t, validator.IsValid(strings.Split(u.Hostname(), ".")[0]))
|
||||||
|
|
||||||
|
for _, accept := range []string{"application/json", "*/*", "text/html"} {
|
||||||
|
req, err = http.NewRequest("GET", u.String(), nil)
|
||||||
|
req.Host = u.Hostname()
|
||||||
|
req.Header.Set("Accept", accept)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
resp, err = client.Do(req)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||||
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
if accept == "application/json" {
|
||||||
|
assert.NoError(t, json.Unmarshal(body, &router.DNSJSONResponse{}))
|
||||||
|
} else {
|
||||||
|
ip := strings.Split(string(body), " ")[0]
|
||||||
|
assert.True(t, net.ParseIP(ip) != nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
return func() {
|
|
||||||
assert.NoError(t, container.Terminate(ctx))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContainerIntegration(t *testing.T) {
|
func TestContainerIntegration(t *testing.T) {
|
||||||
@ -90,7 +82,65 @@ func TestContainerIntegration(t *testing.T) {
|
|||||||
t.Skip("Skiping integration tests")
|
t.Skip("Skiping integration tests")
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Cleanup(initContainer(t, buildContainer()))
|
ctx := context.Background()
|
||||||
|
c, err := tc.GenericContainer(ctx, tc.GenericContainerRequest{
|
||||||
|
ContainerRequest: tc.ContainerRequest{
|
||||||
|
FromDockerfile: tc.FromDockerfile{
|
||||||
|
Context: "../",
|
||||||
|
Dockerfile: "./test/Dockerfile",
|
||||||
|
PrintBuildLog: true,
|
||||||
|
KeepImage: false,
|
||||||
|
BuildOptionsModifier: func(buildOptions *types.ImageBuildOptions) {
|
||||||
|
buildOptions.Target = "test"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ExposedPorts: []string{
|
||||||
|
"8000:8000",
|
||||||
|
"8001:8001",
|
||||||
|
"8001:8001/udp",
|
||||||
|
"53531:53/udp",
|
||||||
|
},
|
||||||
|
Cmd: []string{
|
||||||
|
"-geoip2-city", "/GeoIP2-City-Test.mmdb",
|
||||||
|
"-geoip2-asn", "/GeoLite2-ASN-Test.mmdb",
|
||||||
|
"-bind", ":8000",
|
||||||
|
"-tls-bind", ":8001",
|
||||||
|
"-tls-crt", "/server.pem",
|
||||||
|
"-tls-key", "/server.key",
|
||||||
|
"-trusted-header", "X-Real-IP",
|
||||||
|
"-enable-secure-headers",
|
||||||
|
"-enable-http3",
|
||||||
|
"-resolver", "/resolver.yml",
|
||||||
|
},
|
||||||
|
Files: []tc.ContainerFile{
|
||||||
|
{
|
||||||
|
HostFilePath: "./../test/GeoIP2-City-Test.mmdb",
|
||||||
|
ContainerFilePath: "/GeoIP2-City-Test.mmdb",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
HostFilePath: "./../test/GeoLite2-ASN-Test.mmdb",
|
||||||
|
ContainerFilePath: "/GeoLite2-ASN-Test.mmdb",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
HostFilePath: "./../test/server.pem",
|
||||||
|
ContainerFilePath: "/server.pem",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
HostFilePath: "./../test/server.key",
|
||||||
|
ContainerFilePath: "/server.key",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
HostFilePath: "./../test/resolver.yml",
|
||||||
|
ContainerFilePath: "/resolver.yml",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
WaitingFor: wait.ForLog("Starting QUIC server"),
|
||||||
|
AutoRemove: true,
|
||||||
|
},
|
||||||
|
Started: true,
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
t.Cleanup(func() { c.Terminate(ctx) })
|
||||||
|
|
||||||
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@ -144,8 +194,10 @@ func TestContainerIntegration(t *testing.T) {
|
|||||||
resp, body, err = doQuicRequest(req)
|
resp, body, err = doQuicRequest(req)
|
||||||
} else {
|
} else {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
resp, _ = client.Do(req)
|
resp, err = client.Do(req)
|
||||||
|
assert.NoError(t, err)
|
||||||
body, err = io.ReadAll(resp.Body)
|
body, err = io.ReadAll(resp.Body)
|
||||||
|
assert.NoError(t, err)
|
||||||
if strings.Contains(tt.url, "https://") {
|
if strings.Contains(tt.url, "https://") {
|
||||||
assert.Equal(t, `h3=":8001"; ma=2592000`, resp.Header.Get("Alt-Svc"))
|
assert.Equal(t, `h3=":8001"; ma=2592000`, resp.Header.Get("Alt-Svc"))
|
||||||
}
|
}
|
||||||
@ -178,16 +230,16 @@ func TestContainerIntegration(t *testing.T) {
|
|||||||
assert.NoError(t, json.Unmarshal(body, &j))
|
assert.NoError(t, json.Unmarshal(body, &j))
|
||||||
assert.Equal(t, tt.want, j.Reachable)
|
assert.Equal(t, tt.want, j.Reachable)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testWhatIsMyDNS(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func doQuicRequest(req *http.Request) (*http.Response, []byte, error) {
|
func doQuicRequest(req *http.Request) (*http.Response, []byte, error) {
|
||||||
roundTripper := &http3.RoundTripper{
|
roundTripper := &http3.Transport{
|
||||||
TLSClientConfig: &tls.Config{
|
TLSClientConfig: &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
},
|
},
|
||||||
QuicConfig: &quic.Config{},
|
|
||||||
}
|
}
|
||||||
defer roundTripper.Close()
|
defer roundTripper.Close()
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ func GetLogFormatter(param gin.LogFormatterParams) string {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeLog(log interface{}) interface{} {
|
func normalizeLog(log any) any {
|
||||||
switch v := log.(type) {
|
switch v := log.(type) {
|
||||||
case string:
|
case string:
|
||||||
if v == "" {
|
if v == "" {
|
||||||
|
@ -9,18 +9,29 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/dcarrillo/whatismyip/internal/core"
|
"github.com/dcarrillo/whatismyip/internal/core"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type geodbPath struct {
|
type geodbConf struct {
|
||||||
City string
|
City string
|
||||||
ASN string
|
ASN string
|
||||||
|
Token *string
|
||||||
}
|
}
|
||||||
type serverSettings struct {
|
type serverSettings struct {
|
||||||
ReadTimeout time.Duration
|
ReadTimeout time.Duration
|
||||||
WriteTimeout time.Duration
|
WriteTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type resolver struct {
|
||||||
|
Domain string `yaml:"domain"`
|
||||||
|
ResourceRecords []string `yaml:"resource_records"`
|
||||||
|
RedirectPort string `yaml:"redirect_port,omitempty"`
|
||||||
|
Ipv4 []string `yaml:"ipv4,omitempty"`
|
||||||
|
Ipv6 []string `yaml:"ipv6,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type settings struct {
|
type settings struct {
|
||||||
GeodbPath geodbPath
|
GeodbPath geodbConf
|
||||||
TemplatePath string
|
TemplatePath string
|
||||||
BindAddress string
|
BindAddress string
|
||||||
TLSAddress string
|
TLSAddress string
|
||||||
@ -31,15 +42,14 @@ type settings struct {
|
|||||||
EnableSecureHeaders bool
|
EnableSecureHeaders bool
|
||||||
EnableHTTP3 bool
|
EnableHTTP3 bool
|
||||||
Server serverSettings
|
Server serverSettings
|
||||||
|
Resolver resolver
|
||||||
version bool
|
version bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultAddress = ":8080"
|
const defaultAddress = ":8080"
|
||||||
|
|
||||||
// ErrVersion is the custom error triggered when -version flag is passed
|
|
||||||
var ErrVersion = errors.New("setting: version requested")
|
var ErrVersion = errors.New("setting: version requested")
|
||||||
|
|
||||||
// App is the var with the parsed settings
|
|
||||||
var App = settings{
|
var App = settings{
|
||||||
// hard-coded for the time being
|
// hard-coded for the time being
|
||||||
Server: serverSettings{
|
Server: serverSettings{
|
||||||
@ -48,15 +58,20 @@ var App = settings{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup initializes the App object parsing the flags
|
|
||||||
func Setup(args []string) (output string, err error) {
|
func Setup(args []string) (output string, err error) {
|
||||||
flags := flag.NewFlagSet("whatismyip", flag.ContinueOnError)
|
flags := flag.NewFlagSet("whatismyip", flag.ContinueOnError)
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
var resolverConf string
|
||||||
flags.SetOutput(&buf)
|
flags.SetOutput(&buf)
|
||||||
|
|
||||||
flags.StringVar(&App.GeodbPath.City, "geoip2-city", "", "Path to GeoIP2 city database")
|
flags.StringVar(&App.GeodbPath.City, "geoip2-city", "", "Path to GeoIP2 city database. Enables geo information (--geoip2-asn becomes mandatory)")
|
||||||
flags.StringVar(&App.GeodbPath.ASN, "geoip2-asn", "", "Path to GeoIP2 ASN database")
|
flags.StringVar(&App.GeodbPath.ASN, "geoip2-asn", "", "Path to GeoIP2 ASN database. Enables ASN information. (--geoip2-city becomes mandatory)")
|
||||||
flags.StringVar(&App.TemplatePath, "template", "", "Path to template file")
|
flags.StringVar(&App.TemplatePath, "template", "", "Path to the template file")
|
||||||
|
flags.StringVar(
|
||||||
|
&resolverConf,
|
||||||
|
"resolver",
|
||||||
|
"",
|
||||||
|
"Path to the resolver configuration. It actually enables the resolver for DNS client discovery.")
|
||||||
flags.StringVar(
|
flags.StringVar(
|
||||||
&App.BindAddress,
|
&App.BindAddress,
|
||||||
"bind",
|
"bind",
|
||||||
@ -106,12 +121,12 @@ func Setup(args []string) (output string, err error) {
|
|||||||
return fmt.Sprintf("whatismyip version %s", core.Version), ErrVersion
|
return fmt.Sprintf("whatismyip version %s", core.Version), ErrVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
if App.TrustedPortHeader != "" && App.TrustedHeader == "" {
|
if (App.GeodbPath.City != "" && App.GeodbPath.ASN == "") || (App.GeodbPath.City == "" && App.GeodbPath.ASN != "") {
|
||||||
return "", fmt.Errorf("truster-header is mandatory when truster-port-header is set")
|
return "", fmt.Errorf("both --geoip2-city and --geoip2-asn are mandatory to enable geo information")
|
||||||
}
|
}
|
||||||
|
|
||||||
if App.GeodbPath.City == "" || App.GeodbPath.ASN == "" {
|
if App.TrustedPortHeader != "" && App.TrustedHeader == "" {
|
||||||
return "", fmt.Errorf("geoip2-city and geoip2-asn parameters are mandatory")
|
return "", fmt.Errorf("truster-header is mandatory when truster-port-header is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App.TLSAddress != "") && (App.TLSCrtPath == "" || App.TLSKeyPath == "") {
|
if (App.TLSAddress != "") && (App.TLSCrtPath == "" || App.TLSKeyPath == "") {
|
||||||
@ -132,5 +147,21 @@ func Setup(args []string) (output string, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if resolverConf != "" {
|
||||||
|
var err error
|
||||||
|
App.Resolver, err = readYAML(resolverConf)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("error reading resolver configuration %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return buf.String(), nil
|
return buf.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func readYAML(path string) (resolver resolver, err error) {
|
||||||
|
yamlFile, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return resolver, err
|
||||||
|
}
|
||||||
|
return resolver, yaml.Unmarshal(yamlFile, &resolver)
|
||||||
|
}
|
||||||
|
@ -12,44 +12,43 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestParseMandatoryFlags(t *testing.T) {
|
func TestParseMandatoryFlags(t *testing.T) {
|
||||||
var mandatoryFlags = []struct {
|
mandatoryFlags := []struct {
|
||||||
args []string
|
args []string
|
||||||
}{
|
}{
|
||||||
{
|
|
||||||
[]string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
[]string{"-geoip2-city", "/city-path"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
[]string{"-geoip2-asn", "/asn-path"},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
[]string{
|
[]string{
|
||||||
"-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path", "-tls-bind", ":9000",
|
"-geoip2-city", "my-city-path",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{
|
[]string{
|
||||||
"-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path", "-tls-bind", ":9000",
|
"-geoip2-asn", "my-asn-path",
|
||||||
"-tls-crt", "/crt-path",
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
[]string{
|
||||||
|
"-tls-bind", ":9000",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{
|
[]string{
|
||||||
"-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path", "-tls-bind", ":9000",
|
"-tls-bind", ":9000", "-tls-crt", "/crt-path",
|
||||||
"-tls-key", "/key-path",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{
|
[]string{
|
||||||
"-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path", "-enable-http3",
|
"-tls-bind", ":9000", "-tls-key", "/key-path",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{
|
[]string{
|
||||||
"-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path", "-bind", ":8000",
|
"-enable-http3",
|
||||||
"-trusted-port-header", "port-header",
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
[]string{
|
||||||
|
"-bind", ":8000", "-trusted-port-header", "port-header",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -57,24 +56,20 @@ func TestParseMandatoryFlags(t *testing.T) {
|
|||||||
for _, tt := range mandatoryFlags {
|
for _, tt := range mandatoryFlags {
|
||||||
t.Run(strings.Join(tt.args, " "), func(t *testing.T) {
|
t.Run(strings.Join(tt.args, " "), func(t *testing.T) {
|
||||||
_, err := Setup(tt.args)
|
_, err := Setup(tt.args)
|
||||||
require.NotNil(t, err)
|
require.Error(t, err)
|
||||||
assert.Contains(t, err.Error(), "mandatory")
|
assert.Contains(t, err.Error(), "mandatory")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseFlags(t *testing.T) {
|
func TestParseFlags(t *testing.T) {
|
||||||
var flags = []struct {
|
flags := []struct {
|
||||||
args []string
|
args []string
|
||||||
conf settings
|
conf settings
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
[]string{"-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path"},
|
[]string{},
|
||||||
settings{
|
settings{
|
||||||
GeodbPath: geodbPath{
|
|
||||||
City: "/city-path",
|
|
||||||
ASN: "/asn-path",
|
|
||||||
},
|
|
||||||
BindAddress: ":8080",
|
BindAddress: ":8080",
|
||||||
Server: serverSettings{
|
Server: serverSettings{
|
||||||
ReadTimeout: 10 * time.Second,
|
ReadTimeout: 10 * time.Second,
|
||||||
@ -85,7 +80,7 @@ func TestParseFlags(t *testing.T) {
|
|||||||
{
|
{
|
||||||
[]string{"-bind", ":8001", "-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path"},
|
[]string{"-bind", ":8001", "-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path"},
|
||||||
settings{
|
settings{
|
||||||
GeodbPath: geodbPath{
|
GeodbPath: geodbConf{
|
||||||
City: "/city-path",
|
City: "/city-path",
|
||||||
ASN: "/asn-path",
|
ASN: "/asn-path",
|
||||||
},
|
},
|
||||||
@ -102,7 +97,7 @@ func TestParseFlags(t *testing.T) {
|
|||||||
"-tls-crt", "/crt-path", "-tls-key", "/key-path",
|
"-tls-crt", "/crt-path", "-tls-key", "/key-path",
|
||||||
},
|
},
|
||||||
settings{
|
settings{
|
||||||
GeodbPath: geodbPath{
|
GeodbPath: geodbConf{
|
||||||
City: "/city-path",
|
City: "/city-path",
|
||||||
ASN: "/asn-path",
|
ASN: "/asn-path",
|
||||||
},
|
},
|
||||||
@ -122,7 +117,7 @@ func TestParseFlags(t *testing.T) {
|
|||||||
"-trusted-header", "header", "-trusted-port-header", "port-header",
|
"-trusted-header", "header", "-trusted-port-header", "port-header",
|
||||||
},
|
},
|
||||||
settings{
|
settings{
|
||||||
GeodbPath: geodbPath{
|
GeodbPath: geodbConf{
|
||||||
City: "/city-path",
|
City: "/city-path",
|
||||||
ASN: "/asn-path",
|
ASN: "/asn-path",
|
||||||
},
|
},
|
||||||
@ -141,7 +136,7 @@ func TestParseFlags(t *testing.T) {
|
|||||||
"-trusted-header", "header", "-enable-secure-headers",
|
"-trusted-header", "header", "-enable-secure-headers",
|
||||||
},
|
},
|
||||||
settings{
|
settings{
|
||||||
GeodbPath: geodbPath{
|
GeodbPath: geodbConf{
|
||||||
City: "/city-path",
|
City: "/city-path",
|
||||||
ASN: "/asn-path",
|
ASN: "/asn-path",
|
||||||
},
|
},
|
||||||
@ -166,7 +161,7 @@ func TestParseFlags(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestParseFlagsUsage(t *testing.T) {
|
func TestParseFlagsUsage(t *testing.T) {
|
||||||
var usageArgs = []string{"-help", "-h", "--help"}
|
usageArgs := []string{"-help", "-h", "--help"}
|
||||||
|
|
||||||
for _, arg := range usageArgs {
|
for _, arg := range usageArgs {
|
||||||
t.Run(arg, func(t *testing.T) {
|
t.Run(arg, func(t *testing.T) {
|
||||||
@ -184,19 +179,28 @@ func TestParseFlagVersion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestParseFlagTemplate(t *testing.T) {
|
func TestParseFlagTemplate(t *testing.T) {
|
||||||
flags := []string{
|
testCases := []struct {
|
||||||
"-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path",
|
name string
|
||||||
"-template", "/template-path",
|
flags []string
|
||||||
|
errMsg string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Invalid template path",
|
||||||
|
flags: []string{"-template", "/template-path"},
|
||||||
|
errMsg: "no such file or directory",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Template path is a directory",
|
||||||
|
flags: []string{"-template", "/"},
|
||||||
|
errMsg: "must be a file",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
_, err := Setup(flags)
|
|
||||||
assert.Error(t, err)
|
|
||||||
assert.Contains(t, err.Error(), "no such file or directory")
|
|
||||||
|
|
||||||
flags = []string{
|
for _, tc := range testCases {
|
||||||
"-geoip2-city", "/city-path", "-geoip2-asn", "/asn-path",
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
"-template", "/",
|
_, err := Setup(tc.flags)
|
||||||
|
require.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), tc.errMsg)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
_, err = Setup(flags)
|
|
||||||
require.Error(t, err)
|
|
||||||
assert.Contains(t, err.Error(), "must be a file")
|
|
||||||
}
|
}
|
||||||
|
10
internal/validator/uuid/uuid.go
Normal file
10
internal/validator/uuid/uuid.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package uuid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
func IsValid(u string) bool {
|
||||||
|
_, err := uuid.Parse(u)
|
||||||
|
return err == nil
|
||||||
|
}
|
37
internal/validator/uuid/uuid_test.go
Normal file
37
internal/validator/uuid/uuid_test.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package uuid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsValid(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
u string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Valid UUID",
|
||||||
|
u: "3b241101-e2bb-4255-8caf-4136c566a964",
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Invalid UUID",
|
||||||
|
u: "invalid-uuid",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Empty string",
|
||||||
|
u: "",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
assert.True(t, IsValid(tt.u) == tt.want)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
127
models/geo.go
127
models/geo.go
@ -1,13 +1,13 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/oschwald/maxminddb-golang"
|
"github.com/oschwald/maxminddb-golang"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GeoRecord is the model for City database
|
|
||||||
type GeoRecord struct {
|
type GeoRecord struct {
|
||||||
Country struct {
|
Country struct {
|
||||||
ISOCode string `maxminddb:"iso_code"`
|
ISOCode string `maxminddb:"iso_code"`
|
||||||
@ -26,52 +26,107 @@ type GeoRecord struct {
|
|||||||
} `maxminddb:"postal"`
|
} `maxminddb:"postal"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ASNRecord is the model for ASN database
|
|
||||||
type ASNRecord struct {
|
type ASNRecord struct {
|
||||||
AutonomousSystemNumber uint `maxminddb:"autonomous_system_number"`
|
AutonomousSystemNumber uint `maxminddb:"autonomous_system_number"`
|
||||||
AutonomousSystemOrganization string `maxminddb:"autonomous_system_organization"`
|
AutonomousSystemOrganization string `maxminddb:"autonomous_system_organization"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type geodb struct {
|
type GeoDB struct {
|
||||||
city *maxminddb.Reader
|
cityPath string
|
||||||
asn *maxminddb.Reader
|
asnPath string
|
||||||
|
City *maxminddb.Reader
|
||||||
|
ASN *maxminddb.Reader
|
||||||
}
|
}
|
||||||
|
|
||||||
var db geodb
|
func Setup(cityPath string, asnPath string) (*GeoDB, error) {
|
||||||
|
city, asn, err := openDatabases(cityPath, asnPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
func openMMDB(path string) *maxminddb.Reader {
|
return &GeoDB{
|
||||||
|
cityPath: cityPath,
|
||||||
|
asnPath: asnPath,
|
||||||
|
City: city,
|
||||||
|
ASN: asn,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *GeoDB) CloseDBs() error {
|
||||||
|
var errs []error
|
||||||
|
|
||||||
|
if db.City != nil {
|
||||||
|
if err := db.City.Close(); err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("closing city db: %w", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if db.ASN != nil {
|
||||||
|
if err := db.ASN.Close(); err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("closing ASN db: %w", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(errs) > 0 {
|
||||||
|
return fmt.Errorf("errors closing databases: %s", errs)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *GeoDB) Reload() error {
|
||||||
|
if err := db.CloseDBs(); err != nil {
|
||||||
|
return fmt.Errorf("closing existing connections: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
city, asn, err := openDatabases(db.cityPath, db.asnPath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("opening new connections: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
db.City = city
|
||||||
|
db.ASN = asn
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *GeoDB) LookupCity(ip net.IP) (*GeoRecord, error) {
|
||||||
|
record := &GeoRecord{}
|
||||||
|
err := db.City.Lookup(ip, record)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return record, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *GeoDB) LookupASN(ip net.IP) (*ASNRecord, error) {
|
||||||
|
record := &ASNRecord{}
|
||||||
|
err := db.ASN.Lookup(ip, record)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return record, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func openDatabases(cityPath, asnPath string) (*maxminddb.Reader, *maxminddb.Reader, error) {
|
||||||
|
city, err := openMMDB(cityPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
asn, err := openMMDB(asnPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return city, asn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func openMMDB(path string) (*maxminddb.Reader, error) {
|
||||||
db, err := maxminddb.Open(path)
|
db, err := maxminddb.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Printf("Database %s has been loaded\n", path)
|
log.Printf("Database %s has been loaded\n", path)
|
||||||
|
|
||||||
return db
|
return db, nil
|
||||||
}
|
|
||||||
|
|
||||||
// Setup opens all Geolite2 databases
|
|
||||||
func Setup(cityPath string, asnPath string) {
|
|
||||||
db.city = openMMDB(cityPath)
|
|
||||||
db.asn = openMMDB(asnPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CloseDBs unmaps from memory and frees resources to the filesystem
|
|
||||||
func CloseDBs() {
|
|
||||||
log.Printf("Closing dbs...")
|
|
||||||
if err := db.city.Close(); err != nil {
|
|
||||||
log.Printf("Error closing city db: %s", err)
|
|
||||||
}
|
|
||||||
if err := db.asn.Close(); err != nil {
|
|
||||||
log.Printf("Error closing ASN db: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LookUp an IP and get city data
|
|
||||||
func (record *GeoRecord) LookUp(ip net.IP) error {
|
|
||||||
return db.city.Lookup(ip, record)
|
|
||||||
}
|
|
||||||
|
|
||||||
// LookUp an IP and get ASN data
|
|
||||||
func (record *ASNRecord) LookUp(ip net.IP) error {
|
|
||||||
return db.asn.Lookup(ip, record)
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestModels(t *testing.T) {
|
func TestModels(t *testing.T) {
|
||||||
@ -59,19 +61,21 @@ func TestModels(t *testing.T) {
|
|||||||
AutonomousSystemOrganization: "IP-Only",
|
AutonomousSystemOrganization: "IP-Only",
|
||||||
}
|
}
|
||||||
|
|
||||||
Setup("../test/GeoIP2-City-Test.mmdb", "../test/GeoLite2-ASN-Test.mmdb")
|
db, err := Setup("../test/GeoIP2-City-Test.mmdb", "../test/GeoLite2-ASN-Test.mmdb")
|
||||||
defer CloseDBs()
|
require.NoError(t, err, fmt.Sprintf("Error setting up db: %s", err))
|
||||||
|
defer db.CloseDBs()
|
||||||
|
assert.NotNil(t, db.ASN)
|
||||||
|
assert.NotNil(t, db.City)
|
||||||
|
|
||||||
assert.NotNil(t, db.asn)
|
cityRecord, err := db.LookupCity(net.ParseIP("81.2.69.192"))
|
||||||
assert.NotNil(t, db.city)
|
require.NoError(t, err, fmt.Sprintf("Error looking up city: %s", err))
|
||||||
|
|
||||||
cityRecord := &GeoRecord{}
|
|
||||||
assert.Nil(t, cityRecord.LookUp(net.ParseIP("81.2.69.192")))
|
|
||||||
assert.Equal(t, expectedCity, cityRecord)
|
assert.Equal(t, expectedCity, cityRecord)
|
||||||
assert.Error(t, cityRecord.LookUp(net.ParseIP("error")))
|
_, err = db.LookupCity(net.ParseIP("error"))
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
asnRecord := &ASNRecord{}
|
asnRecord, err := db.LookupASN(net.ParseIP("82.99.17.64"))
|
||||||
assert.Nil(t, asnRecord.LookUp(net.ParseIP("82.99.17.64")))
|
require.NoError(t, err, fmt.Sprintf("Error looking up asn: %s", err))
|
||||||
assert.Equal(t, expectedASN, asnRecord)
|
assert.Equal(t, expectedASN, asnRecord)
|
||||||
assert.Error(t, asnRecord.LookUp(net.ParseIP("error")))
|
_, err = db.LookupASN(net.ParseIP("error"))
|
||||||
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
165
resolver/setup.go
Normal file
165
resolver/setup.go
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
package resolver
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/dcarrillo/whatismyip/internal/setting"
|
||||||
|
"github.com/dcarrillo/whatismyip/internal/validator/uuid"
|
||||||
|
"github.com/miekg/dns"
|
||||||
|
"github.com/patrickmn/go-cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Resolver struct {
|
||||||
|
handler *dns.ServeMux
|
||||||
|
store *cache.Cache
|
||||||
|
domain string
|
||||||
|
rr []string
|
||||||
|
ipv4 []net.IP
|
||||||
|
ipv6 []net.IP
|
||||||
|
}
|
||||||
|
|
||||||
|
func ensureDotSuffix(s string) string {
|
||||||
|
if !strings.HasSuffix(s, ".") {
|
||||||
|
return s + "."
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
func Setup(store *cache.Cache) *Resolver {
|
||||||
|
var ipv4, ipv6 []net.IP
|
||||||
|
for _, ip := range setting.App.Resolver.Ipv4 {
|
||||||
|
ipv4 = append(ipv4, net.ParseIP(ip))
|
||||||
|
}
|
||||||
|
for _, ip := range setting.App.Resolver.Ipv6 {
|
||||||
|
ipv6 = append(ipv6, net.ParseIP(ip))
|
||||||
|
}
|
||||||
|
|
||||||
|
resolver := &Resolver{
|
||||||
|
handler: dns.NewServeMux(),
|
||||||
|
store: store,
|
||||||
|
domain: ensureDotSuffix(setting.App.Resolver.Domain),
|
||||||
|
rr: setting.App.Resolver.ResourceRecords,
|
||||||
|
ipv4: ipv4,
|
||||||
|
ipv6: ipv6,
|
||||||
|
}
|
||||||
|
resolver.handler.HandleFunc(resolver.domain, resolver.resolve)
|
||||||
|
resolver.handler.HandleFunc(".", resolver.blackHole)
|
||||||
|
|
||||||
|
return resolver
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rsv *Resolver) Handler() *dns.ServeMux {
|
||||||
|
return rsv.handler
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rsv *Resolver) blackHole(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
|
msg := startReply(r)
|
||||||
|
msg.SetRcode(r, dns.RcodeRefused)
|
||||||
|
w.WriteMsg(msg)
|
||||||
|
logger(w, r.Question[0], msg.Rcode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rsv *Resolver) resolve(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
|
msg := startReply(r)
|
||||||
|
q := r.Question[0]
|
||||||
|
ip, _, _ := net.SplitHostPort(w.RemoteAddr().String())
|
||||||
|
|
||||||
|
for _, res := range rsv.rr {
|
||||||
|
t := strings.Split(res, " ")[2]
|
||||||
|
if q.Qtype == dns.StringToType[t] {
|
||||||
|
brr, err := buildRR(rsv.domain + " " + res)
|
||||||
|
if err != nil {
|
||||||
|
msg.SetRcode(r, dns.RcodeServerFailure)
|
||||||
|
logger(w, q, msg.Rcode, err.Error())
|
||||||
|
} else {
|
||||||
|
msg.Answer = append(msg.Answer, brr)
|
||||||
|
logger(w, q, msg.Rcode)
|
||||||
|
}
|
||||||
|
w.WriteMsg(msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lowerName := strings.ToLower(q.Name) // lowercase because of dns-0x20
|
||||||
|
subDomain := strings.Split(lowerName, ".")[0]
|
||||||
|
switch {
|
||||||
|
case uuid.IsValid(subDomain):
|
||||||
|
msg.SetRcode(r, rsv.getIP(q, msg))
|
||||||
|
rsv.store.Add(subDomain, ip, cache.DefaultExpiration)
|
||||||
|
case lowerName == rsv.domain:
|
||||||
|
msg.SetRcode(r, rsv.getIP(q, msg))
|
||||||
|
default:
|
||||||
|
msg.SetRcode(r, dns.RcodeRefused)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.WriteMsg(msg)
|
||||||
|
logger(w, q, msg.Rcode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rsv *Resolver) getIP(question dns.Question, msg *dns.Msg) int {
|
||||||
|
if question.Qtype == dns.TypeA && len(rsv.ipv4) > 0 {
|
||||||
|
for _, ip := range rsv.ipv4 {
|
||||||
|
msg.Answer = append(msg.Answer, &dns.A{
|
||||||
|
Hdr: setHdr(question),
|
||||||
|
A: ip,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return dns.RcodeSuccess
|
||||||
|
}
|
||||||
|
|
||||||
|
if question.Qtype == dns.TypeAAAA && len(rsv.ipv6) > 0 {
|
||||||
|
for _, ip := range rsv.ipv6 {
|
||||||
|
msg.Answer = append(msg.Answer, &dns.AAAA{
|
||||||
|
Hdr: setHdr(question),
|
||||||
|
AAAA: ip,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return dns.RcodeSuccess
|
||||||
|
}
|
||||||
|
|
||||||
|
return dns.RcodeRefused
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildRR(rrs string) (dns.RR, error) {
|
||||||
|
rr, err := dns.NewRR(rrs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return rr, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func setHdr(q dns.Question) dns.RR_Header {
|
||||||
|
return dns.RR_Header{
|
||||||
|
Name: q.Name,
|
||||||
|
Rrtype: q.Qtype,
|
||||||
|
Class: dns.ClassINET,
|
||||||
|
Ttl: 60,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func startReply(r *dns.Msg) *dns.Msg {
|
||||||
|
msg := new(dns.Msg)
|
||||||
|
msg.SetReply(r)
|
||||||
|
msg.Authoritative = true
|
||||||
|
|
||||||
|
return msg
|
||||||
|
}
|
||||||
|
|
||||||
|
func logger(w dns.ResponseWriter, q dns.Question, code int, err ...string) {
|
||||||
|
emsg := ""
|
||||||
|
if len(err) > 0 {
|
||||||
|
emsg = " - " + strings.Join(err, " ")
|
||||||
|
}
|
||||||
|
ip, _, _ := net.SplitHostPort(w.RemoteAddr().String())
|
||||||
|
log.Printf(
|
||||||
|
"DNS %s - %s - %s - %s%s",
|
||||||
|
ip,
|
||||||
|
dns.TypeToString[q.Qtype],
|
||||||
|
q.Name,
|
||||||
|
dns.RcodeToString[code],
|
||||||
|
emsg,
|
||||||
|
)
|
||||||
|
}
|
97
router/dns.go
Normal file
97
router/dns.go
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
package router
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
validator "github.com/dcarrillo/whatismyip/internal/validator/uuid"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/patrickmn/go-cache"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DNSJSONResponse struct {
|
||||||
|
DNS dnsData `json:"dns"`
|
||||||
|
}
|
||||||
|
type dnsGeoData struct {
|
||||||
|
Country string `json:"country,omitempty"`
|
||||||
|
AsnOrganization string `json:"provider,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type dnsData struct {
|
||||||
|
IP string `json:"ip"`
|
||||||
|
dnsGeoData
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// Implement a proper vhost manager instead of using a middleware
|
||||||
|
func GetDNSDiscoveryHandler(store *cache.Cache, domain string, redirectPort string) gin.HandlerFunc {
|
||||||
|
return func(ctx *gin.Context) {
|
||||||
|
if !strings.HasSuffix(ctx.Request.Host, domain) {
|
||||||
|
ctx.Next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx.Request.Host == domain && ctx.Request.URL.Path == "/" {
|
||||||
|
ctx.Redirect(http.StatusFound, fmt.Sprintf("http://%s.%s%s", uuid.New().String(), domain, redirectPort))
|
||||||
|
ctx.Abort()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
handleDNS(ctx, store)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleDNS(ctx *gin.Context, store *cache.Cache) {
|
||||||
|
d := strings.Split(ctx.Request.Host, ".")[0]
|
||||||
|
if !validator.IsValid(d) {
|
||||||
|
ctx.String(http.StatusNotFound, http.StatusText(http.StatusNotFound))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
v, found := store.Get(d)
|
||||||
|
if !found {
|
||||||
|
ctx.String(http.StatusNotFound, http.StatusText(http.StatusNotFound))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ipStr, ok := v.(string)
|
||||||
|
if !ok {
|
||||||
|
ctx.String(http.StatusNotFound, http.StatusText(http.StatusNotFound))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ip := net.ParseIP(ipStr)
|
||||||
|
if ip == nil {
|
||||||
|
ctx.String(http.StatusNotFound, http.StatusText(http.StatusNotFound))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
geoResp := dnsGeoData{}
|
||||||
|
if geoSvc != nil {
|
||||||
|
cityRecord := geoSvc.LookUpCity(ip)
|
||||||
|
asnRecord := geoSvc.LookUpASN(ip)
|
||||||
|
|
||||||
|
geoResp = dnsGeoData{
|
||||||
|
Country: cityRecord.Country.Names["en"],
|
||||||
|
AsnOrganization: asnRecord.AutonomousSystemOrganization,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
j := DNSJSONResponse{
|
||||||
|
DNS: dnsData{
|
||||||
|
IP: ipStr,
|
||||||
|
dnsGeoData: geoResp,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ctx.NegotiateFormat(gin.MIMEPlain, gin.MIMEHTML, gin.MIMEJSON) {
|
||||||
|
case gin.MIMEJSON:
|
||||||
|
ctx.JSON(http.StatusOK, j)
|
||||||
|
default:
|
||||||
|
ctx.String(http.StatusOK, fmt.Sprintf("%s (%s / %s)\n", j.DNS.IP, j.DNS.Country, j.DNS.AsnOrganization))
|
||||||
|
}
|
||||||
|
}
|
153
router/dns_test.go
Normal file
153
router/dns_test.go
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
package router
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
validator "github.com/dcarrillo/whatismyip/internal/validator/uuid"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/patrickmn/go-cache"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetDNSDiscoveryHandler(t *testing.T) {
|
||||||
|
store := cache.New(cache.NoExpiration, cache.NoExpiration)
|
||||||
|
handler := GetDNSDiscoveryHandler(store, domain, "")
|
||||||
|
|
||||||
|
t.Run("calls next if host does not have domain suffix", func(t *testing.T) {
|
||||||
|
req, _ := http.NewRequest("GET", "/", nil)
|
||||||
|
req.Header.Set(trustedHeader, testIP.ipv4)
|
||||||
|
req.Host = "example.com"
|
||||||
|
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
c, _ := gin.CreateTestContext(w)
|
||||||
|
c.Request = req
|
||||||
|
handler(c)
|
||||||
|
app.ServeHTTP(w, req)
|
||||||
|
|
||||||
|
assert.Equal(t, http.StatusOK, w.Code)
|
||||||
|
assert.Equal(t, testIP.ipv4+"\n", w.Body.String())
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("return 404 if there is a path", func(t *testing.T) {
|
||||||
|
req, _ := http.NewRequest("GET", "/path", nil)
|
||||||
|
req.Host = domain
|
||||||
|
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
c, _ := gin.CreateTestContext(w)
|
||||||
|
c.Request = req
|
||||||
|
handler(c)
|
||||||
|
app.ServeHTTP(w, req)
|
||||||
|
|
||||||
|
assert.Equal(t, http.StatusNotFound, w.Code)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("redirects if host is domain", func(t *testing.T) {
|
||||||
|
req, _ := http.NewRequest("GET", "/", nil)
|
||||||
|
req.Host = domain
|
||||||
|
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
c, _ := gin.CreateTestContext(w)
|
||||||
|
c.Request = req
|
||||||
|
handler(c)
|
||||||
|
|
||||||
|
assert.Equal(t, http.StatusFound, w.Code)
|
||||||
|
r, err := url.Parse(w.Header().Get("Location"))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.True(t, validator.IsValid(strings.Split(r.Host, ".")[0]))
|
||||||
|
assert.Equal(t, domain, strings.Join(strings.Split(r.Host, ".")[1:], "."))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHandleDNS(t *testing.T) {
|
||||||
|
store := cache.New(cache.NoExpiration, cache.NoExpiration)
|
||||||
|
u := uuid.New().String()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
subDomain string
|
||||||
|
stored any
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "not found if the subdomain is not a valid uuid",
|
||||||
|
subDomain: "not-uuid",
|
||||||
|
stored: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "not found if the ip is not found in the store",
|
||||||
|
subDomain: u,
|
||||||
|
stored: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "not found if the ip is in store but is not valid",
|
||||||
|
subDomain: u,
|
||||||
|
stored: "bogus",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "not found if the store contains no string",
|
||||||
|
subDomain: u,
|
||||||
|
stored: 20,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
req, _ := http.NewRequest("GET", "/", nil)
|
||||||
|
req.Host = tt.subDomain + "." + domain
|
||||||
|
|
||||||
|
if tt.stored != "" {
|
||||||
|
store.Add(tt.subDomain, tt.stored, cache.DefaultExpiration)
|
||||||
|
}
|
||||||
|
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
c, _ := gin.CreateTestContext(w)
|
||||||
|
c.Request = req
|
||||||
|
handleDNS(c, store)
|
||||||
|
assert.Equal(t, http.StatusNotFound, w.Code)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAcceptDNSRequest(t *testing.T) {
|
||||||
|
store := cache.New(cache.NoExpiration, cache.NoExpiration)
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
accept string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "returns json dns data",
|
||||||
|
accept: "application/json",
|
||||||
|
want: jsonDNSIPv4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "return plan text dns data",
|
||||||
|
accept: "text/plain",
|
||||||
|
want: plainDNSIPv4,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
req, _ := http.NewRequest("GET", "/", nil)
|
||||||
|
u := uuid.New().String()
|
||||||
|
req.Host = u + "." + domain
|
||||||
|
req.Header.Add("Accept", tt.accept)
|
||||||
|
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
c, _ := gin.CreateTestContext(w)
|
||||||
|
c.Request = req
|
||||||
|
|
||||||
|
store.Add(u, testIP.ipv4, cache.DefaultExpiration)
|
||||||
|
handleDNS(c, store)
|
||||||
|
|
||||||
|
assert.Equal(t, http.StatusOK, w.Code)
|
||||||
|
assert.Equal(t, tt.want, w.Body.String())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -7,26 +7,28 @@ import (
|
|||||||
|
|
||||||
"github.com/dcarrillo/whatismyip/internal/httputils"
|
"github.com/dcarrillo/whatismyip/internal/httputils"
|
||||||
"github.com/dcarrillo/whatismyip/internal/setting"
|
"github.com/dcarrillo/whatismyip/internal/setting"
|
||||||
"github.com/dcarrillo/whatismyip/service"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// JSONResponse maps data as json
|
type GeoResponse struct {
|
||||||
|
Country string `json:"country,omitempty"`
|
||||||
|
CountryCode string `json:"country_code,omitempty"`
|
||||||
|
City string `json:"city,omitempty"`
|
||||||
|
Latitude float64 `json:"latitude,omitempty"`
|
||||||
|
Longitude float64 `json:"longitude,omitempty"`
|
||||||
|
PostalCode string `json:"postal_code,omitempty"`
|
||||||
|
TimeZone string `json:"time_zone,omitempty"`
|
||||||
|
ASN uint `json:"asn,omitempty"`
|
||||||
|
ASNOrganization string `json:"asn_organization,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type JSONResponse struct {
|
type JSONResponse struct {
|
||||||
IP string `json:"ip"`
|
IP string `json:"ip"`
|
||||||
IPVersion byte `json:"ip_version"`
|
IPVersion byte `json:"ip_version"`
|
||||||
ClientPort string `json:"client_port"`
|
ClientPort string `json:"client_port"`
|
||||||
Country string `json:"country"`
|
Host string `json:"host"`
|
||||||
CountryCode string `json:"country_code"`
|
Headers http.Header `json:"headers"`
|
||||||
City string `json:"city"`
|
GeoResponse
|
||||||
Latitude float64 `json:"latitude"`
|
|
||||||
Longitude float64 `json:"longitude"`
|
|
||||||
PostalCode string `json:"postal_code"`
|
|
||||||
TimeZone string `json:"time_zone"`
|
|
||||||
ASN uint `json:"asn"`
|
|
||||||
ASNOrganization string `json:"asn_organization"`
|
|
||||||
Host string `json:"host"`
|
|
||||||
Headers http.Header `json:"headers"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRoot(ctx *gin.Context) {
|
func getRoot(ctx *gin.Context) {
|
||||||
@ -67,16 +69,14 @@ func getClientPortAsString(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getAllAsString(ctx *gin.Context) {
|
func getAllAsString(ctx *gin.Context) {
|
||||||
output := "IP: " + ctx.ClientIP() + "\n"
|
ip := net.ParseIP(ctx.ClientIP())
|
||||||
|
|
||||||
|
output := "IP: " + ip.String() + "\n"
|
||||||
output += "Client Port: " + getClientPort(ctx) + "\n"
|
output += "Client Port: " + getClientPort(ctx) + "\n"
|
||||||
|
|
||||||
r := service.Geo{IP: net.ParseIP(ctx.ClientIP())}
|
if geoSvc != nil {
|
||||||
if record := r.LookUpCity(); record != nil {
|
output += geoCityRecordToString(geoSvc.LookUpCity(ip)) + "\n"
|
||||||
output += geoCityRecordToString(record) + "\n"
|
output += geoASNRecordToString(geoSvc.LookUpASN(ip)) + "\n"
|
||||||
}
|
|
||||||
|
|
||||||
if record := r.LookUpASN(); record != nil {
|
|
||||||
output += geoASNRecordToString(record) + "\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h := httputils.GetHeadersWithoutTrustedHeaders(ctx)
|
h := httputils.GetHeadersWithoutTrustedHeaders(ctx)
|
||||||
@ -91,28 +91,37 @@ func getJSON(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func jsonOutput(ctx *gin.Context) JSONResponse {
|
func jsonOutput(ctx *gin.Context) JSONResponse {
|
||||||
ip := service.Geo{IP: net.ParseIP(ctx.ClientIP())}
|
ip := net.ParseIP(ctx.ClientIP())
|
||||||
asnRecord := ip.LookUpASN()
|
|
||||||
cityRecord := ip.LookUpCity()
|
|
||||||
var version byte = 4
|
var version byte = 4
|
||||||
if p := net.ParseIP(ctx.ClientIP()).To4(); p == nil {
|
if p := ip.To4(); p == nil {
|
||||||
version = 6
|
version = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
geoResp := GeoResponse{}
|
||||||
|
if geoSvc != nil {
|
||||||
|
cityRecord := geoSvc.LookUpCity(ip)
|
||||||
|
asnRecord := geoSvc.LookUpASN(ip)
|
||||||
|
|
||||||
|
geoResp = GeoResponse{
|
||||||
|
Country: cityRecord.Country.Names["en"],
|
||||||
|
CountryCode: cityRecord.Country.ISOCode,
|
||||||
|
City: cityRecord.City.Names["en"],
|
||||||
|
Latitude: cityRecord.Location.Latitude,
|
||||||
|
Longitude: cityRecord.Location.Longitude,
|
||||||
|
PostalCode: cityRecord.Postal.Code,
|
||||||
|
TimeZone: cityRecord.Location.TimeZone,
|
||||||
|
ASN: asnRecord.AutonomousSystemNumber,
|
||||||
|
ASNOrganization: asnRecord.AutonomousSystemOrganization,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return JSONResponse{
|
return JSONResponse{
|
||||||
IP: ctx.ClientIP(),
|
IP: ip.String(),
|
||||||
IPVersion: version,
|
IPVersion: version,
|
||||||
ClientPort: getClientPort(ctx),
|
ClientPort: getClientPort(ctx),
|
||||||
Country: cityRecord.Country.Names["en"],
|
Host: ctx.Request.Host,
|
||||||
CountryCode: cityRecord.Country.ISOCode,
|
Headers: httputils.GetHeadersWithoutTrustedHeaders(ctx),
|
||||||
City: cityRecord.City.Names["en"],
|
GeoResponse: geoResp,
|
||||||
Latitude: cityRecord.Location.Latitude,
|
|
||||||
Longitude: cityRecord.Location.Longitude,
|
|
||||||
PostalCode: cityRecord.Postal.Code,
|
|
||||||
TimeZone: cityRecord.Location.TimeZone,
|
|
||||||
ASN: asnRecord.AutonomousSystemNumber,
|
|
||||||
ASNOrganization: asnRecord.AutonomousSystemOrganization,
|
|
||||||
Host: ctx.Request.Host,
|
|
||||||
Headers: httputils.GetHeadersWithoutTrustedHeaders(ctx),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/dcarrillo/whatismyip/models"
|
"github.com/dcarrillo/whatismyip/models"
|
||||||
"github.com/dcarrillo/whatismyip/service"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -83,10 +82,13 @@ var asnOutput = map[string]asnDataFormatter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getGeoAsString(ctx *gin.Context) {
|
func getGeoAsString(ctx *gin.Context) {
|
||||||
field := strings.ToLower(ctx.Params.ByName("field"))
|
if geoSvc == nil {
|
||||||
ip := service.Geo{IP: net.ParseIP(ctx.ClientIP())}
|
ctx.String(http.StatusNotFound, http.StatusText(http.StatusNotFound))
|
||||||
record := ip.LookUpCity()
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
field := strings.ToLower(ctx.Params.ByName("field"))
|
||||||
|
record := geoSvc.LookUpCity(net.ParseIP(ctx.ClientIP()))
|
||||||
if field == "" {
|
if field == "" {
|
||||||
ctx.String(http.StatusOK, geoCityRecordToString(record))
|
ctx.String(http.StatusOK, geoCityRecordToString(record))
|
||||||
} else if g, ok := geoOutput[field]; ok {
|
} else if g, ok := geoOutput[field]; ok {
|
||||||
@ -97,10 +99,12 @@ func getGeoAsString(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getASNAsString(ctx *gin.Context) {
|
func getASNAsString(ctx *gin.Context) {
|
||||||
|
if geoSvc == nil {
|
||||||
|
ctx.String(http.StatusNotFound, http.StatusText(http.StatusNotFound))
|
||||||
|
return
|
||||||
|
}
|
||||||
field := strings.ToLower(ctx.Params.ByName("field"))
|
field := strings.ToLower(ctx.Params.ByName("field"))
|
||||||
ip := service.Geo{IP: net.ParseIP(ctx.ClientIP())}
|
record := geoSvc.LookUpASN(net.ParseIP(ctx.ClientIP()))
|
||||||
record := ip.LookUpASN()
|
|
||||||
|
|
||||||
if field == "" {
|
if field == "" {
|
||||||
ctx.String(http.StatusOK, geoASNRecordToString(record))
|
ctx.String(http.StatusOK, geoASNRecordToString(record))
|
||||||
} else if g, ok := asnOutput[field]; ok {
|
} else if g, ok := asnOutput[field]; ok {
|
||||||
|
@ -5,10 +5,12 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/dcarrillo/whatismyip/internal/setting"
|
"github.com/dcarrillo/whatismyip/internal/setting"
|
||||||
|
"github.com/dcarrillo/whatismyip/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetupTemplate reads and parses a template from file
|
var geoSvc *service.Geo
|
||||||
|
|
||||||
func SetupTemplate(r *gin.Engine) {
|
func SetupTemplate(r *gin.Engine) {
|
||||||
if setting.App.TemplatePath == "" {
|
if setting.App.TemplatePath == "" {
|
||||||
t, _ := template.New("home").Parse(home)
|
t, _ := template.New("home").Parse(home)
|
||||||
@ -19,8 +21,8 @@ func SetupTemplate(r *gin.Engine) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup defines the endpoints
|
func Setup(r *gin.Engine, geo *service.Geo) {
|
||||||
func Setup(r *gin.Engine) {
|
geoSvc = geo
|
||||||
r.GET("/", getRoot)
|
r.GET("/", getRoot)
|
||||||
r.GET("/scan/tcp/:port", scanTCPPort)
|
r.GET("/scan/tcp/:port", scanTCPPort)
|
||||||
r.GET("/client-port", getClientPortAsString)
|
r.GET("/client-port", getClientPortAsString)
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/dcarrillo/whatismyip/models"
|
"github.com/dcarrillo/whatismyip/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,19 +35,23 @@ var (
|
|||||||
text: "text/plain; charset=utf-8",
|
text: "text/plain; charset=utf-8",
|
||||||
json: "application/json; charset=utf-8",
|
json: "application/json; charset=utf-8",
|
||||||
}
|
}
|
||||||
jsonIPv4 = `{"client_port":"1001","ip":"81.2.69.192","ip_version":4,"country":"United Kingdom","country_code":"GB","city":"London","latitude":51.5142,"longitude":-0.0931,"postal_code":"","time_zone":"Europe/London","asn":0,"asn_organization":"","host":"test", "headers": {}}`
|
jsonIPv4 = `{"client_port":"1001","ip":"81.2.69.192","ip_version":4,"country":"United Kingdom","country_code":"GB","city":"London","latitude":51.5142,"longitude":-0.0931,"time_zone":"Europe/London","host":"test", "headers": {}}`
|
||||||
jsonIPv6 = `{"asn":3352, "asn_organization":"TELEFONICA DE ESPANA", "city":"", "client_port":"1001", "country":"", "country_code":"", "host":"test", "ip":"2a02:9000::1", "ip_version":6, "latitude":0, "longitude":0, "postal_code":"", "time_zone":"", "headers": {}}`
|
jsonIPv6 = `{"asn":3352,"asn_organization":"TELEFONICA DE ESPANA","client_port":"1001","host":"test","ip":"2a02:9000::1","ip_version":6,"headers": {}}`
|
||||||
|
jsonDNSIPv4 = `{"dns":{"ip":"81.2.69.192","country":"United Kingdom"}}`
|
||||||
|
plainDNSIPv4 = "81.2.69.192 (United Kingdom / )\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
const trustedHeader = "X-Real-IP"
|
const (
|
||||||
const trustedPortHeader = "X-Real-Port"
|
trustedHeader = "X-Real-IP"
|
||||||
|
trustedPortHeader = "X-Real-Port"
|
||||||
|
domain = "dns.example.com"
|
||||||
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
app = gin.Default()
|
app = gin.Default()
|
||||||
app.TrustedPlatform = trustedHeader
|
app.TrustedPlatform = trustedHeader
|
||||||
models.Setup("../test/GeoIP2-City-Test.mmdb", "../test/GeoLite2-ASN-Test.mmdb")
|
svc, _ := service.NewGeo(context.Background(), "../test/GeoIP2-City-Test.mmdb", "../test/GeoLite2-ASN-Test.mmdb")
|
||||||
Setup(app)
|
Setup(app, svc)
|
||||||
defer models.CloseDBs()
|
|
||||||
|
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
@ -62,20 +62,22 @@ func TestDefaultTemplate(t *testing.T) {
|
|||||||
|
|
||||||
tmpl, _ := template.New("home").Parse(home)
|
tmpl, _ := template.New("home").Parse(home)
|
||||||
response := JSONResponse{
|
response := JSONResponse{
|
||||||
IP: "127.0.0.1",
|
IP: "127.0.0.1",
|
||||||
IPVersion: 4,
|
IPVersion: 4,
|
||||||
ClientPort: "1000",
|
ClientPort: "1000",
|
||||||
Country: "A Country",
|
Host: "localhost",
|
||||||
CountryCode: "XX",
|
Headers: req.Header,
|
||||||
City: "A City",
|
GeoResponse: GeoResponse{
|
||||||
Latitude: 100,
|
Country: "A Country",
|
||||||
Longitude: -100,
|
CountryCode: "XX",
|
||||||
PostalCode: "00000",
|
City: "A City",
|
||||||
TimeZone: "My/Timezone",
|
Latitude: 100,
|
||||||
ASN: 0,
|
Longitude: -100,
|
||||||
ASNOrganization: "My ISP",
|
PostalCode: "00000",
|
||||||
Host: "localhost",
|
TimeZone: "My/Timezone",
|
||||||
Headers: req.Header,
|
ASN: 0,
|
||||||
|
ASNOrganization: "My ISP",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
|
48
server/dns.go
Normal file
48
server/dns.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"log"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/miekg/dns"
|
||||||
|
)
|
||||||
|
|
||||||
|
const port = 53
|
||||||
|
|
||||||
|
type DNS struct {
|
||||||
|
server *dns.Server
|
||||||
|
handler *dns.Handler
|
||||||
|
ctx context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDNSServer(ctx context.Context, handler dns.Handler) *DNS {
|
||||||
|
return &DNS{
|
||||||
|
handler: &handler,
|
||||||
|
ctx: ctx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DNS) Start() {
|
||||||
|
d.server = &dns.Server{
|
||||||
|
Addr: ":" + strconv.Itoa(port),
|
||||||
|
Net: "udp",
|
||||||
|
Handler: *d.handler,
|
||||||
|
// UDPSize: 65535,
|
||||||
|
// ReusePort: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Starting DNS server listening on :%d (udp)", port)
|
||||||
|
go func() {
|
||||||
|
if err := d.server.ListenAndServe(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DNS) Stop() {
|
||||||
|
log.Print("Stopping DNS server...")
|
||||||
|
if err := d.server.Shutdown(); err != nil {
|
||||||
|
log.Printf("DNS server forced to shutdown: %s", err)
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@ -9,20 +10,20 @@ import (
|
|||||||
"github.com/quic-go/quic-go/http3"
|
"github.com/quic-go/quic-go/http3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type QuicServer struct {
|
type Quic struct {
|
||||||
server *http3.Server
|
server *http3.Server
|
||||||
tlsServer *TLSServer
|
tlsServer *TLS
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewQuicServer(ctx context.Context, tlsServer *TLSServer) *QuicServer {
|
func NewQuicServer(ctx context.Context, tlsServer *TLS) *Quic {
|
||||||
return &QuicServer{
|
return &Quic{
|
||||||
tlsServer: tlsServer,
|
tlsServer: tlsServer,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *QuicServer) Start() {
|
func (q *Quic) Start() {
|
||||||
q.server = &http3.Server{
|
q.server = &http3.Server{
|
||||||
Addr: setting.App.TLSAddress,
|
Addr: setting.App.TLSAddress,
|
||||||
Handler: q.tlsServer.server.Handler,
|
Handler: q.tlsServer.server.Handler,
|
||||||
@ -30,7 +31,7 @@ func (q *QuicServer) Start() {
|
|||||||
|
|
||||||
parentHandler := q.tlsServer.server.Handler
|
parentHandler := q.tlsServer.server.Handler
|
||||||
q.tlsServer.server.Handler = http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
q.tlsServer.server.Handler = http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
if err := q.server.SetQuicHeaders(rw.Header()); err != nil {
|
if err := q.server.SetQUICHeaders(rw.Header()); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,15 +41,15 @@ func (q *QuicServer) Start() {
|
|||||||
log.Printf("Starting QUIC server listening on %s (udp)", setting.App.TLSAddress)
|
log.Printf("Starting QUIC server listening on %s (udp)", setting.App.TLSAddress)
|
||||||
go func() {
|
go func() {
|
||||||
if err := q.server.ListenAndServeTLS(setting.App.TLSCrtPath, setting.App.TLSKeyPath); err != nil &&
|
if err := q.server.ListenAndServeTLS(setting.App.TLSCrtPath, setting.App.TLSKeyPath); err != nil &&
|
||||||
err.Error() != "quic: Server closed" {
|
!errors.Is(err, http.ErrServerClosed) {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *QuicServer) Stop() {
|
func (q *Quic) Stop() {
|
||||||
log.Printf("Stopping QUIC server...")
|
log.Print("Stopping QUIC server...")
|
||||||
if err := q.server.Close(); err != nil {
|
if err := q.server.Close(); err != nil {
|
||||||
log.Printf("QUIC server forced to shutdown")
|
log.Print("QUIC server forced to shutdown")
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,14 +2,11 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/dcarrillo/whatismyip/internal/setting"
|
"github.com/dcarrillo/whatismyip/service"
|
||||||
"github.com/dcarrillo/whatismyip/models"
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server interface {
|
type Server interface {
|
||||||
@ -17,80 +14,52 @@ type Server interface {
|
|||||||
Stop()
|
Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
type Factory struct {
|
type Manager struct {
|
||||||
tcpServer *TCPServer
|
servers []Server
|
||||||
tlsServer *TLSServer
|
geoSvc *service.Geo
|
||||||
quicServer *QuicServer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Setup(ctx context.Context, handler http.Handler) *Factory {
|
func Setup(servers []Server, geoSvc *service.Geo) *Manager {
|
||||||
var tcpServer *TCPServer
|
return &Manager{
|
||||||
var tlsServer *TLSServer
|
servers: servers,
|
||||||
var quicServer *QuicServer
|
geoSvc: geoSvc,
|
||||||
|
|
||||||
if setting.App.BindAddress != "" {
|
|
||||||
tcpServer = NewTCPServer(ctx, &handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
if setting.App.TLSAddress != "" {
|
|
||||||
tlsServer = NewTLSServer(ctx, &handler)
|
|
||||||
if setting.App.EnableHTTP3 {
|
|
||||||
quicServer = NewQuicServer(ctx, tlsServer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Factory{
|
|
||||||
tcpServer: tcpServer,
|
|
||||||
tlsServer: tlsServer,
|
|
||||||
quicServer: quicServer,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Factory) Run() {
|
func (m *Manager) Run() {
|
||||||
f.start()
|
m.start()
|
||||||
|
|
||||||
signalChan := make(chan os.Signal, 3)
|
signalChan := make(chan os.Signal, len(m.servers))
|
||||||
signal.Notify(signalChan, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(signalChan, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
|
||||||
var s os.Signal
|
var s os.Signal
|
||||||
for {
|
for {
|
||||||
s = <-signalChan
|
s = <-signalChan
|
||||||
|
|
||||||
if s == syscall.SIGHUP {
|
if s == syscall.SIGHUP {
|
||||||
f.stop()
|
m.stop()
|
||||||
models.CloseDBs()
|
if m.geoSvc != nil {
|
||||||
models.Setup(setting.App.GeodbPath.City, setting.App.GeodbPath.ASN)
|
m.geoSvc.Reload()
|
||||||
f.start()
|
}
|
||||||
|
m.start()
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Shutting down...")
|
log.Print("Shutting down...")
|
||||||
f.stop()
|
if m.geoSvc != nil {
|
||||||
models.CloseDBs()
|
m.geoSvc.Shutdown()
|
||||||
|
}
|
||||||
|
m.stop()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Factory) start() {
|
func (m *Manager) start() {
|
||||||
if f.tcpServer != nil {
|
for _, s := range m.servers {
|
||||||
f.tcpServer.Start()
|
s.Start()
|
||||||
}
|
|
||||||
|
|
||||||
if f.tlsServer != nil {
|
|
||||||
f.tlsServer.Start()
|
|
||||||
if f.quicServer != nil {
|
|
||||||
f.quicServer.Start()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Factory) stop() {
|
func (m *Manager) stop() {
|
||||||
if f.tcpServer != nil {
|
for _, s := range m.servers {
|
||||||
f.tcpServer.Stop()
|
s.Stop()
|
||||||
}
|
|
||||||
|
|
||||||
if f.tlsServer != nil {
|
|
||||||
if f.quicServer != nil {
|
|
||||||
f.quicServer.Stop()
|
|
||||||
}
|
|
||||||
f.tlsServer.Stop()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,20 @@ import (
|
|||||||
"github.com/dcarrillo/whatismyip/internal/setting"
|
"github.com/dcarrillo/whatismyip/internal/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TCPServer struct {
|
type TCP struct {
|
||||||
server *http.Server
|
server *http.Server
|
||||||
handler *http.Handler
|
handler *http.Handler
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTCPServer(ctx context.Context, handler *http.Handler) *TCPServer {
|
func NewTCPServer(ctx context.Context, handler *http.Handler) *TCP {
|
||||||
return &TCPServer{
|
return &TCP{
|
||||||
handler: handler,
|
handler: handler,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TCPServer) Start() {
|
func (t *TCP) Start() {
|
||||||
t.server = &http.Server{
|
t.server = &http.Server{
|
||||||
Addr: setting.App.BindAddress,
|
Addr: setting.App.BindAddress,
|
||||||
Handler: *t.handler,
|
Handler: *t.handler,
|
||||||
@ -38,8 +38,8 @@ func (t *TCPServer) Start() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TCPServer) Stop() {
|
func (t *TCP) Stop() {
|
||||||
log.Printf("Stopping TCP server...")
|
log.Print("Stopping TCP server...")
|
||||||
if err := t.server.Shutdown(t.ctx); err != nil {
|
if err := t.server.Shutdown(t.ctx); err != nil {
|
||||||
log.Printf("TCP server forced to shutdown: %s", err)
|
log.Printf("TCP server forced to shutdown: %s", err)
|
||||||
}
|
}
|
@ -9,20 +9,20 @@ import (
|
|||||||
"github.com/dcarrillo/whatismyip/internal/setting"
|
"github.com/dcarrillo/whatismyip/internal/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TLSServer struct {
|
type TLS struct {
|
||||||
server *http.Server
|
server *http.Server
|
||||||
handler *http.Handler
|
handler *http.Handler
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTLSServer(ctx context.Context, handler *http.Handler) *TLSServer {
|
func NewTLSServer(ctx context.Context, handler *http.Handler) *TLS {
|
||||||
return &TLSServer{
|
return &TLS{
|
||||||
handler: handler,
|
handler: handler,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TLSServer) Start() {
|
func (t *TLS) Start() {
|
||||||
t.server = &http.Server{
|
t.server = &http.Server{
|
||||||
Addr: setting.App.TLSAddress,
|
Addr: setting.App.TLSAddress,
|
||||||
Handler: *t.handler,
|
Handler: *t.handler,
|
||||||
@ -39,8 +39,8 @@ func (t *TLSServer) Start() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TLSServer) Stop() {
|
func (t *TLS) Stop() {
|
||||||
log.Printf("Stopping TLS server...")
|
log.Print("Stopping TLS server...")
|
||||||
if err := t.server.Shutdown(t.ctx); err != nil {
|
if err := t.server.Shutdown(t.ctx); err != nil {
|
||||||
log.Printf("TLS server forced to shutdown: %s", err)
|
log.Printf("TLS server forced to shutdown: %s", err)
|
||||||
}
|
}
|
@ -1,37 +1,73 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/dcarrillo/whatismyip/models"
|
"github.com/dcarrillo/whatismyip/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Geo defines a base type for lookups
|
|
||||||
type Geo struct {
|
type Geo struct {
|
||||||
IP net.IP
|
ctx context.Context
|
||||||
|
cancel context.CancelFunc
|
||||||
|
db *models.GeoDB
|
||||||
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookUpCity queries the database for city data related to the given IP
|
func NewGeo(ctx context.Context, cityPath string, asnPath string) (*Geo, error) {
|
||||||
func (g *Geo) LookUpCity() *models.GeoRecord {
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
record := &models.GeoRecord{}
|
|
||||||
err := record.LookUp(g.IP)
|
db, err := models.Setup(cityPath, asnPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
cancel()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
geo := &Geo{
|
||||||
|
ctx: ctx,
|
||||||
|
cancel: cancel,
|
||||||
|
db: db,
|
||||||
|
}
|
||||||
|
|
||||||
|
return geo, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Geo) LookUpCity(ip net.IP) *models.GeoRecord {
|
||||||
|
record, err := g.db.LookupCity(ip)
|
||||||
|
if err != nil {
|
||||||
|
log.Print(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return record
|
return record
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookUpASN queries the database for ASN data related to the given IP
|
func (g *Geo) LookUpASN(ip net.IP) *models.ASNRecord {
|
||||||
func (g *Geo) LookUpASN() *models.ASNRecord {
|
record, err := g.db.LookupASN(ip)
|
||||||
record := &models.ASNRecord{}
|
|
||||||
err := record.LookUp(g.IP)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Print(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return record
|
return record
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Geo) Shutdown() {
|
||||||
|
g.cancel()
|
||||||
|
g.db.CloseDBs()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Geo) Reload() {
|
||||||
|
if err := g.ctx.Err(); err != nil {
|
||||||
|
log.Printf("Skipping reload, service is shutting down: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
g.mu.Lock()
|
||||||
|
defer g.mu.Unlock()
|
||||||
|
|
||||||
|
g.db.Reload()
|
||||||
|
log.Print("Geo database reloaded")
|
||||||
|
}
|
||||||
|
@ -1,36 +1,33 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/dcarrillo/whatismyip/models"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var geoSvc *Geo
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
models.Setup("../test/GeoIP2-City-Test.mmdb", "../test/GeoLite2-ASN-Test.mmdb")
|
geoSvc, _ = NewGeo(context.Background(), "../test/GeoIP2-City-Test.mmdb", "../test/GeoLite2-ASN-Test.mmdb")
|
||||||
defer models.CloseDBs()
|
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCityLookup(t *testing.T) {
|
func TestCityLookup(t *testing.T) {
|
||||||
ip := Geo{IP: net.ParseIP("error")}
|
c := geoSvc.LookUpCity(net.ParseIP("error"))
|
||||||
c := ip.LookUpCity()
|
|
||||||
assert.Nil(t, c)
|
assert.Nil(t, c)
|
||||||
|
|
||||||
ip = Geo{IP: net.ParseIP("1.1.1.1")}
|
c = geoSvc.LookUpCity(net.ParseIP("1.1.1.1"))
|
||||||
c = ip.LookUpCity()
|
|
||||||
assert.NotNil(t, c)
|
assert.NotNil(t, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestASNLookup(t *testing.T) {
|
func TestASNLookup(t *testing.T) {
|
||||||
ip := Geo{IP: net.ParseIP("error")}
|
a := geoSvc.LookUpASN(net.ParseIP("error"))
|
||||||
a := ip.LookUpASN()
|
|
||||||
assert.Nil(t, a)
|
assert.Nil(t, a)
|
||||||
|
|
||||||
ip = Geo{IP: net.ParseIP("1.1.1.1")}
|
a = geoSvc.LookUpASN(net.ParseIP("1.1.1.1"))
|
||||||
a = ip.LookUpASN()
|
|
||||||
assert.NotNil(t, a)
|
assert.NotNil(t, a)
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,20 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const scannerTimeOut = 3 * time.Second
|
||||||
|
|
||||||
type PortScanner struct {
|
type PortScanner struct {
|
||||||
Address net.Addr
|
Address net.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PortScanner) IsPortOpen() (bool, error) {
|
func (p *PortScanner) IsPortOpen() (bool, error) {
|
||||||
conn, err := net.DialTimeout(p.Address.Network(), p.Address.String(), 3*time.Second)
|
conn, err := net.DialTimeout(p.Address.Network(), p.Address.String(), scannerTimeOut)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if conn != nil {
|
if conn != nil {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
15
test/Dockerfile
Normal file
15
test/Dockerfile
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
FROM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
|
ARG ARG_VERSION
|
||||||
|
ENV VERSION=$ARG_VERSION
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
FROM builder AS build-test-app
|
||||||
|
RUN CGO_ENABLED=0 \
|
||||||
|
go build -ldflags="-s -w" -o whatismyip ./cmd
|
||||||
|
|
||||||
|
FROM scratch AS test
|
||||||
|
COPY --from=build-test-app /app/whatismyip /usr/bin/
|
||||||
|
ENTRYPOINT ["whatismyip"]
|
10
test/resolver.yml
Normal file
10
test/resolver.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
domain: dns.example.com
|
||||||
|
redirect_port: ":8000"
|
||||||
|
resource_records:
|
||||||
|
- "1800 IN SOA xns.example.com. hostmaster.example.com. 1 10000 2400 604800 1800"
|
||||||
|
- "3600 IN NS xns.example.com."
|
||||||
|
ipv4:
|
||||||
|
- "127.0.0.2"
|
||||||
|
ipv6:
|
||||||
|
- "aaa:aaa:aaa:aaaa::1"
|
Reference in New Issue
Block a user