Skip to content

To support a funky restricted environment #3333

@master255

Description

@master255

The AI's great intelligence told me how to fix it:

ifaceAddrs, err := manet.InterfaceMultiaddrs()

Replace to:

	// Resolve the interface addresses
	ifaceAddrs, err := anet.InterfaceAddrs()
	if err != nil {
		// This usually shouldn't happen, but we could be in some kind
		// of funky restricted environment.
		log.Errorw("failed to resolve local interface addresses", "error", err)

		// Add the loopback addresses to the filtered addrs and use them as the non-filtered addrs.
		// Then bail. There's nothing else we can do here.
		i.filtered = append(i.filtered, manet.IP4Loopback, manet.IP6Loopback)
		i.all = i.filtered
		return
	}

	// remove link local ipv6 addresses
	for _, addr := range ifaceAddrs {
		if ipNet, ok := addr.(*net.IPNet); ok {
			if maddr, err := manet.FromIP(ipNet.IP); err == nil && !manet.IsIP6LinkLocal(maddr) {
				i.all = append(i.all, maddr)
			}
		}
	}

and

for j := range len(addrs) {

Replace to:

	i := 0
	for j = 0; j < len(addrs); j++ {
		if addrs[j] != nil {
			addrs[i], addrs[j] = addrs[j], addrs[i]
			i++
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions