Skip to content

Libp2p fails to determine default route on FreeBSD #973

@Stebalien

Description

@Stebalien

On FreeBSD, netroute.Router.Route('0.0.0.0') returns an error instead of returning the default route. We need some other way to determine the default route. We could just try looking up a well known IP address.

if r, err := netroute.New(); err != nil {
log.Debugw("failed to build Router for kernel's routing table", "err", err)
} else {
if _, _, localIPv4, err := r.Route(net.IPv4zero); err != nil {
log.Debugw("failed to fetch local IPv4 address", "err", err)
} else {
maddr, err := manet.FromIP(localIPv4)
if err == nil {
h.localIPv4Addr = maddr
}
}
if _, _, localIpv6, err := r.Route(net.IPv6unspecified); err != nil {
log.Debugw("failed to fetch local IPv6 address", "err", err)
} else {
maddr, err := manet.FromIP(localIpv6)
if err == nil {
h.localIPv6Addr = maddr
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood issue for new contributorshelp wantedSeeking public contribution on this issuekind/bugA bug in existing code (including security flaws)status/readyReady to be worked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions