Giter Club home page Giter Club logo

vpngate-with-proxy's Introduction

vpngate-with-proxy

VPN GATE client for linux

  • Be able to connect to open vpn servers at http://www.vpngate.net/en/ directly or through proxy
  • Auto add DNS to fix DNS leak.
  • Auto filter out dead VPN servers.
  • Can execute user defined script after vpn_tunnel is established or broken.

Note: Work on Debian and Redhat based system. Tested on Ubuntu, Raspbian, Fedora, Bunsen. New commit (2020/04/28) fixed it to work with python 3.6+ and only tested on Ubuntu 20.04.

I will wrap SoftEther_vpn later when I have time. You are welcome to fork this repo and wrap SoftEther_vpn yourself.

Indicator: is optional.

Tested on Ubuntu and is only enabled by default on Ubuntu.

For other unix os, you need to modify the run file and install packages below:

sudo apt-get install gir1.2-appindicator3-0.1 gir1.2-notify-0.7 python-gobject

If you have any trouble or request about the program, please make a new issue at https://github.com/Dragon2fly/vpngate-with-proxy/issues

Dependency:

  • python 2.7.x 3.6+: should already be shipped with your linux

Except python 2.7.x3.6+, all below dependencies should be automatically installed at first run.

  • openvpn: $ sudo apt-get install openvpn
  • python-requests: $ sudo apt-get install python-requests
  • python-urwid 1.3+: $ sudo apt-get install python-urwid , for tui version (terminal user interface)
  • wmctrl: $ sudo apt-get install wmctrl, for Indicator of tui version, use for focusing window from indicator.

How to use:

0. Pre-installation

  • If your network is behind a proxy
  $ export http_proxy="http://your_proxy:your_port"
  $ export https_proxy="http://your_proxy:your_port"
  • If you has just installed your os, please update your os for it to fetch packages list and know where to download other packages later.
$ sudo apt-get update && sudo apt-get upgrade
  • Please check the os clock and calendar if it is correct for openvpn authentication to work properly.

1. Installation:

Using git:

$ sudo apt-get install git
$ git clone https://github.com/Dragon2fly/vpngate-with-proxy.git

If your network is behind a proxy:

$ sudo -E apt-get install git
$ git clone https://github.com/Dragon2fly/vpngate-with-proxy.git

You can also download the zip file It contains the "vpngate-with-proxy" folder. Extract it into anywhere you want eg: $HOME.

user_script:

Within this folder, there should be a file user_script.sh. This file allow you to run extra commands to fit your need. You have to manually edit this file and don't change the file name. Commands are divided into 2 groups:

  • up: execute after vpn tunnel is established successfully.
  • down: execute after vpn tunnel is broken/terminated.

2. First run:

If you have configured system wide proxy or proxy in firefox, it'd better to turn it off. After vpn tunnel is established, the programs that use system wide proxy may failed to connect to the internet using your proxy.

Launch vpngate-with-proxy by

$ cd vpngate-with-proxy
$ ./run [arg]
  • arg could be either none or tui or cli.
  • vpnproxy_tui.py has better UI, colorful and easier to use. Run when arg is none or tui
  • vpnproxy_cli.py is normal terminal application, lightweight and is aim to run on server (RaspberryPi ?). Run when arg is cli

Then the program will first setup a configuration file config.ini by asking you for proxy if needed to connect to the Internet. After that it will show the default configuration of the program. Change any parameter to suit you and press Enter to continue. Next time launching this program, you won't see this configuration again. Either modify config.ini or check 5. Some notes

If no thing goes wrong, the vpn server's list will show up.

