ping: Fix on android
This commit is contained in:
parent
86d96064d5
commit
dd18aa2b86
2 changed files with 3 additions and 3 deletions
|
|
@ -40,7 +40,7 @@ func Connect(privileged bool, controlFunc control.Func, destination netip.Addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) ReadIP(buffer *buf.Buffer) error {
|
func (c *Conn) ReadIP(buffer *buf.Buffer) error {
|
||||||
if c.destination.Is6() || runtime.GOOS == "linux" && !c.privileged {
|
if c.destination.Is6() || (runtime.GOOS == "linux" || runtime.GOOS == "android") && !c.privileged {
|
||||||
var readMsg func(b, oob []byte) (n, oobn int, addr netip.Addr, err error)
|
var readMsg func(b, oob []byte) (n, oobn int, addr netip.Addr, err error)
|
||||||
switch conn := c.conn.(type) {
|
switch conn := c.conn.(type) {
|
||||||
case *net.IPConn:
|
case *net.IPConn:
|
||||||
|
|
@ -163,7 +163,7 @@ func (c *Conn) ReadICMP(buffer *buf.Buffer) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if c.destination.Is6() || runtime.GOOS == "linux" && !c.privileged {
|
if c.destination.Is6() || (runtime.GOOS == "linux" || runtime.GOOS == "android") && !c.privileged {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !c.destination.Is6() {
|
if !c.destination.Is6() {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ func connect(privileged bool, controlFunc control.Func, destination netip.Addr)
|
||||||
return nil, E.Cause(err, "connect()")
|
return nil, E.Cause(err, "connect()")
|
||||||
}
|
}
|
||||||
|
|
||||||
if destination.Is4() && runtime.GOOS == "linux" {
|
if destination.Is4() && (runtime.GOOS == "linux" || runtime.GOOS == "android") {
|
||||||
//err = unix.SetsockoptInt(fd, unix.IPPROTO_IP, unix.IP_RECVTOS, 1)
|
//err = unix.SetsockoptInt(fd, unix.IPPROTO_IP, unix.IP_RECVTOS, 1)
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue