ping: Fix on android

This commit is contained in:
世界 2025-08-24 10:47:15 +08:00
parent 86d96064d5
commit dd18aa2b86
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 3 additions and 3 deletions

View file

@ -40,7 +40,7 @@ func Connect(privileged bool, controlFunc control.Func, destination netip.Addr)
}
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)
switch conn := c.conn.(type) {
case *net.IPConn:
@ -163,7 +163,7 @@ func (c *Conn) ReadICMP(buffer *buf.Buffer) error {
if err != nil {
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
}
if !c.destination.Is6() {