From 6cd26daf5e1f13fc7b85165680b3e6428c403bac Mon Sep 17 00:00:00 2001 From: Sebastian YEPES Date: Tue, 1 Oct 2024 22:17:00 +0200 Subject: [PATCH] update deps + add flag to disable ipv6 --- .github/workflows/release.yml | 2 +- .goreleaser.yml | 3 +- Makefile | 2 +- go.mod | 30 +++++------ go.sum | 95 ++++++++++++----------------------- main.go | 7 +-- monitor/monitor_mtr.go | 6 ++- monitor/monitor_ping.go | 6 ++- pkg/icmp/icmp.go | 14 ++++-- pkg/mtr/mtr.go | 12 ++--- pkg/mtr/type.go | 4 +- pkg/ping/ping.go | 12 ++--- target/target_mtr.go | 6 ++- target/target_ping.go | 6 ++- 14 files changed, 98 insertions(+), 107 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0b2c84..d21a3f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -52,7 +52,7 @@ jobs: check-latest: true go-version-file: go.mod - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 + uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser version: latest diff --git a/.goreleaser.yml b/.goreleaser.yml index 991e45e..b951289 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,3 +1,4 @@ +version: 2 project_name: network_exporter dist: artifacts before: @@ -41,7 +42,7 @@ archives: - network_exporter.yml wrap_in_directory: false snapshot: - name_template: SNAPSHOT-{{ .Commit }} + version_template: SNAPSHOT-{{ .Commit }} nfpms: - vendor: Sebastian YEPES homepage: "https://github.com/syepes/network_exporter" diff --git a/Makefile b/Makefile index c2f2e60..5634cc8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -BUILDX_VER=v0.15.1 +BUILDX_VER=v0.17.1 IMAGE_NAME=syepes/network_exporter VERSION?=latest diff --git a/go.mod b/go.mod index 0659a5f..cf4c48e 100644 --- a/go.mod +++ b/go.mod @@ -1,23 +1,23 @@ -go 1.22 +go 1.23 module github.com/syepes/network_exporter require ( - github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30 // indirect + github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect github.com/go-kit/log v0.2.1 - github.com/prometheus/client_golang v1.19.1 - github.com/prometheus/common v0.55.0 + github.com/prometheus/client_golang v1.20.4 + github.com/prometheus/common v0.60.0 github.com/prometheus/procfs v0.15.1 // indirect - golang.org/x/net v0.27.0 - golang.org/x/sys v0.23.0 // indirect + golang.org/x/net v0.29.0 + golang.org/x/sys v0.25.0 // indirect gopkg.in/yaml.v3 v3.0.1 ) require ( github.com/alecthomas/kingpin/v2 v2.4.0 - github.com/creasty/defaults v1.7.0 - github.com/felixge/fgprof v0.9.4 - github.com/prometheus/exporter-toolkit v0.11.0 + github.com/creasty/defaults v1.8.0 + github.com/felixge/fgprof v0.9.5 + github.com/prometheus/exporter-toolkit v0.13.0 ) require ( @@ -25,17 +25,19 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect - github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect + github.com/google/pprof v0.0.0-20241001023024-f4c0cfd0cf1d // indirect github.com/jpillora/backoff v1.0.0 // indirect - github.com/kr/text v0.2.0 // indirect + github.com/klauspost/compress v1.17.10 // indirect + github.com/mdlayher/socket v0.5.1 // indirect + github.com/mdlayher/vsock v1.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/crypto v0.27.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/text v0.18.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 2f7b3ad..58c62c0 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,9 @@ github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY= github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE= -github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 h1:ez/4by2iGztzR4L0zgAOR8lTQK9VlyBVVd7G4omaOQs= -github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= -github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30 h1:t3eaIm0rUkzbrIewtiFmMK5RXHej2XnoXNhxVsAYUfg= -github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs= +github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b h1:mimo19zliBX/vSQ6PWWSL9lK8qwHozUj03+zLoEB8O0= +github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= @@ -18,14 +14,13 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdBA= -github.com/creasty/defaults v1.7.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM= +github.com/creasty/defaults v1.8.0 h1:z27FJxCAa0JKt3utc0sCImAEb+spPucmKoOdLHvHYKk= +github.com/creasty/defaults v1.8.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM= 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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/felixge/fgprof v0.9.4 h1:ocDNwMFlnA0NU0zSB3I52xkO4sFXk80VK9lXjLClu88= -github.com/felixge/fgprof v0.9.4/go.mod h1:yKl+ERSa++RYOs32d8K6WEXCB4uXdLls4ZaZPpayhMM= +github.com/felixge/fgprof v0.9.5 h1:8+vR6yu2vvSKn08urWyEuxx75NWPEvybbkBirEpsbVY= +github.com/felixge/fgprof v0.9.5/go.mod h1:yKl+ERSa++RYOs32d8K6WEXCB4uXdLls4ZaZPpayhMM= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= @@ -36,22 +31,27 @@ github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/K github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= 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/pprof v0.0.0-20240227163752-401108e1b7e7 h1:y3N7Bm7Y9/CtpiVkw/ZWj6lSlDF3F74SfKwfTCer72Q= github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= -github.com/google/pprof v0.0.0-20240618054019-d3b898a103f8 h1:ASJ/LAqdCHOyMYI+dwNxn7Rd8FscNkMyTr1KZU1JI/M= -github.com/google/pprof v0.0.0-20240618054019-d3b898a103f8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= -github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= -github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/google/pprof v0.0.0-20241001023024-f4c0cfd0cf1d h1:Jaz2JzpQaQXyET0AjLBXShrthbpqMkhGiEfkcQAiAUs= +github.com/google/pprof v0.0.0-20241001023024-f4c0cfd0cf1d/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0= +github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos= +github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ= +github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ= +github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= @@ -59,24 +59,14 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= 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/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= -github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= -github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.50.0 h1:YSZE6aa9+luNa2da6/Tik0q0A5AbR+U003TItK57CPQ= -github.com/prometheus/common v0.50.0/go.mod h1:wHFBCEVWVmHMUpg7pYcOm2QUR/ocQdYSJVQJKnHc3xQ= -github.com/prometheus/common v0.54.0 h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM1D8= -github.com/prometheus/common v0.54.0/go.mod h1:/TQgMJP5CuVYveyT7n/0Ix8yLNNXy9yRSkhnLTHPDIQ= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= -github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= -github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= -github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o= -github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g= +github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA= +github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= +github.com/prometheus/exporter-toolkit v0.12.0 h1:DkE5RcEZR3lQA2QD5JLVQIf41dFKNsVMXFhgqcif7fo= +github.com/prometheus/exporter-toolkit v0.12.0/go.mod h1:fQH0KtTn0yrrS0S82kqppRjDDiwMfIQUwT+RBRRhwUc= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= @@ -85,51 +75,32 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ 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.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 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.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= -golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= -golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= -golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= 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/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index 692edac..5814c91 100644 --- a/main.go +++ b/main.go @@ -26,11 +26,12 @@ import ( "github.com/syepes/network_exporter/pkg/common" ) -const version string = "1.7.8" +const version string = "1.7.9" var ( WebListenAddresses = kingpin.Flag("web.listen-address", "The address to listen on for HTTP requests").Default(":9427").Strings() WebSystemdSocket = kingpin.Flag("web.system.socket", "WebSystemdSocket").Default("0").Bool() + enableIpv6 = kingpin.Flag("ipv6", "ipv6 Enable").Default("true").Bool() WebMetricPath = kingpin.Flag("web.metrics.path", "metric path").Default("/metrics").String() WebConfigFile = kingpin.Flag("web.config.file", "Path to the web configuration file").Default("").String() configFile = kingpin.Flag("config.file", "Exporter configuration file").Default("/app/cfg/network_exporter.yml").String() @@ -69,10 +70,10 @@ func main() { resolver := getResolver() - monitorPING = monitor.NewPing(logger, sc, resolver, icmpID) + monitorPING = monitor.NewPing(logger, sc, resolver, icmpID, *enableIpv6) go monitorPING.AddTargets() - monitorMTR = monitor.NewMTR(logger, sc, resolver, icmpID) + monitorMTR = monitor.NewMTR(logger, sc, resolver, icmpID, *enableIpv6) go monitorMTR.AddTargets() monitorTCP = monitor.NewTCPPort(logger, sc, resolver) diff --git a/monitor/monitor_mtr.go b/monitor/monitor_mtr.go index 1dea305..9dc6af7 100644 --- a/monitor/monitor_mtr.go +++ b/monitor/monitor_mtr.go @@ -24,12 +24,13 @@ type MTR struct { timeout time.Duration maxHops int count int + ipv6 bool targets map[string]*target.MTR mtx sync.RWMutex } // NewMTR creates and configures a new Monitoring MTR instance -func NewMTR(logger log.Logger, sc *config.SafeConfig, resolver *config.Resolver, icmpID *common.IcmpID) *MTR { +func NewMTR(logger log.Logger, sc *config.SafeConfig, resolver *config.Resolver, icmpID *common.IcmpID, ipv6 bool) *MTR { if logger == nil { logger = log.NewNopLogger() } @@ -42,6 +43,7 @@ func NewMTR(logger log.Logger, sc *config.SafeConfig, resolver *config.Resolver, timeout: sc.Cfg.MTR.Timeout.Duration(), maxHops: sc.Cfg.MTR.MaxHops, count: sc.Cfg.MTR.Count, + ipv6: ipv6, targets: make(map[string]*target.MTR), } } @@ -109,7 +111,7 @@ func (p *MTR) AddTargetDelayed(name string, host string, srcAddr string, labels return err } - target, err := target.NewMTR(p.logger, p.icmpID, startupDelay, name, ipAddrs[0], srcAddr, p.interval, p.timeout, p.maxHops, p.count, labels) + target, err := target.NewMTR(p.logger, p.icmpID, startupDelay, name, ipAddrs[0], srcAddr, p.interval, p.timeout, p.maxHops, p.count, labels, p.ipv6) if err != nil { return err } diff --git a/monitor/monitor_ping.go b/monitor/monitor_ping.go index 1031b64..87bb015 100644 --- a/monitor/monitor_ping.go +++ b/monitor/monitor_ping.go @@ -23,12 +23,13 @@ type PING struct { interval time.Duration timeout time.Duration count int + ipv6 bool targets map[string]*target.PING mtx sync.RWMutex } // NewPing creates and configures a new Monitoring ICMP instance -func NewPing(logger log.Logger, sc *config.SafeConfig, resolver *config.Resolver, icmpID *common.IcmpID) *PING { +func NewPing(logger log.Logger, sc *config.SafeConfig, resolver *config.Resolver, icmpID *common.IcmpID, ipv6 bool) *PING { if logger == nil { logger = log.NewNopLogger() } @@ -40,6 +41,7 @@ func NewPing(logger log.Logger, sc *config.SafeConfig, resolver *config.Resolver interval: sc.Cfg.ICMP.Interval.Duration(), timeout: sc.Cfg.ICMP.Timeout.Duration(), count: sc.Cfg.ICMP.Count, + ipv6: ipv6, targets: make(map[string]*target.PING), } } @@ -113,7 +115,7 @@ func (p *PING) AddTargetDelayed(name string, host string, ip string, srcAddr str p.mtx.Lock() defer p.mtx.Unlock() - target, err := target.NewPing(p.logger, p.icmpID, startupDelay, name, host, ip, srcAddr, p.interval, p.timeout, p.count, labels) + target, err := target.NewPing(p.logger, p.icmpID, startupDelay, name, host, ip, srcAddr, p.interval, p.timeout, p.count, labels, p.ipv6) if err != nil { return err } diff --git a/pkg/icmp/icmp.go b/pkg/icmp/icmp.go index f2f53b1..e7a3f0b 100644 --- a/pkg/icmp/icmp.go +++ b/pkg/icmp/icmp.go @@ -20,7 +20,7 @@ const ( ) // Icmp Validate IP and check the version -func Icmp(destAddr string, srcAddr string, ttl int, pid int, timeout time.Duration, seq int) (hop common.IcmpReturn, err error) { +func Icmp(destAddr string, srcAddr string, ttl int, pid int, timeout time.Duration, seq int, ipv6 bool) (hop common.IcmpReturn, err error) { dstIp := net.ParseIP(destAddr) if dstIp == nil { return hop, fmt.Errorf("destination ip: %v is invalid", destAddr) @@ -37,13 +37,21 @@ func Icmp(destAddr string, srcAddr string, ttl int, pid int, timeout time.Durati if p4 := dstIp.To4(); len(p4) == net.IPv4len { return icmpIpv4(srcAddr, &ipAddr, ttl, pid, timeout, seq) } - return icmpIpv6(srcAddr, &ipAddr, ttl, pid, timeout, seq) + if ipv6 { + return icmpIpv6(srcAddr, &ipAddr, ttl, pid, timeout, seq) + } else { + return hop, nil + } } if p4 := dstIp.To4(); len(p4) == net.IPv4len { return icmpIpv4("0.0.0.0", &ipAddr, ttl, pid, timeout, seq) } - return icmpIpv6("::", &ipAddr, ttl, pid, timeout, seq) + if ipv6 { + return icmpIpv6("::", &ipAddr, ttl, pid, timeout, seq) + } else { + return hop, nil + } } func icmpIpv4(localAddr string, dst net.Addr, ttl int, pid int, timeout time.Duration, seq int) (hop common.IcmpReturn, err error) { diff --git a/pkg/mtr/mtr.go b/pkg/mtr/mtr.go index 5e8a8a3..707eaae 100644 --- a/pkg/mtr/mtr.go +++ b/pkg/mtr/mtr.go @@ -10,7 +10,7 @@ import ( ) // Mtr Return traceroute object -func Mtr(addr string, srcAddr string, maxHops int, count int, timeout time.Duration, icmpID int) (*MtrResult, error) { +func Mtr(addr string, srcAddr string, maxHops int, count int, timeout time.Duration, icmpID int, ipv6 bool) (*MtrResult, error) { var out MtrResult var err error @@ -19,7 +19,7 @@ func Mtr(addr string, srcAddr string, maxHops int, count int, timeout time.Durat options.SetCount(count) options.SetTimeout(timeout) - out, err = runMtr(addr, srcAddr, icmpID, &options) + out, err = runMtr(addr, srcAddr, icmpID, &options, ipv6) if err == nil { if len(out.Hops) == 0 { @@ -33,7 +33,7 @@ func Mtr(addr string, srcAddr string, maxHops int, count int, timeout time.Durat } // MtrString Console print traceroute operation -func MtrString(addr string, srcAddr string, maxHops int, count int, timeout time.Duration, icmpID int) (result string, err error) { +func MtrString(addr string, srcAddr string, maxHops int, count int, timeout time.Duration, icmpID int, ipv6 bool) (result string, err error) { options := MtrOptions{} options.SetMaxHops(maxHops) options.SetCount(count) @@ -43,7 +43,7 @@ func MtrString(addr string, srcAddr string, maxHops int, count int, timeout time var buffer bytes.Buffer buffer.WriteString(fmt.Sprintf("Start: %v, DestAddr: %v\n", time.Now().Format("2006-01-02 15:04:05"), addr)) - out, err = runMtr(addr, srcAddr, icmpID, &options) + out, err = runMtr(addr, srcAddr, icmpID, &options, ipv6) if err == nil { if len(out.Hops) == 0 { @@ -83,7 +83,7 @@ func MtrString(addr string, srcAddr string, maxHops int, count int, timeout time } // MTR -func runMtr(destAddr string, srcAddr string, icmpID int, options *MtrOptions) (result MtrResult, err error) { +func runMtr(destAddr string, srcAddr string, icmpID int, options *MtrOptions, ipv6 bool) (result MtrResult, err error) { result.Hops = []common.IcmpHop{} result.DestAddr = destAddr @@ -100,7 +100,7 @@ func runMtr(destAddr string, srcAddr string, icmpID int, options *MtrOptions) (r mtrReturns[ttl] = &MtrReturn{ttl: ttl, host: "unknown", succSum: 0, success: false, lastTime: time.Duration(0), sumTime: time.Duration(0), bestTime: time.Duration(0), worstTime: time.Duration(0), avgTime: time.Duration(0)} } - hopReturn, err := icmp.Icmp(destAddr, srcAddr, ttl, pid, timeout, seq) + hopReturn, err := icmp.Icmp(destAddr, srcAddr, ttl, pid, timeout, seq, ipv6) if err != nil || !hopReturn.Success { continue } diff --git a/pkg/mtr/type.go b/pkg/mtr/type.go index 3559cbc..f87fc2b 100644 --- a/pkg/mtr/type.go +++ b/pkg/mtr/type.go @@ -13,8 +13,8 @@ const defaultCount = 10 // MtrResult Calculated results type MtrResult struct { - DestAddr string `json:"dest_address"` - Hops []common.IcmpHop `json:"hops"` + DestAddr string `json:"dest_address"` + Hops []common.IcmpHop `json:"hops"` HopSummaryMap map[string]*common.IcmpSummary `json:"hop_summary_map"` } diff --git a/pkg/ping/ping.go b/pkg/ping/ping.go index e86fc88..42afbe5 100644 --- a/pkg/ping/ping.go +++ b/pkg/ping/ping.go @@ -10,14 +10,14 @@ import ( ) // Ping ICMP Operation -func Ping(addr string, ip string, srcAddr string, count int, timeout time.Duration, icmpID int) (*PingResult, error) { +func Ping(addr string, ip string, srcAddr string, count int, timeout time.Duration, icmpID int, ipv6 bool) (*PingResult, error) { var out PingResult pingOptions := &PingOptions{} pingOptions.SetCount(count) pingOptions.SetTimeout(timeout) - out, err := runPing(addr, ip, srcAddr, icmpID, pingOptions) + out, err := runPing(addr, ip, srcAddr, icmpID, pingOptions, ipv6) if err != nil { return &out, err } @@ -25,7 +25,7 @@ func Ping(addr string, ip string, srcAddr string, count int, timeout time.Durati } // PingString ICMP Operation -func PingString(addr string, ip string, srcAddr string, count int, timeout time.Duration, icmpID int) (result string, err error) { +func PingString(addr string, ip string, srcAddr string, count int, timeout time.Duration, icmpID int, ipv6 bool) (result string, err error) { pingOptions := &PingOptions{} pingOptions.SetCount(count) pingOptions.SetTimeout(timeout) @@ -33,7 +33,7 @@ func PingString(addr string, ip string, srcAddr string, count int, timeout time. var buffer bytes.Buffer buffer.WriteString(fmt.Sprintf("Start %v, PING %v (%v)\n", time.Now().Format("2006-01-02 15:04:05"), addr, addr)) begin := time.Now().UnixNano() / 1e6 - pingResult, err := runPing(addr, ip, srcAddr, icmpID, pingOptions) + pingResult, err := runPing(addr, ip, srcAddr, icmpID, pingOptions, ipv6) end := time.Now().UnixNano() / 1e6 buffer.WriteString(fmt.Sprintf("%v packets transmitted, %v packet loss, time %vms\n", count, pingResult.DropRate, end-begin)) @@ -48,7 +48,7 @@ func PingString(addr string, ip string, srcAddr string, count int, timeout time. return result, nil } -func runPing(ipAddr string, ip string, srcAddr string, icmpID int, option *PingOptions) (pingResult PingResult, err error) { +func runPing(ipAddr string, ip string, srcAddr string, icmpID int, option *PingOptions, ipv6 bool) (pingResult PingResult, err error) { pingResult.DestAddr = ipAddr pingResult.DestIp = ip @@ -60,7 +60,7 @@ func runPing(ipAddr string, ip string, srcAddr string, icmpID int, option *PingO seq := 0 for cnt := 0; cnt < option.Count(); cnt++ { - icmpReturn, err := icmp.Icmp(ip, srcAddr, ttl, pid, timeout, seq) + icmpReturn, err := icmp.Icmp(ip, srcAddr, ttl, pid, timeout, seq, ipv6) if err != nil || !icmpReturn.Success || !common.IsEqualIP(ip, icmpReturn.Addr) { continue diff --git a/target/target_mtr.go b/target/target_mtr.go index 4554454..a4b007f 100644 --- a/target/target_mtr.go +++ b/target/target_mtr.go @@ -24,6 +24,7 @@ type MTR struct { timeout time.Duration maxHops int count int + ipv6 bool labels map[string]string result *mtr.MtrResult stop chan struct{} @@ -32,7 +33,7 @@ type MTR struct { } // NewMTR starts a new monitoring goroutine -func NewMTR(logger log.Logger, icmpID *common.IcmpID, startupDelay time.Duration, name string, host string, srcAddr string, interval time.Duration, timeout time.Duration, maxHops int, count int, labels map[string]string) (*MTR, error) { +func NewMTR(logger log.Logger, icmpID *common.IcmpID, startupDelay time.Duration, name string, host string, srcAddr string, interval time.Duration, timeout time.Duration, maxHops int, count int, labels map[string]string, ipv6 bool) (*MTR, error) { if logger == nil { logger = log.NewNopLogger() } @@ -46,6 +47,7 @@ func NewMTR(logger log.Logger, icmpID *common.IcmpID, startupDelay time.Duration timeout: timeout, maxHops: maxHops, count: count, + ipv6: ipv6, labels: labels, stop: make(chan struct{}), result: &mtr.MtrResult{HopSummaryMap: map[string]*common.IcmpSummary{}}, @@ -89,7 +91,7 @@ func (t *MTR) Stop() { func (t *MTR) mtr() { icmpID := int(t.icmpID.Get()) - data, err := mtr.Mtr(t.host, t.srcAddr, t.maxHops, t.count, t.timeout, icmpID) + data, err := mtr.Mtr(t.host, t.srcAddr, t.maxHops, t.count, t.timeout, icmpID, t.ipv6) if err != nil { level.Error(t.logger).Log("type", "MTR", "func", "mtr", "msg", fmt.Sprintf("%s", err)) } diff --git a/target/target_ping.go b/target/target_ping.go index 4c394bc..866e231 100644 --- a/target/target_ping.go +++ b/target/target_ping.go @@ -25,6 +25,7 @@ type PING struct { interval time.Duration timeout time.Duration count int + ipv6 bool labels map[string]string result *ping.PingResult stop chan struct{} @@ -33,7 +34,7 @@ type PING struct { } // NewPing starts a new monitoring goroutine -func NewPing(logger log.Logger, icmpID *common.IcmpID, startupDelay time.Duration, name string, host string, ip string, srcAddr string, interval time.Duration, timeout time.Duration, count int, labels map[string]string) (*PING, error) { +func NewPing(logger log.Logger, icmpID *common.IcmpID, startupDelay time.Duration, name string, host string, ip string, srcAddr string, interval time.Duration, timeout time.Duration, count int, labels map[string]string, ipv6 bool) (*PING, error) { if logger == nil { logger = log.NewNopLogger() } @@ -47,6 +48,7 @@ func NewPing(logger log.Logger, icmpID *common.IcmpID, startupDelay time.Duratio interval: interval, timeout: timeout, count: count, + ipv6: ipv6, labels: labels, stop: make(chan struct{}), result: &ping.PingResult{}, @@ -90,7 +92,7 @@ func (t *PING) Stop() { func (t *PING) ping() { icmpID := int(t.icmpID.Get()) - data, err := ping.Ping(t.host, t.ip, t.srcAddr, t.count, t.timeout, icmpID) + data, err := ping.Ping(t.host, t.ip, t.srcAddr, t.count, t.timeout, icmpID, t.ipv6) if err != nil { level.Error(t.logger).Log("type", "ICMP", "func", "ping", "msg", fmt.Sprintf("%s", err)) }