mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 08:31:30 +00:00
platform: Add link flags
This commit is contained in:
parent
b702d0b67a
commit
1d517b6ca5
30
experimental/libbox/link_flags_linux.go
Normal file
30
experimental/libbox/link_flags_linux.go
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package libbox
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// copied from net.linkFlags
|
||||||
|
func linkFlags(rawFlags uint32) net.Flags {
|
||||||
|
var f net.Flags
|
||||||
|
if rawFlags&syscall.IFF_UP != 0 {
|
||||||
|
f |= net.FlagUp
|
||||||
|
}
|
||||||
|
if rawFlags&syscall.IFF_RUNNING != 0 {
|
||||||
|
f |= net.FlagRunning
|
||||||
|
}
|
||||||
|
if rawFlags&syscall.IFF_BROADCAST != 0 {
|
||||||
|
f |= net.FlagBroadcast
|
||||||
|
}
|
||||||
|
if rawFlags&syscall.IFF_LOOPBACK != 0 {
|
||||||
|
f |= net.FlagLoopback
|
||||||
|
}
|
||||||
|
if rawFlags&syscall.IFF_POINTOPOINT != 0 {
|
||||||
|
f |= net.FlagPointToPoint
|
||||||
|
}
|
||||||
|
if rawFlags&syscall.IFF_MULTICAST != 0 {
|
||||||
|
f |= net.FlagMulticast
|
||||||
|
}
|
||||||
|
return f
|
||||||
|
}
|
11
experimental/libbox/link_flags_stub.go
Normal file
11
experimental/libbox/link_flags_stub.go
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
//go:build !linux
|
||||||
|
|
||||||
|
package libbox
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
)
|
||||||
|
|
||||||
|
func linkFlags(rawFlags uint32) net.Flags {
|
||||||
|
panic("stub!")
|
||||||
|
}
|
|
@ -38,6 +38,7 @@ type NetworkInterface struct {
|
||||||
MTU int32
|
MTU int32
|
||||||
Name string
|
Name string
|
||||||
Addresses StringIterator
|
Addresses StringIterator
|
||||||
|
Flags int32
|
||||||
}
|
}
|
||||||
|
|
||||||
type WIFIState struct {
|
type WIFIState struct {
|
||||||
|
|
|
@ -181,6 +181,7 @@ func (w *platformInterfaceWrapper) Interfaces() ([]control.Interface, error) {
|
||||||
MTU: int(netInterface.MTU),
|
MTU: int(netInterface.MTU),
|
||||||
Name: netInterface.Name,
|
Name: netInterface.Name,
|
||||||
Addresses: common.Map(iteratorToArray[string](netInterface.Addresses), netip.MustParsePrefix),
|
Addresses: common.Map(iteratorToArray[string](netInterface.Addresses), netip.MustParsePrefix),
|
||||||
|
Flags: linkFlags(uint32(netInterface.Flags)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return interfaces, nil
|
return interfaces, nil
|
||||||
|
|
Loading…
Reference in a new issue