3. Interaction:

  • Connect to a specific vpn server by typing its index number (eg: 3) and then Enter. If nothing went wrong, a successfully message show up.

  • Your currently chosen server will be highlighted with dark blue color.

  • All connected servers before the current one is show in dark red color.

  • Change your desire setting by press the F# key corresponding to that setting. Hit that F# key again to discard all changes and close setting popup. Setting will only be saved when you hit <OK> or Enter.

    • F2: Proxy, use http proxy? address? port?
    • F3: DNS, change DNS when connecting to vpn? which dns to change to?
    • F4: Country, looking for a specific country or all that available?
    • F5: Sort by, sort these servers by what parameter?

  • Vpn command: As you mentioned above, give an index of the server then hit Enter will open a vpn tunnel from your to that server. And there are still some more.

    • r, refresh: fetch new server's data from vpngate.net or mirrors
    • restore: will restore your system DNS back to original one
    • kill: send SIGTERM to all openvpn processes
    • q: terminate vpn tunnel, then quit the program
    • log: check if current season is logged or not. Log file is vpn.log and is in the same folder with this program. Every time you start the program, log file is rewritten (old content will be lost) if log is turned on.
      • log on: turn on logging
      • log off: turn off logging
  • Other keys and combinations:

    • Up, Down, PgUp, PgDown: scroll the server list
    • F10 : toggle logging on/off
    • Esc : clear the text in any input form (vpn command, Proxy, Country)
    • Ctrl + F5: the same as r or refresh command
    • Ctrl + r : the same as restore command
    • Ctrl + k : the same as kill command
    • Ctrl + c : if connected to vpn server, terminate vpn tunnel, turn back to normal state. Else, quit the program

4. After VPN Tunnel is established successfully:

A successful connection doesn't mean you have access to the Internet. If you can access the Internet through selected vpn server, that doesn't mean you are totally safe.

  1. Check if you can access the Internet: * try browse some websites. Low score VPN servers tend to block you out of the Internet

  2. Check DNS leak:

If you are serious about privacy, this is necessary. DNS server knows the web addresses that you connected to, unless you type IP address directly.

To know your current DNS provider, https://www.dnsleaktest.com or https://ipleak.net

If DNS is not changed, make sure that you have turned off your system wide proxy and try again. While using the ethernet for vpn, connected to wifi may reset your DNS.

You could also use below command in Ubuntu to see trace route:

$ mtr -rw google.com

5. Some notes:

  • To view or change settings before the program fetches server's list, use one of below:
$ ./run config
$ ./run cli config
$ ./run tui config
  • (vpnproxy_cli.py only) To view or change settings at server's list: type Vpn command c or config then Enter

  • Ctrl+z: Try not to press this combination while program is running. It will not terminate the vpn tunnel nor kill the program properly. Which means iptable may be left messed up, DNS won't reset to original, you may be still in vpn.

  • The program only shows the last log line at the bottom of terminal. In fact, there is 20 last lines of the log. To view these lines, you just need to extend the high of the terminal window.

log

The log is shown up side down so the latest information will be in the highest place

  • If your terminal looks weird after program crashed or Ctrtl+z, $ reset would help

Troubleshoot:

If the program is unable to fetch new server data nor connect to any vpn server, your networking is not back to normal.

That is when restore, kill and log on command come in handy.

You will need to reset your network setting by:

  1. kill all openvpn processes
  2. $ sudo service network-manager restart

Restart your system or reconnect to wifi or ethernet will also help. If it still doesn't, your proxy may be offline or \etc\resolv.conf's content is incorrect. Ping your proxy from another computer to test. And double check \etc\resolv.conf

If your network is behind a proxy, there is a chance that your ip will be blocked. Testing if OpenVPN servers are dead or alive requires spamming many socket connection. Although the program has limited the number of socket connection per second, the proxy may think it is being DDoS. Search in the source code for test_interval and increase it a little bit.

If vpn_indicator is unresponsive, kill it by:

  $ kill -9 `pgrep -f vpn_indicator`

For other problems and bugs, please make an issue at https://github.com/Dragon2fly/vpngate-with-proxy/issues. State clearly the OS and what steps that you have taken that lead to the bug.

vpngate-with-proxy's People

Contributors

dragon2fly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vpngate-with-proxy's Issues

Error to run on encode

lucas@pc:~/vpngate-with-proxy$ ./run tui
Traceback (most recent call last):
File "vpnproxy_tui.py", line 1082, in
screen.run()
File "vpnproxy_tui.py", line 1018, in run
self.loop.run()
File "/usr/lib/python2.7/dist-packages/urwid/main_loop.py", line 278, in run
self._run()
File "/usr/lib/python2.7/dist-packages/urwid/main_loop.py", line 376, in _run
self.event_loop.run()
File "/usr/lib/python2.7/dist-packages/urwid/main_loop.py", line 682, in run
self._loop()
File "/usr/lib/python2.7/dist-packages/urwid/main_loop.py", line 715, in _loop
alarm_callback()
File "/usr/lib/python2.7/dist-packages/urwid/main_loop.py", line 164, in cb
callback(self, user_data)
File "vpnproxy_tui.py", line 665, in periodic_checker
self.status(self.ovpn.messages)
File "vpnproxy_tui.py", line 957, in status
log.write(m + '\n')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 59274: ordinal not in range(128)

