File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ urls = ["www.google.com"] # required
17
17
# ping_interval = 1.0
18
18
## per-ping timeout, in s. 0 == no timeout (ping -W <TIMEOUT>)
19
19
# timeout = 1.0
20
- ## interface to send ping from (ping -I <INTERFACE>)
20
+ ## interface or source address to send ping from (ping -I <INTERFACE/SRC_ADDR>)
21
+ ## on Darwin and Freebsd only source address possible: (ping -S <SRC_ADDR>)
21
22
# interface = ""
22
23
```
23
24
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ type Ping struct {
34
34
// Ping timeout, in seconds. 0 means no timeout (ping -W <TIMEOUT>)
35
35
Timeout float64
36
36
37
- // Interface to send ping from (ping -I <INTERFACE>)
37
+ // Interface or source address to send ping from (ping -I/-S <INTERFACE/SRC_ADDR >)
38
38
Interface string
39
39
40
40
// URLs to ping
@@ -60,7 +60,8 @@ const sampleConfig = `
60
60
# ping_interval = 1.0
61
61
## per-ping timeout, in s. 0 == no timeout (ping -W <TIMEOUT>)
62
62
# timeout = 1.0
63
- ## interface to send ping from (ping -I <INTERFACE>)
63
+ ## interface or source address to send ping from (ping -I <INTERFACE/SRC_ADDR>)
64
+ ## on Darwin and Freebsd only source address possible: (ping -S <SRC_ADDR>)
64
65
# interface = ""
65
66
`
66
67
@@ -179,7 +180,15 @@ func (p *Ping) args(url string) []string {
179
180
}
180
181
}
181
182
if p .Interface != "" {
182
- args = append (args , "-I" , p .Interface )
183
+ switch runtime .GOOS {
184
+ case "linux" :
185
+ args = append (args , "-I" , p .Interface )
186
+ case "freebsd" , "darwin" :
187
+ args = append (args , "-S" , p .Interface )
188
+ default :
189
+ // Not sure the best option here, just assume GNU ping?
190
+ args = append (args , "-I" , p .Interface )
191
+ }
183
192
}
184
193
args = append (args , url )
185
194
return args
You can’t perform that action at this time.
0 commit comments