arblant
firefox-vpn-client / core / internal / tunstack / interface_other.go
interface_other.go19 lines · 414 B
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
//go:build !windows

package tunstack

import "net"

// Interface is the adapter's name and interface index; the LUID is
// Windows'.
func (d *Device) Interface() (name string, index uint32, luid uint64, err error) {
	name, err = d.tun.Name()
	if err != nil {
		return "", 0, 0, err
	}
	iface, err := net.InterfaceByName(name)
	if err != nil {
		return "", 0, 0, err
	}
	return name, uint32(iface.Index), 0, nil
}