From 064760edde908289765846fb92697e54f503c120 Mon Sep 17 00:00:00 2001 From: Never M Date: Wed, 7 Jul 2021 14:27:27 +0300 Subject: [PATCH] Remove env_test --- internal/vpn/env.go | 4 +++ internal/vpn/env_test.go | 59 ---------------------------------------- 2 files changed, 4 insertions(+), 59 deletions(-) delete mode 100644 internal/vpn/env_test.go diff --git a/internal/vpn/env.go b/internal/vpn/env.go index ec97991aa..4e089dbf3 100644 --- a/internal/vpn/env.go +++ b/internal/vpn/env.go @@ -114,6 +114,8 @@ func AppEnvArgs(config DirectRoutesEnvConfig) map[string]string { // - domain without port; // - IP with port; // - IP without port. +// In case domain is provided instead of an IP address, a DNS lookup is also +// performed to resolve the actual IP address func IPFromEnv(key string) (net.IP, bool, error) { return ParseIP(os.Getenv(key)) } @@ -125,6 +127,8 @@ func IPFromEnv(key string) (net.IP, bool, error) { // - domain without port; // - IP with port; // - IP without port. +// In case domain is provided instead of an IP address, a DNS lookup is also +// performed to resolve the actual IP address func ParseIP(addr string) (net.IP, bool, error) { if addr == "" { return nil, false, nil diff --git a/internal/vpn/env_test.go b/internal/vpn/env_test.go deleted file mode 100644 index 94c927282..000000000 --- a/internal/vpn/env_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package vpn - -import ( - "net" - "os" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestIPFromEnv(t *testing.T) { - const envKey = "KEY" - - want := net.IPv4(172, 104, 191, 38) - - tests := []struct { - name string - envVal string - }{ - { - name: "URL with port", - envVal: "tcp://dmsg.server02a4.skywire.skycoin.com:30080", - }, - { - name: "URL without port", - envVal: "tcp://dmsg.server02a4.skywire.skycoin.com", - }, - { - name: "Domain with port", - envVal: "dmsg.server02a4.skywire.skycoin.com:30080", - }, - { - name: "Domain without port", - envVal: "dmsg.server02a4.skywire.skycoin.com", - }, - { - name: "IP with port", - envVal: "172.104.191.38:30080", - }, - { - name: "IP without port", - envVal: "172.104.191.38", - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - os.Clearenv() - - err := os.Setenv(envKey, tc.envVal) - require.NoError(t, err) - - ip, ok, err := IPFromEnv(envKey) - require.NoError(t, err) - require.True(t, ok) - require.True(t, ip.Equal(want)) - }) - } -}