ipv4.js
function searchNetworkInterface(ip, networks) {
    networks = networks || getNetworkInterfaces();
    for (const [net, netinfo] of Object.entries(networks)) {
        const ipnet = netinfo.ip;
        const mask = netinfo.netmask;
        if (isNetworkSame(mask, ip, ipnet)) {
            return net;
        }
    }
    return null;
}
function searchNetworkInterface(ip, networks) {
    networks = networks || getNetworkInterfaces();
    for (const [net, netinfo] of Object.entries(networks)) {
        const ipnet = netinfo.ip;
        const mask = netinfo.netmask;
        if (isNetworkSame(mask, ip, ipnet)) {
            return net;
        }
    }
    return null;
}
function searchNetworkInterface ( ip , networks ) { networks = networks || getNetworkInterfaces ( ) ; for ( const [ net , netinfo ] of Object . entries ( networks ) ) { const ipnet = netinfo . ip ; const mask = netinfo . netmask ; if ( isNetworkSame ( mask , ip , ipnet ) ) { return net ; } } return null ; }
Look for the network interface from the IP address
@param {string} ip : IP address
@param {object} [networks] : List of my network interfaces. This is the same as getNetworks () 's return value.
@return {string} network interface. e.g. 'eth0' or 'wlan0'
Look for the network interface from the IP address