Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change win32 batch file input params #206

Merged
merged 1 commit into from
Apr 5, 2020
Merged
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
Change win32 batch file input params
  • Loading branch information
a86913179 authored Apr 4, 2020
commit fca58374100a6fc0b8b9169be9345fc7a0bcf715
6 changes: 3 additions & 3 deletions src/helper/win32/config_route.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set TUN_GW=%1
for /f %%a in ('PowerShell -Command "& {Get-NetAdapter -InterfaceDescription *TAP* | Select-Object -ExpandProperty InterfaceAlias}"') do (set TAP=%%a)
set DEVICE_NAME=%2

PowerShell -Command "& {New-NetRoute -DestinationPrefix 0.0.0.0/0 -InterfaceAlias %TAP% -NextHop %TUN_GW% -RouteMetric 0 -PolicyStore ActiveStore -Confirm:$False}"
PowerShell -Command "& {Set-NetIPInterface -InterfaceAlias * -AddressFamily IPv6 -RouterDiscovery Disabled}"
PowerShell -Command "& {New-NetRoute -DestinationPrefix 0.0.0.0/0 -InterfaceAlias %DEVICE_NAME% -NextHop %TUN_GW% -RouteMetric 0 -PolicyStore ActiveStore -Confirm:$False}"
PowerShell -Command "& {Set-NetIPInterface -AddressFamily IPv6 -RouterDiscovery Disabled}"
PowerShell -Command "& {Clear-DnsClientCache}"
2 changes: 1 addition & 1 deletion src/helper/win32/ensure_tap_device.bat
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ netsh interface set interface "%DEVICE_NAME%" admin=enabled
:: )

echo Set all adapters metric to auto.
PowerShell -Command "& {Set-NetIPInterface -InterfaceAlias * -AutomaticMetric Enabled}"
PowerShell -Command "& {Set-NetIPInterface -AutomaticMetric Enabled}"

echo Set TAP adapter metric to 0.
PowerShell -Command "& {Set-NetIPInterface -InterfaceAlias %DEVICE_NAME% -InterfaceMetric 0}"
Expand Down
6 changes: 3 additions & 3 deletions src/helper/win32/recover_route.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
for /f %%a in ('PowerShell -Command "& {Get-NetAdapter -InterfaceDescription *TAP* | Select-Object -ExpandProperty InterfaceAlias}"') do (set TAP=%%a)
set DEVICE_NAME=%1

PowerShell -Command "& {Remove-NetRoute -InterfaceAlias %TAP% -Confirm:$False}"
PowerShell -Command "& {Set-NetIPInterface -InterfaceAlias * -AddressFamily IPv6 -RouterDiscovery Enabled}"
PowerShell -Command "& {Remove-NetRoute -DestinationPrefix 0.0.0.0/0 -InterfaceAlias %DEVICE_NAME% -Confirm:$False}"
PowerShell -Command "& {Set-NetIPInterface -AddressFamily IPv6 -RouterDiscovery Enabled}"
PowerShell -Command "& {Clear-DnsClientCache}"
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ async function configRoute() {
execSync(util.format('"%s" add default %s -ifscope %s', routeCmd, origGw, origGwScope))
break
case 'win32':
await sudoExec(util.format('"%s" %s %s', path.join(helperResourcePath, 'config_route.bat'), tunGw, origGw))
await sudoExec(util.format('"%s" %s %s', path.join(helperResourcePath, 'config_route.bat'), tunGw, tunName))
break
case 'linux':
execSync(util.format('"%s" %s %s %s %s %s', path.join(helperResourcePath, 'config_route'), routeCmd, tunGw, origGw, origGwScope, sendThrough))
Expand Down Expand Up @@ -689,7 +689,7 @@ async function recoverRoute() {
execSync(util.format('"%s" add default %s', routeCmd, origGw))
break
case 'win32':
await sudoExec(util.format('"%s" %s', path.join(helperResourcePath, 'recover_route.bat'), origGw))
await sudoExec(util.format('"%s" %s', path.join(helperResourcePath, 'recover_route.bat'), tunName))
break
case 'linux':
execSync(util.format('"%s" %s %s', path.join(helperResourcePath, 'recover_route'), routeCmd, sendThrough, origGw))
Expand Down