mirror of
https://github.com/go-ping/ping.git
synced 2025-06-27 06:26:55 +00:00
create error type for unsupported SO_MARK socket option
Signed-off-by: Jeremiah Millay <jmillay@fastly.com>
This commit is contained in:
parent
089e6a92cb
commit
877239a18a
4
ping.go
4
ping.go
@ -83,6 +83,8 @@ const (
|
||||
var (
|
||||
ipv4Proto = map[string]string{"icmp": "ip4:icmp", "udp": "udp4"}
|
||||
ipv6Proto = map[string]string{"icmp": "ip6:ipv6-icmp", "udp": "udp6"}
|
||||
|
||||
ErrMarkNotSupported = errors.New("setting SO_MARK socket option is not supported on this platform")
|
||||
)
|
||||
|
||||
// New returns a new Pinger struct pointer.
|
||||
@ -191,7 +193,7 @@ type Pinger struct {
|
||||
ipaddr *net.IPAddr
|
||||
addr string
|
||||
|
||||
// Mark is a mark (fwmark) set on outgoing icmp packets
|
||||
// mark is a SO_MARK (fwmark) set on outgoing icmp packets
|
||||
mark uint
|
||||
|
||||
// trackerUUIDs is the list of UUIDs being used for sending packets.
|
||||
|
@ -3,10 +3,6 @@
|
||||
|
||||
package ping
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Returns the length of an ICMP message.
|
||||
func (p *Pinger) getMessageLength() int {
|
||||
return p.Size + 8
|
||||
@ -20,17 +16,17 @@ func (p *Pinger) matchID(ID int) bool {
|
||||
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||
// Setting this option requires CAP_NET_ADMIN.
|
||||
func (c *icmpConn) SetMark(mark uint) error {
|
||||
return errors.New("setting SO_MARK socket option is not supported on this platform")
|
||||
return ErrMarkNotSupported
|
||||
}
|
||||
|
||||
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||
// Setting this option requires CAP_NET_ADMIN.
|
||||
func (c *icmpv4Conn) SetMark(mark uint) error {
|
||||
return errors.New("setting SO_MARK socket option is not supported on this platform")
|
||||
return ErrMarkNotSupported
|
||||
}
|
||||
|
||||
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||
// Setting this option requires CAP_NET_ADMIN.
|
||||
func (c *icmpV6Conn) SetMark(mark uint) error {
|
||||
return errors.New("setting SO_MARK socket option is not supported on this platform")
|
||||
return ErrMarkNotSupported
|
||||
}
|
||||
|
@ -4,8 +4,6 @@
|
||||
package ping
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"golang.org/x/net/ipv4"
|
||||
"golang.org/x/net/ipv6"
|
||||
)
|
||||
@ -29,17 +27,17 @@ func (p *Pinger) matchID(ID int) bool {
|
||||
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||
// Setting this option requires CAP_NET_ADMIN.
|
||||
func (c *icmpConn) SetMark(mark uint) error {
|
||||
return errors.New("setting SO_MARK socket option is not supported on this platform")
|
||||
return ErrMarkNotSupported
|
||||
}
|
||||
|
||||
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||
// Setting this option requires CAP_NET_ADMIN.
|
||||
func (c *icmpv4Conn) SetMark(mark uint) error {
|
||||
return errors.New("setting SO_MARK socket option is not supported on this platform")
|
||||
return ErrMarkNotSupported
|
||||
}
|
||||
|
||||
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||
// Setting this option requires CAP_NET_ADMIN.
|
||||
func (c *icmpV6Conn) SetMark(mark uint) error {
|
||||
return errors.New("setting SO_MARK socket option is not supported on this platform")
|
||||
return ErrMarkNotSupported
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user