xjasonlyu / tun2socks

tun2socks - powered by gVisor TCP/IP stack
https://github.com/xjasonlyu/tun2socks/wiki
GNU General Public License v3.0
2.85k stars 404 forks source link

[Feature] Multiple tun-post-up arguments #265

Closed SaeedDev94 closed 1 year ago

SaeedDev94 commented 1 year ago

Description

In windows after setting up tun interface (by running tun2socks itself) we need 3 commands to execute (netsh) :
1- For assigning IP address to tun 2- Set primary DNS 3- Set secondary DNS It seems that tun-post-up only accept 1 command and if i try to pass multiple commands with && It ignores the whole command and doesn't execute anything So please add a feature that we can pass multiple tun-post-up:
tun2socks ... -tun-post-up "%TUN_IP%" -tun-post-up "%TUN_FIRST_DNS%" -tun-post-up "%TUN_SECOND_DNS%" Or please add support for &&:
tun2socks ... -tun-post-up "%TUN_IP% && %TUN_FIRST_DNS% && %TUN_SECOND_DNS%"

Is this feature related to a specific bug?

No response

Do you have a specific solution in mind?

No response

xjasonlyu commented 1 year ago

You can use a cmd/bat script to do this. 😉

SaeedDev94 commented 1 year ago

You can use a cmd/bat script to do this. wink

Yeah, but since tun2socks is a blocking command and it creates the tun interface i have to run it in background Then i can't run netsh ... immediately to set ip or dns because the interface needs time to create
(Probably that's why -tun-post-up exists)
So i have to use something like timeout command (1 or 2 seconds) In this way i don't need -tun-post-up at all
(I wish if i could use tun-post-up to not using timeout command)

xjasonlyu commented 1 year ago

Oh, I mean you can use a cmd/bat script like: -tun-post-up <your_script.bat>

SaeedDev94 commented 1 year ago

Oh, I mean you can use a cmd/bat script like: -tun-post-up <your_script.bat>

Thanks, but I wrote a script (socks2vpn.bat) to make the setup a little bit easier
Your suggest may work, but I have to create another script which is not sounds good to me
Currently used the timeout command and it's working fine