Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ To keep the code base of commitlint neat and tidy the following rules apply to e
- Favor micro library over swiss army knives (rimraf, ncp vs. fs-extra)
- Be awesome

> use commands `npm run eslint` and `npm run format` to be sure your code
> use commands `npm run lint` and `npm run format` to be sure your code
> respect coding rules.

> You can also use `npm run format:fix` to fix prettier errors
Expand Down
74 changes: 53 additions & 21 deletions src/windows-current-connections.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,64 @@
const os = require('os');
const execFile = require('child_process').execFile;
const env = require('./env');
const networkUtils = require('./utils/network-utils.js');

function isWin11() {
const winMajor = os.release().split('.')[0];
const winMinor = os.release().split('.')[1];
const winBuild = os.release().split('.')[2];
return winMajor >= 10 && winMinor >= 0 && winBuild >= 22000;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be winMajor >= 11? It still works because there is also the winBuild restriction though.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering my own question: no, winMajor is still 10 in windows 11:

https://stackoverflow.com/a/76873811

}

function parseShowInterfaces(stdout) {
const lines = stdout.split('\r\n');
const numberOfLines = isWin11() ? 20 : 18;
const connections = [];
let i = 3;
while (lines.length > i + 18) {
while (lines.length > i + numberOfLines) {
const tmpConnection = {};
const fields = [
'name',
'description',
'guid',
'mac',
'state',
'ssid',
'bssid',
'mode',
'radio',
'authentication',
'encryption',
'connection',
'channel',
'reception',
'transmission',
'signal',
'profil'
];
const fields = isWin11()
? [
'name',
'description',
'guid',
'mac',
'ifaceType',
'state',
'ssid',
'bssid',
'mode',
'radio',
'authentication',
'encryption',
'connection',
'band',
'channel',
'reception',
'transmission',
'signal',
'profile'
]
: [
// else Windows 10
'name',
'description',
'guid',
'mac',
'state',
'ssid',
'bssid',
'mode',
'radio',
'authentication',
'encryption',
'connection',
'channel',
'reception',
'transmission',
'signal',
'profile'
];
for (let j = 0; j < fields.length; j++) {
const line = lines[i + j];
tmpConnection[fields[j]] = line.match(/.*: (.*)/)[1];
Expand All @@ -48,7 +80,7 @@ function parseShowInterfaces(stdout) {
security_flags: tmpConnection.encryption
});

i = i + 18;
i = i + numberOfLines;
}

return connections;
Expand Down