Skip to content

Commit 7aaaaf2

Browse files
committed
Merge branch 'develop'
2 parents 97316e2 + 387149c commit 7aaaaf2

File tree

5 files changed

+4
-50
lines changed

5 files changed

+4
-50
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM devopsworks/golang-upx:1.15 AS builder
1+
FROM devopsworks/golang-upx:1.16 AS builder
22

33
ENV GO111MODULE=on \
44
CGO_ENABLED=0 \

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func run(args []string, stdout io.Writer) error {
3232
var confFile, pprofAddr, loglvl string
3333
flag.StringVar(&confFile, "config", "config.yaml", "path to config file")
3434
flag.StringVar(&pprofAddr, "pprof.addr", "", "pprof addr")
35-
flag.StringVar(&loglvl, "log.lvl", "info", "log level. Can be {trace,debug,info,warn,error,fatal}")
35+
flag.StringVar(&loglvl, "log.lvl", "debug", "log level. Can be {trace,debug,info,warn,error,fatal}")
3636
flag.Parse()
3737

3838
fmt.Printf("scan-exporter version %s (built %s)\n", Version, BuildDate)

metrics/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (s *Server) Updater(metChan chan NewMetrics, pingChan chan PingInfo, pendin
163163

164164
// New ping metric has been received
165165
if pm.IsResponding {
166-
log.Info().Str("name", pm.Name).Str("ip", pm.IP).Str("rtt", pm.RTT.String()).Msgf("%s (%s) responds to ICMP requests", pm.Name, pm.IP)
166+
log.Debug().Str("name", pm.Name).Str("ip", pm.IP).Str("rtt", pm.RTT.String()).Msgf("%s (%s) responds to ICMP requests", pm.Name, pm.IP)
167167
} else {
168168
log.Warn().Str("name", pm.Name).Str("ip", pm.IP).Str("rtt", "nil").Msgf("%s (%s) does not respond to ICMP requests", pm.Name, pm.IP)
169169
}

scan/scan.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ import (
1919
"golang.org/x/sync/semaphore"
2020
)
2121

22-
type pinger struct {
23-
ip string
24-
name string
25-
period string
26-
}
27-
2822
type target struct {
2923
ip string
3024
name string
@@ -162,7 +156,7 @@ func (s *Scanner) Start(c *config.Conf) error {
162156
for {
163157
select {
164158
case triggeredIP := <-trigger:
165-
s.Logger.Debug().Msgf("received trigger for %s", triggeredIP)
159+
s.Logger.Debug().Msgf("starting new scan for %s", triggeredIP)
166160
if err := s.run(triggeredIP, scanIsOver, singleResult); err != nil {
167161
s.Logger.Error().Err(err).Msg("error running scan")
168162
}

scan/utils.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package scan
22

33
import (
4-
"errors"
54
"fmt"
6-
"net"
75
"strconv"
86
"strings"
97
"time"
@@ -30,44 +28,6 @@ func getDuration(period string) (time.Duration, error) {
3028
return t, nil
3129
}
3230

33-
// getIP returns an external IP to bind on
34-
func getIP() (string, error) {
35-
ifaces, err := net.Interfaces()
36-
if err != nil {
37-
return "", err
38-
}
39-
for _, iface := range ifaces {
40-
if iface.Flags&net.FlagUp == 0 {
41-
continue // interface down
42-
}
43-
if iface.Flags&net.FlagLoopback != 0 {
44-
continue // loopback interface
45-
}
46-
addrs, err := iface.Addrs()
47-
if err != nil {
48-
return "", err
49-
}
50-
for _, addr := range addrs {
51-
var ip net.IP
52-
switch v := addr.(type) {
53-
case *net.IPNet:
54-
ip = v.IP
55-
case *net.IPAddr:
56-
ip = v.IP
57-
}
58-
if ip == nil || ip.IsLoopback() {
59-
continue
60-
}
61-
ip = ip.To4()
62-
if ip == nil {
63-
continue // not an ipv4 address
64-
}
65-
return ip.String(), nil
66-
}
67-
}
68-
return "", errors.New("no critical error but impossible to find an external IP address")
69-
}
70-
7131
// readPortsRange transforms a range of ports given in conf to an array of
7232
// effective ports
7333
func readPortsRange(ranges string) ([]int, error) {

0 commit comments

Comments
 (0)