From 2b92213dfe988f1c100358c05ee79d69fa7a4651 Mon Sep 17 00:00:00 2001 From: Aviad Hahami Date: Mon, 29 Jan 2024 12:39:02 +0200 Subject: [PATCH 01/10] new: devcontainer support --- .devcontainer/devcontainer.json | 32 ++++++++++++++++++++++++++++++++ .devcontainer/postcreate.sh | 25 +++++++++++++++++++++++++ .vscode/launch.json | 18 ++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100755 .devcontainer/postcreate.sh create mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..688fe71 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/go +{ + "name": "Go", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/go:1-1.20-bookworm", + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": ".devcontainer/postcreate.sh", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + "remoteUser": "root", + "customizations": { + "vscode": { + "extensions": [ + "foxundermoon.shell-format", + "GitHub.copilot", + "eamodio.gitlens", + "ms-vscode.makefile-tools" + ] + } + } +} diff --git a/.devcontainer/postcreate.sh b/.devcontainer/postcreate.sh new file mode 100755 index 0000000..3934772 --- /dev/null +++ b/.devcontainer/postcreate.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +echo "[ + ] Running post-create script..." +echo "[ + ] Installing Node.js 20..." + +# Check if we don't have nvm, if no - install it +echo "[ + ] Installing nvm..." +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash +# Activate nvm +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + +# Refresh bash +source ~/.bashrc + +# Install node 20 +echo "[ + ] Installing Node.js 20..." +nvm install 20 && nvm use 20; + +echo "[ + ] Installing UI dependencies and building..." +# Change to the "ui" directory +cd ui && npm install && cd ../ + +echo "[ + ] Installing Go dependencies and building..." +make build \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..5f83604 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + // Run the main.go program + { + "name": "Launch Package", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "${workspaceFolder}/main.go", + "env": {}, + "args": [] + }, + ] +} \ No newline at end of file From 121dee74b253f9f5779fce02ea6453613863523d Mon Sep 17 00:00:00 2001 From: Aviad Hahami Date: Mon, 29 Jan 2024 14:22:28 +0200 Subject: [PATCH 02/10] improve: docker build can now build and land in alpine Update the docker to have multi-stage build and compile a static binary so we can land in Alpine later --- .devcontainer/devcontainer.json | 3 ++- Dockerfile | 27 +++++++++++++++++++++++---- Makefile | 7 +++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 688fe71..0b8ab67 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -25,7 +25,8 @@ "foxundermoon.shell-format", "GitHub.copilot", "eamodio.gitlens", - "ms-vscode.makefile-tools" + "ms-vscode.makefile-tools", + "ms-azuretools.vscode-docker" ] } } diff --git a/Dockerfile b/Dockerfile index 31104fb..e6362c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,21 @@ -FROM alpine +FROM golang:1.20.13-bookworm AS GO_BUILD -ENV PWD="/app" +WORKDIR /app + +COPY . . + +RUN make build-go-for-docker + +FROM node:20.11-bookworm AS NODE_BUILD + +WORKDIR /ui + +COPY ./ui . + +RUN pwd && ls -lah && npm install + +# Final image +FROM alpine:latest # SLRP configuration environment variables ENV SLRP_APP_STATE="$PWD/.slrp/data" @@ -17,11 +32,15 @@ ENV SLRP_CHECKER_TIMEOUT="5s" ENV SLRP_CHECKER_STRATEGY="simple" ENV SLRP_HISTORY_LIMIT="1000" +ENV PWD="/opt" WORKDIR $PWD -COPY slrp $PWD + +COPY --from=GO_BUILD /app/main $PWD/slrp +COPY --from=NODE_BUILD /ui $PWD/ui/ RUN mkdir ./.slrp EXPOSE 8089 8090 -CMD ["./slrp"] +# Run the binary +CMD ["/opt/slrp"] diff --git a/Makefile b/Makefile index 870b62d..a21f345 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,13 @@ build: build-ui go mod vendor go build -ldflags "-s -w" main.go +build-go-for-docker: + go mod vendor + CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-s -w" -o main main.go + +docker: + docker build -t slrp:latest . + quick: go build From d8e7f27acd028d5b82af71299c7940a788a99934 Mon Sep 17 00:00:00 2001 From: Aviad Hahami Date: Mon, 29 Jan 2024 18:30:40 +0200 Subject: [PATCH 03/10] added patch script --- Dockerfile | 13 ++++++++++--- docker-entrypoint.sh | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index e6362c6..02a8bc7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /ui COPY ./ui . -RUN pwd && ls -lah && npm install +RUN npm install # Final image FROM alpine:latest @@ -42,5 +42,12 @@ RUN mkdir ./.slrp EXPOSE 8089 8090 -# Run the binary -CMD ["/opt/slrp"] +# The new script requires iproute2 via apk +RUN apk add --no-cache iproute2 +# Copy the script +COPY ./docker-entrypoint.sh $PWD/docker-entrypoint.sh +# Make the script executable +RUN chmod +x $PWD/docker-entrypoint.sh + +# Run the script +ENTRYPOINT ["/opt/docker-entrypoint.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..256f323 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +_term() { + echo "Caught SIGTERM signal!" + kill -TERM "$child" 2>/dev/null +} + +MITM_PORT=${MITM_PORT:-"8090"} +SERVER_PORT=${SERVER_PORT:-"8089"} + +default_iface=$(awk '$2 == 00000000 { print $1 }' /proc/net/route) +listen_ip=$(ip addr show dev "$default_iface" | awk '$1 == "inet" { sub("/.*", "", $2); print $2 }') +echo "Chose IP: ${listen_ip}" +SLRP_MITM_ADDR="${listen_ip}:${MITM_PORT}" SLRP_SERVER_ADDR="${listen_ip}:${SERVER_PORT}" /opt/slrp + +child=$! +wait "$child" \ No newline at end of file From 540968cfa92dc34b876ef4084657492293378a64 Mon Sep 17 00:00:00 2001 From: Aviad Hahami Date: Mon, 29 Jan 2024 19:05:40 +0200 Subject: [PATCH 04/10] fix: replace [::] with 0.0.0.0 --- Dockerfile | 11 ++--------- docker-entrypoint.sh | 17 ----------------- pmux/proxy.go | 10 ++++++++++ 3 files changed, 12 insertions(+), 26 deletions(-) delete mode 100644 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 02a8bc7..5397c84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,12 +42,5 @@ RUN mkdir ./.slrp EXPOSE 8089 8090 -# The new script requires iproute2 via apk -RUN apk add --no-cache iproute2 -# Copy the script -COPY ./docker-entrypoint.sh $PWD/docker-entrypoint.sh -# Make the script executable -RUN chmod +x $PWD/docker-entrypoint.sh - -# Run the script -ENTRYPOINT ["/opt/docker-entrypoint.sh"] +# Run the binary +CMD ["/opt/slrp"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100644 index 256f323..0000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -_term() { - echo "Caught SIGTERM signal!" - kill -TERM "$child" 2>/dev/null -} - -MITM_PORT=${MITM_PORT:-"8090"} -SERVER_PORT=${SERVER_PORT:-"8089"} - -default_iface=$(awk '$2 == 00000000 { print $1 }' /proc/net/route) -listen_ip=$(ip addr show dev "$default_iface" | awk '$1 == "inet" { sub("/.*", "", $2); print $2 }') -echo "Chose IP: ${listen_ip}" -SLRP_MITM_ADDR="${listen_ip}:${MITM_PORT}" SLRP_SERVER_ADDR="${listen_ip}:${SERVER_PORT}" /opt/slrp - -child=$! -wait "$child" \ No newline at end of file diff --git a/pmux/proxy.go b/pmux/proxy.go index 48d9a55..fe68e99 100644 --- a/pmux/proxy.go +++ b/pmux/proxy.go @@ -247,8 +247,18 @@ func NewProxyFromURL(url string) Proxy { } func NewProxy(addr string, t string) Proxy { + // Check if the address is valid or contains "[::]:"; This happens when running inside a docker container + // It means that the address is listening on all interfaces but via IPv6, which is not supported by the + // proxy package(or so). Hence we replace it with 0.0.0.0 + if strings.Contains(addr, "[::]") { + // Set it to 0.0.0.0 but maintain the port + fmt.Println("Encountered [::]: in address, replacing with 0.0.0.0") + addr = strings.Replace(addr, "[::]", "0.0.0.0", 1) + } + addrPort, err := netip.ParseAddrPort(addr) if err != nil { + fmt.Println("Error parsing address:", err) return 0 } p, ok := protoMap[t] From 55f404aaa1c2a45daa7350d19b2686db68335a8a Mon Sep 17 00:00:00 2001 From: Aviad Hahami Date: Mon, 29 Jan 2024 19:18:41 +0200 Subject: [PATCH 05/10] updated readme to reflect docker changes --- README.md | 11 ++++++++++- pmux/proxy.go | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 48117f3..2bba805 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,17 @@ SLRP - rotating open proxy multiplexer * Packaged as a single executable binary, that also includes Web UI # Usage +For all methods, wait couple of minutes for the pool to pick up. Check the dashboard at [http://localhost:8089/](http://localhost:8089/) for progress. -Download service, start it up, wait couple of minutes for the pool to pick up. Now run `curl --proxy-insecure -D - -x http://127.0.0.1:8090 -k http://httpbin.org/get` couple of times and see different origins and user agent headers. +## Via binary +Download the binary from the releases, which can be found [here](https://github.com/nfx/slrp/releases) + +## Via Docker +> Assuming you have docker and make present +Run `make docker`. Once done, invoke with `docker run -p 8089:8089 -p 8090:8090 -v $HOME/.slrp/data:/data nfx/slrp:latest` + +Once running, you can access the UI at [http://localhost:8089/](http://localhost:8089/) and the proxy at [http://localhost:8090/](http://localhost:8090/) +Test using a simple curl command `curl --proxy-insecure -D - -x http:// http://127.0.0.1:8090 -k http://httpbin.org/get` couple of times and see different origins and user agent headers. # Concepts diff --git a/pmux/proxy.go b/pmux/proxy.go index fe68e99..9fead42 100644 --- a/pmux/proxy.go +++ b/pmux/proxy.go @@ -247,7 +247,7 @@ func NewProxyFromURL(url string) Proxy { } func NewProxy(addr string, t string) Proxy { - // Check if the address is valid or contains "[::]:"; This happens when running inside a docker container + // Check if the address is valid or contains "[::]"; This happens when running inside a docker container // It means that the address is listening on all interfaces but via IPv6, which is not supported by the // proxy package(or so). Hence we replace it with 0.0.0.0 if strings.Contains(addr, "[::]") { From 0a72c7761d84d8cfba6ca7a7674401e24892f937 Mon Sep 17 00:00:00 2001 From: Cyril Deschamps Date: Sat, 3 Feb 2024 19:47:05 +0100 Subject: [PATCH 06/10] fix: fixed dockerfile to build ui --- Dockerfile | 62 ++++++++++++++++++++++-------------------------------- 1 file changed, 25 insertions(+), 37 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5397c84..cd333c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,46 +1,34 @@ -FROM golang:1.20.13-bookworm AS GO_BUILD - +# Install node and deps to build the frontend +FROM node:20.11-bookworm AS NODE_INSTALL WORKDIR /app - COPY . . +RUN npm --prefix ui install && \ + npm --prefix ui run build +# Install go and deps to build the backend +FROM golang:1.20.13-bookworm AS BUILD +WORKDIR /app +COPY --from=NODE_INSTALL /app . RUN make build-go-for-docker -FROM node:20.11-bookworm AS NODE_BUILD - -WORKDIR /ui - -COPY ./ui . - -RUN npm install - # Final image FROM alpine:latest - # SLRP configuration environment variables -ENV SLRP_APP_STATE="$PWD/.slrp/data" -ENV SLRP_APP_SYNC="1m" -ENV SLRP_LOG_LEVEL="info" -ENV SLRP_LOG_FORMAT="pretty" -ENV SLRP_SERVER_ADDR="0.0.0.0:8089" -ENV SLRP_SERVER_READ_TIMEOUT="15s" -ENV SLRP_MITM_ADDR="0.0.0.0:8090" -ENV SLRP_MITM_READ_TIMEOUT="15s" -ENV SLRP_MITM_IDLE_TIMEOUT="15s" -ENV SLRP_MITM_WRITE_TIMEOUT="15s" -ENV SLRP_CHECKER_TIMEOUT="5s" -ENV SLRP_CHECKER_STRATEGY="simple" -ENV SLRP_HISTORY_LIMIT="1000" - -ENV PWD="/opt" -WORKDIR $PWD - -COPY --from=GO_BUILD /app/main $PWD/slrp -COPY --from=NODE_BUILD /ui $PWD/ui/ - -RUN mkdir ./.slrp - +ENV SLRP_APP_STATE="/opt/.slrp/data" \ + SLRP_APP_SYNC="1m" \ + SLRP_LOG_LEVEL="info" \ + SLRP_LOG_FORMAT="pretty" \ + SLRP_SERVER_ADDR="0.0.0.0:8089" \ + SLRP_SERVER_READ_TIMEOUT="15s" \ + SLRP_MITM_ADDR="0.0.0.0:8090" \ + SLRP_MITM_READ_TIMEOUT="15s" \ + SLRP_MITM_IDLE_TIMEOUT="15s" \ + SLRP_MITM_WRITE_TIMEOUT="15s" \ + SLRP_CHECKER_TIMEOUT="5s" \ + SLRP_CHECKER_STRATEGY="simple" \ + SLRP_HISTORY_LIMIT="1000" +WORKDIR /opt +COPY --from=BUILD /app/main /opt/slrp +RUN mkdir -p ./.slrp/data EXPOSE 8089 8090 - -# Run the binary -CMD ["/opt/slrp"] +CMD ["/opt/slrp"] \ No newline at end of file From 6cc45bfbcc96381307172e49f59737b76bb67f49 Mon Sep 17 00:00:00 2001 From: Aviad Hahami Date: Mon, 19 Feb 2024 12:03:54 +0200 Subject: [PATCH 07/10] pr comments changes --- .devcontainer/devcontainer.json | 20 ++------------------ .devcontainer/postcreate.sh | 22 ++++++++++++++-------- Makefile | 1 + 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0b8ab67..2ba857d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,23 +1,7 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/go { - "name": "Go", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "name": "slrp dev", "image": "mcr.microsoft.com/devcontainers/go:1-1.20-bookworm", - - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": ".devcontainer/postcreate.sh", - - // Configure tool-specific properties. - // "customizations": {}, - - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. "remoteUser": "root", "customizations": { "vscode": { @@ -30,4 +14,4 @@ ] } } -} +} \ No newline at end of file diff --git a/.devcontainer/postcreate.sh b/.devcontainer/postcreate.sh index 3934772..2ca6977 100755 --- a/.devcontainer/postcreate.sh +++ b/.devcontainer/postcreate.sh @@ -1,11 +1,17 @@ #!/bin/bash -echo "[ + ] Running post-create script..." -echo "[ + ] Installing Node.js 20..." +NVM_VERSION="0.38.0" +NODE_VERSION="20" + +echo "[ + ] Running post-create script. Installing the following:" +echo "[ + ] NVM version: $NVM_VERSION" +echo "[ + ] NodeJS version: $NODE_VERSION" +echo "[ + ] ==============================" # Check if we don't have nvm, if no - install it -echo "[ + ] Installing nvm..." -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash +echo "[ + ] Installing nvm at v$NVM_VERSION" + +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash # Activate nvm export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" @@ -13,13 +19,13 @@ export NVM_DIR="$HOME/.nvm" # Refresh bash source ~/.bashrc -# Install node 20 -echo "[ + ] Installing Node.js 20..." -nvm install 20 && nvm use 20; +# Install node at a set versions +echo "[ + ] Installing NodeJS at v$NODE_VERSION" +nvm install $NODE_VERSION && nvm use $NODE_VERSION echo "[ + ] Installing UI dependencies and building..." # Change to the "ui" directory cd ui && npm install && cd ../ echo "[ + ] Installing Go dependencies and building..." -make build \ No newline at end of file +make build diff --git a/Makefile b/Makefile index a21f345..6bd3dc8 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ build: build-ui go mod vendor go build -ldflags "-s -w" main.go +# When running inside Alpine images there are no classic OS packages/binaries enabled, hence - we compile statically (CGO) build-go-for-docker: go mod vendor CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-s -w" -o main main.go From d5f37a3525b8618044fa1415541705cb5460704f Mon Sep 17 00:00:00 2001 From: Aviad Hahami Date: Sun, 25 Feb 2024 11:45:03 +0200 Subject: [PATCH 08/10] chore: allow usage for when behind self-signed certs --- .devcontainer/postcreate.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.devcontainer/postcreate.sh b/.devcontainer/postcreate.sh index 2ca6977..a56d458 100755 --- a/.devcontainer/postcreate.sh +++ b/.devcontainer/postcreate.sh @@ -1,8 +1,12 @@ #!/bin/bash - NVM_VERSION="0.38.0" NODE_VERSION="20" +# # If you're developing in a container behind a VPNed/MDM-managed machine you might get "self signed certs in chain" error. +# # This snippet below bypasses that (ssl is required later for nvm installation) +# apt update && apt install -y git +# git config --global http.sslVerify false + echo "[ + ] Running post-create script. Installing the following:" echo "[ + ] NVM version: $NVM_VERSION" echo "[ + ] NodeJS version: $NODE_VERSION" @@ -11,7 +15,7 @@ echo "[ + ] ==============================" # Check if we don't have nvm, if no - install it echo "[ + ] Installing nvm at v$NVM_VERSION" -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash +curl -k -o- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash # Activate nvm export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" From 8be8cfa7d94fb47668d8c5c61bbfb9faedabaa2f Mon Sep 17 00:00:00 2001 From: Aviad Hahami Date: Sun, 25 Feb 2024 11:45:19 +0200 Subject: [PATCH 09/10] fix: small test type mismatch fix --- sources/try_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/try_test.go b/sources/try_test.go index d2b5473..d66662e 100644 --- a/sources/try_test.go +++ b/sources/try_test.go @@ -113,7 +113,7 @@ func Test_mergeSrc_Len(t *testing.T) { case pmux.HttpProxy("127.0.0.1:2048"): canAssertB <- true } - t.Logf("received: %s", v) + t.Logf("received: %v", v) } }() From 807db30476f07cd72071cc7b8e054983262400f4 Mon Sep 17 00:00:00 2001 From: Aviad Hahami Date: Thu, 29 Feb 2024 11:56:53 +0200 Subject: [PATCH 10/10] chore: updates to readme and logger switch Using log instead of stdout --- README.md | 2 +- pmux/proxy.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2bba805..360b03c 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Download the binary from the releases, which can be found [here](https://github. Run `make docker`. Once done, invoke with `docker run -p 8089:8089 -p 8090:8090 -v $HOME/.slrp/data:/data nfx/slrp:latest` Once running, you can access the UI at [http://localhost:8089/](http://localhost:8089/) and the proxy at [http://localhost:8090/](http://localhost:8090/) -Test using a simple curl command `curl --proxy-insecure -D - -x http:// http://127.0.0.1:8090 -k http://httpbin.org/get` couple of times and see different origins and user agent headers. +Test using a simple curl command `curl --proxy-insecure -D - -x "https://127.0.0.1:8090" "https://httpbin.org/get"` couple of times and see different origins and user agent headers. # Concepts diff --git a/pmux/proxy.go b/pmux/proxy.go index 9fead42..bd22e33 100644 --- a/pmux/proxy.go +++ b/pmux/proxy.go @@ -252,13 +252,13 @@ func NewProxy(addr string, t string) Proxy { // proxy package(or so). Hence we replace it with 0.0.0.0 if strings.Contains(addr, "[::]") { // Set it to 0.0.0.0 but maintain the port - fmt.Println("Encountered [::]: in address, replacing with 0.0.0.0") + log.Info().Str("ip address", addr).Msg("encountered [::]: in address, replacing with 0.0.0.0") addr = strings.Replace(addr, "[::]", "0.0.0.0", 1) } addrPort, err := netip.ParseAddrPort(addr) if err != nil { - fmt.Println("Error parsing address:", err) + log.Err(fmt.Errorf("error parsing address")).Str("ip address", addr).Msg("") return 0 } p, ok := protoMap[t]