Enhancement - show ip addresses and or names of available VPN servers

Hi Dragon2fly,

It would also be nice to have the ip address (and or name) of the VPN servers displayed in the console terminal output menu screen. This way we can determine which VPN server(s) we may have used before, or that we have tried and work better. Of course maybe recording the connection history of server ip addresses to a text file (or database file) and providing a quick compare to currently available servers option with a visual indicator (some character or symbol) showing which servers (if any) have been used before would help users as well?

FYI: I also tried this in my Linux Mint 18.1 KDE system and it works well there as well. :)

Thank you again for providing this very useful tool.

Have a great day and night ...

Best regards to you and yours,
Phil
phd21

Very Nice Thank You - Questions and Features request.

Hi Dragon2fly,

First, thank you for providing this for everyone. I found this in the link below:
(http://www.webupd8.org/2017/02/easily-use-free-vpn-servers-from-vpn.html)

I tried this out on my Linux Mint KDE 17.3 system today, and it worked great. Nice touch with having the DNS option as well. I tested it with "ipleak.net".

Question(s):

  1. I noticed that it is only showing me TCP connections instead of both UDP and TCP servers that are available. Is there an option that I can set for using UDP ? I tried changing "Protocol" to "udp" and it did not find anything.

Feature Requests:

  1. A desktop GUI front-end application so that it does not need to run from the console terminal prompt window. (perhaps in QT or a Python GUI).

  2. Auto-reconnect option?

  3. Packaging an installer as a ".deb" file, or ".appimage", etc...

Thank you again...

Have a great day !

Phil
phd21

Errors when country VPN servers are unavailable that mess up console text display

Hi Dragon2fly and evadogstar,

I hope both of you and yours are doing well.

A couple of things:

1.) If you try to connect to a country VPN server that is not there, you get a lot errors that mess up the console text display. Could you please change the error routine for "country VPN not found" to send the errors to a text file with a date and time stamp, and perhaps reset the country code option to "all" and auto refresh? I have to hit "ctrl-c" to exit, then restart this to get a normal text display again...

2.) I like the "tui" interface, can you please add the listed VPN server IP addresses to its display too?

3.) I would still like a GUI front-end to this whenever you get a chance, let me know...

4.) When I run "python --version" from the console terminal prompt, the results is "Python 2.7.12", yet I do have python version 3 installed as well? If I type "python3 --version", the results is "Python 3.5.2". I assume that any applications will automatically look for an use whichever version they need, is this a false assumption? Or, is there some console terminal command to set a default for priority preference for python?

Thank you again for a wonderful vpngate application.

Best regards to you and yours...
Phil

Vpn got error, terminated Restore dns

Occurs when I try to connect to a server:

31 76.69 19 days 2weeks 1447316 tcp 995
Vpn command: user_script.sh: line 28: hostname: command not found 1/5
Error calling command line “dbus-launch --autolaunch=70c2c43711774be2b6238f1e2da3db0

failed to negotiate cipher with server. Add the server's cipher
('AES-128-CBC') to --data-ciphers (currently 'AES-256-GCM:AES-128-GCM:CHACHA20-POLY1305') if you
want to connect to this server.

OS: Arch Linux;

Please add SOCKS5 Proxy support

Please add SOCKS5 Proxy support to enable using Tor's local SOCKS5 Proxy at 127.0.0.1:9050 to route the VPN connection over Tor.

iptables rules that block non-VPN traffic

nice set of scripts, thanks !

it would be useful to have an option to setup iptables rules that guard traffic against non-VPN leakage. See https://github.com/sjakthol/vpngate-client/blob/master/vpngate-client , line 34 ff.

(i am still considering to use user_script.sh for this purpose, yet i see an issue with that too. That is, as i understand it, case "down" gets executed on both "VPN terminated" AND "VPN broken", so flushing iptables here is not what we want. We want it to be flushed on termination but exactly not in the event the VPN connection breaks.)

Cannot connect to vpngate mirror sites

vpngate.net is blocked by my ISP. There are mirror sites which can be accessible by my browser but I can't connect with vpngate-with-proxy. Here is the log of vpn.

