friedrith / node-wifi

šŸ“¶ NodeJS tool to manage wifi (connections, scans)
MIT License
396 stars 161 forks source link

It fails to differentiate SSIDs with Unicode and ones without. #194

Open issuefiler opened 5 months ago

issuefiler commented 5 months ago

Expected behavior

WiFi.scan() should be able to differentiate the two SSIDs ā€œšŸ§Šā€ (4 octets in UTF-8) and ā€œF09FA78Aā€ (8 octets).

Wi-Fi access points with two different SSIDs

Current behavior

> netsh wlan show networks
Interface name : Wi-Fi
There are 5 networks currently visible.

ā€¦ā€¦

SSID 3 : F09FA78A
    Network type            : Infrastructure
    Authentication          : WPA2-Personal
    Encryption              : CCMP

SSID 4 : F09FA78A
    Network type            : Infrastructure
    Authentication          : WPA2-Personal
    Encryption              : CCMP

ā€¦ā€¦
import WiFi from "node-wifi";

WiFi.init({iface: null});
console.log(await WiFi.scan());
ā€¦ā€¦
{
    mac: '28:cd:c1:0e:50:82',
    bssid: '28:cd:c1:0e:50:82',
    ssid: 'F09FA78A',
    channel: 3,
    frequency: 2422,
    signal_level: -67.5,
    quality: 65,
    security: 'WPA2-Personal',
    security_flags: 'CCMP ',
    mode: 'Unknown'
},
{
    mac: '28:cd:c1:0e:50:80',
    bssid: '28:cd:c1:0e:50:80',
    ssid: 'F09FA78A',
    channel: 3,
    frequency: 2422,
    signal_level: -60,
    quality: 80,
    security: 'WPA2-Personal',
    security_flags: 'CCMP ',
    mode: 'Unknown'
}
ā€¦ā€¦

Which are the affected features

Which is your operating system?

Windows

Environment

Windows

Version of node-wifi

2.0.16

Steps to Reproduce

Have two Wi-Fi access points with the different SSIDs ā€œšŸ§Šā€ (4 octets in UTF-8) and ā€œF09FA78Aā€ (8 octets), and try scanning them with this Node.js package in Windows.

Solutions

By not relying on netsh and calling the native Wi-Fi Windows API instead.