Skip to content

Return in case of an error in FetchIPFromSTUNCall, fix #1

Pea Nut requested to merge fix-1 into main

Issue: #1 (closed)

This fixes the issue. I could not use return "", err, because we are inside of a nameless function without return values. That's why there are channels used.

To verify: go to bitmask-core, checkout main, then run go test -count=1 -v ./... -run TestGeolocatation

To use the upstream changes, I use:

go 1.22.2

toolchain go1.23.0

use (
        .
        ../tunnel-telemetry/
)

If everything works:

pea@peabox:bootstrap go test -count=1 -v ./... -run TestGeolocatation
=== RUN   TestGeolocatation
1:21PM INF TEST_MENSHEN_HOST env (hostname of menshen) is not set. Using localhost as default
1:21PM INF TEST_MENSHEN_PORT env (port of menshen) env is not set. Using 8443 as default
1:21PM INF TEST_MENSHEN_TLS env (connect via tls to menshen) is not set. Using default false. Set TEST_MENSHEN_TLS=1 to connect vial TLS
1:21PM DBG Disabling DNS over HTTP (not using SSL)
1:21PM TRC Getting country code
1:21PM TRC Trying to get current ip address using STUN servers
1:21PM TRC Trying STUN server server=stun.nextcloud.com:443
1:21PM INF Successfully got country code countryCode=FR
1:21PM TRC Getting country code
1:21PM TRC Trying to get current ip address using STUN servers
1:21PM TRC Trying STUN server server=198.27.70.99:3478
1:21PM INF Successfully got country code countryCode=FR
--- PASS: TestGeolocatation (0.67s)
PASS
ok      0xacab.org/leap/bitmask-core/pkg/bootstrap      0.683s

In case of an error

pea@peabox:bootstrap go test -count=1 -v ./... -run TestGeolocatation
=== RUN   TestGeolocatation
1:21PM INF TEST_MENSHEN_HOST env (hostname of menshen) is not set. Using localhost as default
1:21PM INF TEST_MENSHEN_PORT env (port of menshen) env is not set. Using 8443 as default
1:21PM INF TEST_MENSHEN_TLS env (connect via tls to menshen) is not set. Using default false. Set TEST_MENSHEN_TLS=1 to connect vial TLS
1:21PM DBG Disabling DNS over HTTP (not using SSL)
1:21PM TRC Getting country code
1:21PM TRC Trying to get current ip address using STUN servers
1:21PM TRC Trying STUN server server=stun.nextcloud.com:443
1:21PM INF Successfully got country code countryCode=FR
1:21PM TRC Getting country code
1:21PM TRC Trying to get current ip address using STUN servers
1:21PM TRC Trying STUN server server=stun1.l.google.com:3478
1:21PM WRN Could not get ip using STUN server error="transaction is timed out" server=stun1.l.google.com:3478
1:21PM TRC Trying STUN server server=198.27.70.99:3478
1:21PM INF Successfully got country code countryCode=FR
--- PASS: TestGeolocatation (11.65s)
PASS
ok      0xacab.org/leap/bitmask-core/pkg/bootstrap      11.668s

Merge request reports

Loading