Sat Feb 5 20:27:05 2022: Vpngate with proxy is started
using gate: http://www.vpngate.net
ConnectionTimeout
Connection to gate http://www.vpngate.net failed
using gate: http://213.136.92.167:13182
ConnectionError
Connection to gate http://213.136.92.167:13182 failed
using gate: http://78.142.193.246:33304
ConnectionError
Connection to gate http://78.142.193.246:33304 failed
using gate: http://172.107.219.42:32685
ConnectionError
Connection to gate http://172.107.219.42:32685 failed
using gate: http://222.255.11.117:54621
ConnectionError
Connection to gate http://222.255.11.117:54621 failed
using gate: http://i118-27-48-67.vpngate-sv.d.rspnet.jp:7458
ConnectionError
Connection to gate http://i118-27-48-67.vpngate-sv.d.rspnet.jp:7458 failed
using gate: http://118.105.213.20:23041
ConnectionError
Connection to gate http://118.105.213.20:23041 failed
Failed to get VPN servers data
Check your network setting and proxy

Linux Mint Issue

(vpn_indicator.py:17228): Gdk-CRITICAL **: 13:28:51.754: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
Traceback (most recent call last):
File "vpnproxy_tui.py", line 1090, in
screen = Display(vpn_connect)
File "vpnproxy_tui.py", line 605, in init
self.table = self.make_GUI() # list of lines, urwid.columns
File "vpnproxy_tui.py", line 801, in make_GUI
self.Udata.append(deepcopy(Ulabel))
File "/usr/lib/python2.7/copy.py", line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.7/copy.py", line 334, in _reconstruct
state = deepcopy(state, memo)
File "/usr/lib/python2.7/copy.py", line 163, in deepcopy
y = copier(x, memo)
File "/usr/lib/python2.7/copy.py", line 257, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.7/copy.py", line 190, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.7/copy.py", line 352, in _reconstruct
y.append(item)
File "/usr/local/lib/python2.7/dist-packages/urwid/monitored_list.py", line 384, in append
rval = super(MonitoredFocusList, self).append(item)
File "/usr/local/lib/python2.7/dist-packages/urwid/monitored_list.py", line 30, in call_modified_wrapper
self._modified()
File "/usr/local/lib/python2.7/dist-packages/urwid/container.py", line 1816, in _contents_modified
self._selectable = any(w.selectable() for w, o in self.contents)
File "/usr/local/lib/python2.7/dist-packages/urwid/container.py", line 1906, in _get_contents
return self._contents
AttributeError: 'Columns' object has no attribute '_contents'

Add redirect-gateway setting to config file

          Sorry for misunderstanding you. So you need the DNS **appeared** in the `user_script.sh` so that you can inform your **firewall** to **allow connections** to them. It is better not to change the source code of main program since other people don't have that need. Instead, let do entire job within `user_script.sh` only. The below code will parse DNS from `config.ini`, remove `,` and store the result in `dns` variable.
dns=$(cat config.ini | grep -o -P '(?<=^dns = ).*')
dns="${dns//,/}"
echo $dns

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 #2 (comment)

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

Cannot connect to vpngate mirror sites

Same issue as #35
Tried using a proxy - terminal pings it and gets [alive], but still fails to fetch the list (vpngate.net is blocked for me)
I can manually download the list, how should I save it (and does it need re-formatting?)?
App also asked me to install KDE Wallet which I cancelled, is it crucial for the app to work?

Error on Run

I'm doing neither ./run [arg] nor ./vpnproxy_tui.py and ./vpnproxy_cli.py has error. Thank you

File "vpnproxy_cli.py", line 95
    print ctext('Warning: ', 'yB'),
              ^
SyntaxError: invalid syntax

File "vpnproxy_tui.py", line 167
    print '\n' + '_' * 12 + ctext(' First time config ', 'gB') + '_' * 12 + '\n'
             ^
SyntaxError: invalid syntax

How to access local domain with VPN?

Currently, I use dnsmasq to forward all domain with TLD .dev to my local ip 127.0.0.1, everything is working fine. But when I connect to a VPN, I cannot open my domain.dev, please help me to config it.

Not sure what is going on, but recently the list of vpngate servers seems confused?

Hi Dragon2fly,

I hope you and yours are doing well.

