@balaji003/lantransfer 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server.js +6 -8
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -512,24 +512,22 @@ function checkWindowsFirewall() {
|
|
|
512
512
|
const ruleName = 'LAN Transfer (lantransfer)';
|
|
513
513
|
const nodeExe = process.execPath;
|
|
514
514
|
|
|
515
|
-
// Check if a firewall rule already exists
|
|
515
|
+
// Check if a firewall rule already exists
|
|
516
516
|
exec(`netsh advfirewall firewall show rule name="${ruleName}"`, { windowsHide: true }, (err, stdout) => {
|
|
517
517
|
if (!err && stdout.includes(ruleName)) {
|
|
518
|
-
// Rule exists, check if it's enabled
|
|
519
518
|
if (stdout.includes('Enabled:') && stdout.includes('Yes')) {
|
|
520
519
|
console.log(' Firewall: Allowed');
|
|
521
520
|
return;
|
|
522
521
|
}
|
|
523
522
|
}
|
|
524
523
|
|
|
525
|
-
// No rule
|
|
524
|
+
// No rule — prompt user via UAC elevation
|
|
526
525
|
console.log('');
|
|
527
526
|
console.log(' !! Firewall rule not found for LAN Transfer.');
|
|
528
|
-
console.log(' !! Device discovery requires UDP/TCP
|
|
529
|
-
console.log(' !!
|
|
527
|
+
console.log(' !! Device discovery requires UDP/TCP through Windows Firewall.');
|
|
528
|
+
console.log(' !! Requesting permission (UAC prompt)...');
|
|
530
529
|
console.log('');
|
|
531
530
|
|
|
532
|
-
// Try to add the rule via elevated PowerShell — this triggers a UAC prompt
|
|
533
531
|
const addCmd = [
|
|
534
532
|
`netsh advfirewall firewall add rule name="${ruleName}" dir=in action=allow protocol=UDP localport=${DISCOVERY_PORT} program="${nodeExe}" enable=yes`,
|
|
535
533
|
`netsh advfirewall firewall add rule name="${ruleName}" dir=in action=allow protocol=TCP localport=${TRANSFER_PORT} program="${nodeExe}" enable=yes`,
|
|
@@ -539,14 +537,14 @@ function checkWindowsFirewall() {
|
|
|
539
537
|
|
|
540
538
|
exec(psCmd, { windowsHide: false, timeout: 60_000 }, (err2) => {
|
|
541
539
|
if (err2) {
|
|
542
|
-
console.log(' !!
|
|
540
|
+
console.log(' !! Firewall permission denied. Discovery will NOT work.');
|
|
543
541
|
console.log(' !! To fix manually:');
|
|
544
542
|
console.log(' !! 1. Open Windows Security > Firewall & network protection');
|
|
545
543
|
console.log(' !! 2. Click "Allow an app through firewall"');
|
|
546
544
|
console.log(' !! 3. Add Node.js and allow Private + Public networks');
|
|
547
545
|
console.log('');
|
|
548
546
|
} else {
|
|
549
|
-
console.log(' Firewall: Rule added
|
|
547
|
+
console.log(' Firewall: Rule added! Discovery should work now.');
|
|
550
548
|
}
|
|
551
549
|
});
|
|
552
550
|
});
|