Skip to content

Commit

Permalink
Renaming the Interface Pinger property to InterfaceDevice to avoi…
Browse files Browse the repository at this point in the history
…d conflict with the `interface` keyword.

Signed-off-by: Matthieu Pignolet <matthieu@matthieu-dev.xyz>
  • Loading branch information
MatthieuCoder committed Oct 29, 2024
1 parent 978c60e commit 7385672
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/ping/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func main() {
pinger.Interval = *interval
pinger.Timeout = *timeout
pinger.TTL = *ttl
pinger.Interface = *iface
pinger.InterfaceDevice = *iface
pinger.SetPrivileged(*privileged)

fmt.Printf("PING %s (%s):\n", pinger.Addr(), pinger.IPAddr())
Expand Down
6 changes: 3 additions & 3 deletions ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ type Pinger struct {
Source string

// Interface used to send/recv ICMP messages
Interface string
InterfaceDevice string

// Channel and mutex used to communicate when the Pinger should stop between goroutines.
done chan interface{}
Expand Down Expand Up @@ -528,8 +528,8 @@ func (p *Pinger) RunWithContext(ctx context.Context) error {
}

conn.SetTTL(p.TTL)
if p.Interface != "" {
iface, err := net.InterfaceByName(p.Interface)
if p.InterfaceDevice != "" {
iface, err := net.InterfaceByName(p.InterfaceDevice)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ func TestSetInterfaceName(t *testing.T) {
pinger.Timeout = time.Second

// Set loopback interface
pinger.Interface = "lo"
pinger.InterfaceDevice = "lo"
err := pinger.Run()
if runtime.GOOS == "linux" {
AssertNoError(t, err)
Expand All @@ -489,7 +489,7 @@ func TestSetInterfaceName(t *testing.T) {
}

// Set fake interface
pinger.Interface = "L()0pB@cK"
pinger.InterfaceDevice = "L()0pB@cK"
err = pinger.Run()
AssertError(t, err, "device not found")
}
Expand Down

0 comments on commit 7385672

Please sign in to comment.