Not sure what is going on, but recently the list of vpngate servers seems confused? When I select a server like one in the US, it sometimes shows Japan when I check it through "ipleak.net", yet I can select another US server and it works? This did not happen before a couple weeks ago? This is using the "vpngate with proxy" not the "vpnwp_v2". Does the "vpnwp_v2" have a gui interface?

Is this because of the vpngate system, retrieved server lists, vpngate with proxy, or something from my system?

Best regards,
Phil
[email protected]

Cannot Open TAP/TUN Archlinux

Hello,

I installed all the dependencies on archlinux - I can't seem to connect. I have tried various methods of connecting (including trying to do this manually via openvpn) however I cannot connect. Your app is the first one that gave me the error message. Please see below:

image

I want to connect to Russian Servers to play LostArk.

Bug: Taskbar indicator -> show main

Vpn command: Traceback (most recent call last):                                                       ↑↓ page: 1/6
  File "vpn_indicator.py", line 317, in change_focus                    
    call(['wmctrl', '-a', 'vpngate-with-proxy'])                        
  File "/usr/lib/python2.7/subprocess.py", line 168, in call            
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)leted 1
  File "/usr/lib/python2.7/subprocess.py", line 1025, in _execute_child
    raise child_exceptionpngate.net
OSError: [Errno 2] No such file or directory

No any process named vpngate-with-proxy

sudo ps -aux | grep vpn*
  8458  0.0  0.0  14372    28 pts/0    S    11:37   0:00 /bin/bash /home/virgosun/Documents/vpngate-with-proxy/run
root      8460  0.0  0.4 647504  9228 pts/0    Sl   11:37   0:12 python vpn_indicator.py
root     10247  0.0  0.1  60704  2644 pts/0    S+   19:22   0:00 sudo /home/virgosun/Documents/vpngate-with-proxy/run
root     10251  0.0  0.1  14372  2204 pts/0    S+   19:22   0:00 /bin/bash /home/virgosun/Documents/vpngate-with-proxy/run
root     10262  0.0  0.1  60704  2652 pts/0    S+   19:22   0:00 sudo python vpnproxy_tui.py /home/virgosun
root     10266  0.7  2.5 1118156 46744 pts/0   Sl+  19:22   0:01 python vpnproxy_tui.py /home/virgosun

Indicator not show in gnome

I run vpn_indicator.py in background, so there is a notify at gnome top bar when the vpn connected.
But I dont see this Image of Yaktocat

Fix vpn_indicator' vpn status "Season:" -> "Session:"

After starting vpngate, vpn_indicator informs the status of the vpn connected. But a misspelling has catched my eyes. It is "Season:" maybe for "Session:"
To fix it, at first terminate vpn-gate, and open & edit indicator_config file, ~/vpngate-with-proxy/vpn_indicator.py.
Substitute "Season:" -> "Session:"
That's it :)

Season_before_edit_file

Session_after_edit_file

vpn_status_2022-10-06 16-03-33

Run Open VPN as a different user

Hi Dragon2fly,

Me again, the problem I'm facing now is the script needs to be run as qvpn user to get through the dns on the system... I tried adding
command = ['sg qvpn -c openvpn', '--config', ovpn]
but it failed.

Where can I preappend sg qvpn -c to the openvpn command? Thanks

Notify version check issue

Hi Dragon2fly,
First let me tell you I love this handy tool!
Also really waiting for the implementation of softether for it!

Anyway at the moment I am running into a little issue:

user@acer:~/vpngate-with-proxy$ `./run tui`
Traceback (most recent call last):
  File "vpnproxy_tui.py", line 21, in <module>
    from vpn_indicator import InfoClient
  File "/home/user/vpngate-with-proxy/vpn_indicator.py", line 22, in <module>
    gi.require_version('Notify', '0.7')
  File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 100, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Notify not available
user@acer:~/vpngate-with-proxy$ 

and here is the line in question; I commented it as a quick workaround but can you suggest anything better?
#gi.require_version('Notify', '0.7')

then I can ./run tui, but after the initial configuration I click Enter, an rerun it, I get

`Lack of Gtk related modules! VPN indicator will not run!
 You should try "sudo apt-get install gir1.2-appindicator3-0.1 python-gobject`

althought these dependencies are met!

(my distro = BunsenLab, latest version, always kept up to date; it is based on Debian Jessie
Thanks a lot

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.