forked from clowwindy/ShadowVPN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Support by TUN/TAP driver from OpenVPN - Native Windows API without emulation - Client up and down sample .bat scripts Limitations: * Only support MinGW, not support Cygwin due to the TUN/TAP driver * Daemonize not working, can only run in the foreground * Scripts can only be written in batch file format, bash not supported
- Loading branch information
Showing
15 changed files
with
707 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
*.status | ||
*.tar.* | ||
*~ | ||
*.exe | ||
.DS_Store | ||
.deps | ||
.dirstamp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# ShadowVPN config example for windows | ||
|
||
# notice: do not put space before or after "=" | ||
|
||
# server listen address | ||
server=127.0.0.1 | ||
|
||
# server listen port | ||
port=1123 | ||
|
||
# password to use | ||
password=my_password | ||
|
||
# server or client | ||
mode=client | ||
|
||
# local tunnel ip address (required) | ||
tunip=10.7.0.2 | ||
|
||
# the MTU of VPN device | ||
# 1492(Ethernet) - 20(IPv4, or 40 for IPv6) - 8(UDP) - 24(ShadowVPN) | ||
mtu=1440 | ||
|
||
# tun/tap interface name | ||
intf=Local Area Connection 2 | ||
|
||
# the script to run after VPN is created | ||
# use this script to set up routes, NAT, etc | ||
# configuration in this file will be set as environment variables | ||
up=client_up.bat | ||
|
||
# the script to run before stopping VPN | ||
# use this script to restore routes, NAT, etc | ||
# configuration in this file will be set as environment variables | ||
down=client_down.bat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@ECHO off | ||
REM example client down script for windows | ||
REM will be executed when client is down | ||
|
||
REM all key value pairs in ShadowVPN config file will be passed to this script | ||
REM as environment variables, except password | ||
|
||
REM user-defined variables | ||
SET remote_tun_ip=10.7.0.1 | ||
SET orig_intf="Local Area Connection" | ||
|
||
REM revert ip settings | ||
netsh interface ip set interface %orig_intf% ignoredefaultroutes=disabled > NUL | ||
netsh interface ip set address name="%intf%" dhcp > NUL | ||
|
||
REM revert routing table | ||
ECHO reverting default route | ||
route delete 0.0.0.0 mask 128.0.0.0 %remote_tun_ip% > NUL | ||
route delete 128.0.0.0 mask 128.0.0.0 %remote_tun_ip% > NUL | ||
route delete %server% > NUL | ||
|
||
REM revert dns server | ||
netsh interface ip set dns name="%intf%" source=dhcp > NUL | ||
|
||
ECHO %0 done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@ECHO off | ||
REM example client up script for windows | ||
REM will be executed when client is up | ||
|
||
REM all key value pairs in ShadowVPN config file will be passed to this script | ||
REM as environment variables, except password | ||
|
||
REM user-defined variables | ||
SET remote_tun_ip=10.7.0.1 | ||
SET dns_server=8.8.8.8 | ||
SET orig_intf="Local Area Connection" | ||
|
||
REM exclude remote server in routing table | ||
for /F "tokens=3" %%* in ('route print ^| findstr "\<0.0.0.0\>"') do set "orig_gw=%%*" | ||
route add %server% %orig_gw% metric 5 > NUL | ||
|
||
REM configure IP address and MTU of VPN interface | ||
netsh interface ip set interface %orig_intf% ignoredefaultroutes=enabled > NUL | ||
netsh interface ip set address name="%intf%" static %tunip% 255.255.255.0 > NUL | ||
netsh interface ipv4 set subinterface "%intf%" mtu=%mtu% > NUL | ||
|
||
REM change routing table | ||
ECHO changing default route | ||
netsh interface ipv4 add route 128.0.0.0/1 "%intf%" %remote_tun_ip% metric=6 > NUL | ||
netsh interface ipv4 add route 0.0.0.0/1 "%intf%" %remote_tun_ip% metric=6 > NUL | ||
ECHO default route changed to %remote_tun_ip% | ||
|
||
REM change dns server | ||
netsh interface ip set dns name="%intf%" static %dns_server% > NUL | ||
|
||
ECHO %0 done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.