mirror of
https://github.com/go-ping/ping.git
synced 2025-06-27 14:36:56 +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 (
|
var (
|
||||||
ipv4Proto = map[string]string{"icmp": "ip4:icmp", "udp": "udp4"}
|
ipv4Proto = map[string]string{"icmp": "ip4:icmp", "udp": "udp4"}
|
||||||
ipv6Proto = map[string]string{"icmp": "ip6:ipv6-icmp", "udp": "udp6"}
|
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.
|
// New returns a new Pinger struct pointer.
|
||||||
@ -191,7 +193,7 @@ type Pinger struct {
|
|||||||
ipaddr *net.IPAddr
|
ipaddr *net.IPAddr
|
||||||
addr string
|
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
|
mark uint
|
||||||
|
|
||||||
// trackerUUIDs is the list of UUIDs being used for sending packets.
|
// trackerUUIDs is the list of UUIDs being used for sending packets.
|
||||||
|
@ -3,10 +3,6 @@
|
|||||||
|
|
||||||
package ping
|
package ping
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Returns the length of an ICMP message.
|
// Returns the length of an ICMP message.
|
||||||
func (p *Pinger) getMessageLength() int {
|
func (p *Pinger) getMessageLength() int {
|
||||||
return p.Size + 8
|
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.
|
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||||
// Setting this option requires CAP_NET_ADMIN.
|
// Setting this option requires CAP_NET_ADMIN.
|
||||||
func (c *icmpConn) SetMark(mark uint) error {
|
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.
|
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||||
// Setting this option requires CAP_NET_ADMIN.
|
// Setting this option requires CAP_NET_ADMIN.
|
||||||
func (c *icmpv4Conn) SetMark(mark uint) error {
|
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.
|
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||||
// Setting this option requires CAP_NET_ADMIN.
|
// Setting this option requires CAP_NET_ADMIN.
|
||||||
func (c *icmpV6Conn) SetMark(mark uint) error {
|
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
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
|
|
||||||
"golang.org/x/net/ipv4"
|
"golang.org/x/net/ipv4"
|
||||||
"golang.org/x/net/ipv6"
|
"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.
|
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||||
// Setting this option requires CAP_NET_ADMIN.
|
// Setting this option requires CAP_NET_ADMIN.
|
||||||
func (c *icmpConn) SetMark(mark uint) error {
|
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.
|
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||||
// Setting this option requires CAP_NET_ADMIN.
|
// Setting this option requires CAP_NET_ADMIN.
|
||||||
func (c *icmpv4Conn) SetMark(mark uint) error {
|
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.
|
// SetMark sets the SO_MARK socket option on outgoing ICMP packets.
|
||||||
// Setting this option requires CAP_NET_ADMIN.
|
// Setting this option requires CAP_NET_ADMIN.
|
||||||
func (c *icmpV6Conn) SetMark(mark uint) error {
|
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