Closed partisansb closed 1 year ago
Hi @partisansb
You would start here https://github.com/Dragon2fly/vpngate-with-proxy/blob/3a2b067c3146a8ece7233e83f470696c77418bd6/vpnproxy_tui.py#L489
Add your setting to the file before writing it out to .ovpn or before the OpenVPN is called.
can someone write me a script that automatically reconnects if the connection is lost like vpngate client after a while?
hi @bomayso
Just add your option here
extra_option = ['keepalive 5 30\r\n', # prevent connection drop due to inactivity timeout
'%s' % ('connect-retry 2\r\n' if self.proto == 'tcp' else ''),
'resolv-retry 2\r\n',
]
The options that control the reconnection are the followings:
--connect-retry n [max]
Wait n seconds between connection attempts (default=5). Repeated reconnection attempts are slowed down after 5 retries per remote by doubling the wait time after each unsuccessful attempt. The optional argument max specifies the maximum value of wait time in seconds at which it gets capped (default=300).
--connect-retry-max n
n specifies the number of times each --remote or <connection> entry is tried. Specifying n as one would try each entry exactly once. A successful connection resets the counter. (default=unlimited).
Bản thân script này đã có chức năng ý rồi hả bạn, tại test thử ngắt mạng đi thì không thấy nó tự kết nối.
Mặc định openvpn sẽ retry vô hạn. Nhưng chương trình này chỉ cho kết nối lại tối đa 3 lần nếu lỗi ở server vpn. Còn những lỗi ở máy bạn hay do đường truyền bị ngắt thì chương trình sẽ dừng luôn nhé. Việc thử lại quá nhiều lần sẽ dẫn đến nguy cơ bị block ở proxy hay firewall.
Số lần retry tối đa https://github.com/Dragon2fly/vpngate-with-proxy/blob/3a2b067c3146a8ece7233e83f470696c77418bd6/vpnproxy_tui.py#L116
Code check điều kiện retry khi kết nối fail. Nếu không thỏa cái if
này thì sẽ dừng kết nối.
https://github.com/Dragon2fly/vpngate-with-proxy/blob/3a2b067c3146a8ece7233e83f470696c77418bd6/vpnproxy_tui.py#L552
Hi, I've customised your cli script so it can run int he background automatically at start up.
I'm not so familiar with the python code you have used so how would I go about adding it...
I tried :
vpn_file = vpn_list[ranked[chose]]."/nredirect-gateway def1".write_file()
But it didn't work...
Thanks for your time, I've been using this script for a long time now and love it, just want to make it work better for me, thank you.
hi @partisansb
You could try to add your line here
extra_option = ['keepalive 5 30\r\n', # prevent connection drop due to inactivity timeout
'%s' % ('connect-retry 2\r\n' if self.proto == 'tcp' else ''),
'resolv-retry 2\r\n',
'redirect-gateway def1\r\n' # <--- added gateway redirecting option
]
Sorry in the delay getting back to you. I'm getting getting a connection and the script runs without errors, but my vm's are not getting a browser connection though it... Where can I check the .ovpn file thats being made?
Thanks
This is working as it should thank you
Then, just use your
dns
to do what ever needed with your firewall.Perhaps, you should write about your use-case somewhere for other people to follow.
Thanks :)
Originally posted by @Dragon2fly in https://github.com/Dragon2fly/vpngate-with-proxy/issues/2#issuecomment-266325359
I'm trying to achieve the same thing as this person here, but having issues. I think my issue might be slightly different however as I am using Debian VM rather than Fedora VM.
I am able to get a connection, however other App VM's connecting through the vpn can't get web browser access. Does you're script create a .ovpn config file? As I need to add the setting of "redirect-gateway def1" to it somehow.
Where would I go about doing that? Many thanks