mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 12:03:33 +00:00
exclude Docker bridge br-[0-9a-f]{12} interfaces from machine routable IPs
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -24,6 +25,13 @@ func ListRoutableIPs() ([]netip.Addr, error) {
|
|||||||
// Skip the Uncloud WireGuard and Docker interfaces.
|
// Skip the Uncloud WireGuard and Docker interfaces.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// Docker bridge name doesn't seem to be documented but this is the source code where it is generated:
|
||||||
|
// https://github.com/moby/moby/blob/v27.2.1/libnetwork/drivers/bridge/bridge_linux.go#L664
|
||||||
|
if match, _ := regexp.MatchString(`br-[0-9a-f]{12}`, iface.Name); match {
|
||||||
|
// Skip Docker bridge interfaces.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if iface.Flags&net.FlagUp == 0 || iface.Flags&net.FlagRunning == 0 || iface.Flags&net.FlagLoopback != 0 {
|
if iface.Flags&net.FlagUp == 0 || iface.Flags&net.FlagRunning == 0 || iface.Flags&net.FlagLoopback != 0 {
|
||||||
// Skip interfaces:
|
// Skip interfaces:
|
||||||
// * Not administratively UP.
|
// * Not administratively UP.
|
||||||
|
|||||||
Reference in New Issue
Block a user