home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 42,189 of 42,547   
   Andy Burnelli to Mr. Man-wai Chang   
   Re: How can we programmatically distingu   
   30 Mar 23 11:25:06   
   
   XPost: alt.comp.os.windows-10, alt.comp.os.windows-11   
   From: nospam@nospam.net   
      
   Mr. Man-wai Chang wrote:   
      
   >> This is a general purpose solution _everyone_ can use instantly.   
   >> For free. To connect to any one of _thousands_ of free VPN servers.   
   >> Around the world. Perfectly legally. Maintained by a university in Japan.   
   >   
   > Define your "successful VPN connection"!! Ping test? Lantency value?   
   > Bandwidth test?   
      
   Good question.   
   The answer to that question is super simple.   
    It either connects or it doesn't connect.   
   That's all that matters for a "success" or "failure" of the connection.   
      
   But that's not the problem (AFAIK).   
   The problem is _how_ to insert that test into the existing batch command.   
      
   As I said prior, an "curl.exe icanhazip.com" comparison might work.   
   Likewise, your ping test should work.   
      
   All the icanhazip has to return is an IP address that's not yours.   
   All the ping has to return is a successful connection that's not yours.   
      
   But the "curl icanhazip.com" has to be _outside_ the batch file (AFAIK).   
   The ping also has to be _outside_ the batch file that connects to the VPN.   
      
   Doesn't it?   
      
   Maybe I don't understand batch coding (well, clearly I don't).   
   Otherwise I wouldn't be asking such a question of this newsgroup after all.   
      
   The problem, as I see it, is you can't run _anything_ in the batch that   
   starts the VPN because the _last_ thing it does is connect to the VPN.   
      
   All you can do is kill it.   
   If I add the ping, where do I put it in the batch file?   
      
    set vpncmd=C:\the\path\to\openvpn\bin\openvpn.exe   
    set configdir=C:\the\path\to\the\config-files\config\   
    cd %configdir%   
    set vpnserver=219.100.37.1.ovpn   
    set vpnserver=219.100.37.2.ovpn   
    set vpnserver=219.100.37.3.ovpn   
    "%vpncmd% %configdir%%vpnserver%   
      
   The _only_ thing you can do at that point is kill the connection.   
      
   If the connection works, the last few lines look like this:   
   (and this, by the way, is my actual connection for this post!)   
    2023-03-30 11:21:02 IPv4 MTU set to 1500 on interface 17 using    
   etIpInterfaceEntry()   
    2023-03-30 11:21:07 TEST ROUTES: 1/1 succeeded len=0 ret=1 a=0 u/d=up   
    2023-03-30 11:21:07 C:\Windows\system32\route.exe ADD 180.145.28.25 MASK   
   255.255.255.255 192.168.1.1   
    2023-03-30 11:21:07 ROUTE: CreateIpForwardEntry succeeded with    
   wForwardMetric1=35 and dwForwardType=4   
    2023-03-30 11:21:07 Route addition via IPAPI succeeded [adaptive]   
    2023-03-30 11:21:07 C:\Windows\system32\route.exe ADD 0.0.0.0 MASK 128.0.0.0   
   10.211.1.54   
    2023-03-30 11:21:07 ROUTE: CreateIpForwardEntry succeeded with    
   wForwardMetric1=25 and dwForwardType=4   
    2023-03-30 11:21:07 Route addition via IPAPI succeeded [adaptive]   
    2023-03-30 11:21:07 C:\Windows\system32\route.exe ADD 128.0.0.0 MASK   
   128.0.0.0 10.211.1.54   
    2023-03-30 11:21:07 ROUTE: CreateIpForwardEntry succeeded with    
   wForwardMetric1=25 and dwForwardType=4   
    2023-03-30 11:21:07 Route addition via IPAPI succeeded [adaptive]   
    2023-03-30 11:21:07 Initialization Sequence Completed   
      
   If the connection fails, it fails in _many_ ways... here's one:   
    2023-03-30 11:19:09 TCP/UDP: Preserving recently used remote address:   
   [AF_INET]58.143.149.135:1195   
    2023-03-30 11:19:09 Socket Buffers: R=[65536->65536] S=[65536->65536]   
    2023-03-30 11:19:09 UDP link local: (not bound)   
    2023-03-30 11:19:09 UDP link remote: [AF_INET]58.143.149.135:1195   
      
   But in _all_ cases, the _only_ thing you can do inside that batch   
   command window is a control-C (or an F4 to kill it more gracefully).   
      
   There's nothing else you _can_ do inside that batch window (AFAIK).   
   Hence, the problem (for me) is _where_ to put the ping test?   
      
   In summary, when you have a batch file that connects to a VPN server   
   (see above batch file), there's _nothing_ that I know of that you   
   can do after the connection in the command window that pops up.   
      
   It's not hard to manually determine success in a _different_   
   window because a ping or curl icanhazip needs to simply report   
   back a different IP address than what you happen to know is yours.   
      
   But where do you put the test for a successful VPN connection   
   if you want it to happen as part of the original batch command?   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca