Skip to content

Commit 1fd659d

Browse files
fix(ipscan): lints related to fmt.ErrorF and address formatting
1 parent 63ffe2a commit 1fd659d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/mod/ipscan/ipscan.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ func ScanIpRange(start, end string) ([]*DiscoveredHost, error) {
3232
ipStart := net.ParseIP(start)
3333
ipEnd := net.ParseIP(end)
3434
if ipStart == nil || ipEnd == nil {
35-
return nil, fmt.Errorf("Invalid IP address")
35+
return nil, fmt.Errorf("invalid IP address")
3636
}
3737

3838
if bytes.Compare(ipStart, ipEnd) > 0 {
39-
return nil, fmt.Errorf("Invalid IP range")
39+
return nil, fmt.Errorf("invalid IP range")
4040
}
4141

4242
var wg sync.WaitGroup
@@ -108,7 +108,7 @@ func (host *DiscoveredHost) CheckPing() error {
108108
pinger.Run()
109109
stats := pinger.Statistics()
110110
if stats.PacketsRecv == 0 {
111-
return fmt.Errorf("Host unreachable for " + host.IP)
111+
return fmt.Errorf("host unreachable for %s", host.IP)
112112
}
113113
host.Ping = int(stats.AvgRtt.Milliseconds())
114114
return nil
@@ -136,7 +136,7 @@ func (host *DiscoveredHost) ScanPorts(startPort, endPort int) []int {
136136
var openPorts []int
137137

138138
for port := startPort; port <= endPort; port++ {
139-
target := fmt.Sprintf("%s:%d", host.IP, port)
139+
target := net.JoinHostPort(host.IP, fmt.Sprintf("%d", port))
140140
conn, err := net.DialTimeout("tcp", target, time.Millisecond*500)
141141
if err == nil {
142142
conn.Close()

src/mod/ipscan/portscan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func ScanPorts(host string) []*OpenedPort {
3030
wg.Add(1)
3131
go func(port int) {
3232
defer wg.Done()
33-
address := fmt.Sprintf("%s:%d", host, port)
33+
address := net.JoinHostPort(host, fmt.Sprintf("%d", port))
3434

3535
// Check TCP
3636
conn, err := net.DialTimeout("tcp", address, 5*time.Second)

0 commit comments

Comments
 (0)