Giter VIP home page Giter VIP logo

Comments (9)

Dragon2fly avatar Dragon2fly commented on July 30, 2024 2

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

self.max_retry = 3

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.

elif self.is_connected and 'Restart pause, ' in line and self.dropped_time <= self.max_retry:

from vpngate-with-proxy.

Dragon2fly avatar Dragon2fly commented on July 30, 2024

Hi @partisansb

You would start here

vpn_file = server.write_file(self.use_proxy, self.ip, self.port)

Add your setting to the file before writing it out to .ovpn or before the OpenVPN is called.

from vpngate-with-proxy.

bomayso avatar bomayso commented on July 30, 2024

can someone write me a script that automatically reconnects if the connection is lost like vpngate client after a while?
image

from vpngate-with-proxy.

Dragon2fly avatar Dragon2fly commented on July 30, 2024

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).

from vpngate-with-proxy.

bomayso avatar bomayso commented on July 30, 2024

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.

from vpngate-with-proxy.

partisansb avatar partisansb commented on July 30, 2024

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.

from vpngate-with-proxy.

Dragon2fly avatar Dragon2fly commented on July 30, 2024

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
                        ]

from vpngate-with-proxy.

partisansb avatar partisansb commented on July 30, 2024

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

from vpngate-with-proxy.

partisansb avatar partisansb commented on July 30, 2024

This is working as it should thank you

from vpngate-with-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.