diff --git a/.github/workflows/agent.yml b/.github/workflows/agent.yml index 5130b34..f8927a4 100644 --- a/.github/workflows/agent.yml +++ b/.github/workflows/agent.yml @@ -9,7 +9,7 @@ jobs: deploy: runs-on: ubuntu-latest container: - image: goreleaser/goreleaser-cross:v1.20 + image: goreleaser/goreleaser-cross:v1.21 steps: - run: | git config --global --add safe.directory /__w/agent/agent @@ -18,7 +18,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-go@v4 with: - go-version: "^1.20.0" + go-version: "^1.21.3" - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml index f4e03bc..7bb49fc 100644 --- a/.github/workflows/test-on-pr.yml +++ b/.github/workflows/test-on-pr.yml @@ -10,10 +10,10 @@ jobs: env: GO111MODULE: on steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: "^1.20.0" + go-version: "^1.21.3" - name: Unit test run: | go test -v ./... diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f41adb7..16272ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,10 +16,10 @@ jobs: tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: "^1.20.0" + go-version: "^1.21.3" - name: Unit test run: | go test -v ./... diff --git a/go.mod b/go.mod index 4f245dc..7e0d8aa 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/nezhahq/agent -go 1.20 +go 1.21 + +toolchain go1.21.3 require ( github.com/AlecAivazis/survey/v2 v2.3.7 diff --git a/go.sum b/go.sum index d2274aa..6a608dc 100644 --- a/go.sum +++ b/go.sum @@ -79,11 +79,14 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= 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-ping/ping v1.1.0 h1:3MCGhVX4fyEUuhsfwPrsEdQw6xspHkv5zHsiSoDFZYw= @@ -185,9 +188,11 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de h1:V53FWzU6KAZVi1tPp5UIsMoUWJ2/PNwYIDXnu7QuBCE= github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= @@ -214,7 +219,8 @@ github.com/nezhahq/go-github-selfupdate v0.0.0-20221018153747-e1fb0e0b65b0 h1:KN github.com/nezhahq/go-github-selfupdate v0.0.0-20221018153747-e1fb0e0b65b0/go.mod h1:V/9eVYzbfq7sNIMJSkgRiRYGB8FMT1wkosIxbYDwC5E= github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= -github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= +github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -234,6 +240,7 @@ github.com/quic-go/quic-go v0.39.1 h1:d/m3oaN/SD2c+f7/yEjZxe2zEVotXprnrCCJ2y/ZZF github.com/quic-go/quic-go v0.39.1/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/shirou/gopsutil/v3 v3.23.8 h1:xnATPiybo6GgdRoC4YoGnxXZFRc3dqQTGi73oLvvBrE= github.com/shirou/gopsutil/v3 v3.23.8/go.mod h1:7hmCaBn+2ZwaZOr6jmPBZDfawwMGuo1id3C6aM8EDqQ= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= diff --git a/main.go b/main.go index 9e6cfdf..2df4088 100644 --- a/main.go +++ b/main.go @@ -91,10 +91,7 @@ func init() { d := net.Dialer{ Timeout: time.Second * 5, } - dnsServers := []string{ - "8.8.4.4:53", "223.5.5.5:53", "94.140.14.140:53", "119.29.29.29:53", - "[2001:4860:4860::8844]:53", "[2400:3200::1]:53", "[2a10:50c0::1:ff]:53", "[2402:4e00::]:53", - } + dnsServers := util.DNSServersAll if len(agentConfig.DNS) > 0 { dnsServers = agentConfig.DNS } diff --git a/pkg/util/http.go b/pkg/util/http.go index b9988ad..4df8341 100644 --- a/pkg/util/http.go +++ b/pkg/util/http.go @@ -9,6 +9,10 @@ import ( "time" ) +var DNSServersV4 = []string{"8.8.4.4:53", "223.5.5.5:53", "94.140.14.140:53", "119.29.29.29:53"} +var DNSServersV6 = []string{"[2001:4860:4860::8844]:53", "[2400:3200::1]:53", "[2a10:50c0::1:ff]:53", "[2402:4e00::]:53"} +var DNSServersAll = append(DNSServersV4, DNSServersV6...) + func NewSingleStackHTTPClient(httpTimeout, dialTimeout, keepAliveTimeout time.Duration, ipv6 bool) *http.Client { dialer := &net.Dialer{ Timeout: dialTimeout, @@ -36,9 +40,9 @@ func NewSingleStackHTTPClient(httpTimeout, dialTimeout, keepAliveTimeout time.Du func resolveIP(addr string, ipv6 bool) (string, error) { url := strings.Split(addr, ":") - dnsServers := []string{"[2001:4860:4860::8844]", "[2400:3200::1]", "[2a10:50c0::1:ff]", "[2402:4e00::]"} + dnsServers := DNSServersV6 if !ipv6 { - dnsServers = []string{"8.8.4.4", "223.5.5.5", "94.140.14.140", "119.29.29.29"} + dnsServers = DNSServersV4 } res, err := net.LookupIP(url[0]) @@ -50,7 +54,7 @@ func resolveIP(addr string, ipv6 bool) (string, error) { d := net.Dialer{ Timeout: time.Second * 10, } - return d.DialContext(ctx, "udp", dnsServers[i]+":53") + return d.DialContext(ctx, "udp", dnsServers[i]) }, } res, err = r.LookupIP(context.Background(), "ip", url[0])