@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +6 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@balaji003/lantransfer",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "LAN File Transfer — peer-to-peer file sharing over local network. Zero dependencies.",
5
5
  "main": "server.js",
6
6
  "bin": {
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 for this app
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 found — prompt the user to allow it
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 access through Windows Firewall.');
529
- console.log(' !! Attempting to add firewall rule (requires Admin)...');
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(' !! Could not add firewall rule. Discovery may not work.');
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 successfully! Discovery should work now.');
547
+ console.log(' Firewall: Rule added! Discovery should work now.');
550
548
  }
551
549
  });
552
550
  });