Dragon2fly / vpngate-with-proxy

vpn gate client for linux, be able to connect to open vpn server through proxy
GNU General Public License v2.0
249 stars 71 forks source link

Error to run on encode #16

Closed lucasduete closed 6 years ago

lucasduete commented 7 years ago

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)

Dragon2fly commented 7 years ago

Thank you for reporting an error. Can you name which OS are you using? Is it the first time you encounter this error?

lucasduete commented 7 years ago

it's the first time that i have this error, i'm using the elementary OS 0.4 Loki, it is based in the kernel of Ubuntu 16.04.02 LTS

Dragon2fly commented 7 years ago

Can you reproduce this error? If yes, what steps that you have taken?

lucasduete commented 7 years ago

to install i use : $sudo apt install python-requests openvpn resolvconf python-urwid wmctrl realpath gir1.2-appindicator3-0.1 gir1.2-notify-0.7 python-gobject git $git clone https://github.com/Dragon2fly/vpngate-with-proxy.git

to run i use $cd vpngate-with-proxy $./run tui

i test this but returned the same error : $./run clt

Dragon2fly commented 7 years ago

i test this but returned the same error : $./run clt

Do you mean $./run cli?

Does this error happened for every server and every times that you try to connect? Currently I have no clue how it could happen. The error means that it read the output of openvpn process and failed to decode a character. And since it reads line by line, the number of 59274 makes no sense. No line could have that many character.

lucasduete commented 7 years ago

I teste if the error appears when i use the script in a network with proxy and not return concret response. After i test with a script for execute many times the code, some times it's works but usually not. For last i try this:

./run tui >> error.txt

Traceback (most recent call last):
  File "vpnproxy_tui.py", line 1082, in <module>
    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)

the result in the error.txt is :

cat error.txt

#!/bin/bash

# allow running from anywhere
# when making an alias in .bashrc or /etc/environment: vpn="path/to/./run"

dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "$(dirname "$(realpath "$0")")";
echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"

user_home=($HOME)
type=$1
arg=$2

if [ "$type" == "cli" ]; then
    sudo python vpnproxy_cli.py $user_home $arg
else
    if [ "$type" != "tui" ]; then
        arg=$type
    fi

    # check if this os is *buntu and launch vpn_indicator
    os_id=`cat /proc/version`
    target="buntu"
    test "${os_id#*$target}" != "$os_id" && stdbuf -oL python vpn_indicator.py > logs/indicator.log &

    sleep 0.2
    sudo python vpnproxy_tui.py $user_home $arg
fi
Dragon2fly commented 7 years ago

`the result in the error.txt is : cat error.txt

You copy the wrong content. That is the content of cat run, not cat error.txt. Also ./run tui >> error.txt doesn't redirect the stderr to file.

Please try the following 2 lines. It's redirect both stdout and stderr to file.

$./run cli > error_cli.txt 2>&1
$./run tui > error_tui.txt 2>&1

Then, please paste the content of these 2 files to here.

lucasduete commented 7 years ago

cat error_tui.txt

vpn_indicator.py:5234): Gtk-WARNING **: Theme parsing error: gtk-widgets.css:2045:14: 'min-height' is not a valid property name
(vpn_indicator.py:5234): Gtk-WARNING **: Theme parsing error: gtk-widgets.css:2046:13: 'min-width' is not a valid property name
(vpn_indicator.py:5234): Gtk-WARNING **: Theme parsing error: gtk-widgets.css:2051:13: 'min-width' is not a valid property name
Traceback (most recent call last):
  File "vpnproxy_tui.py", line 1082, in <module>
    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)

cat error_cli.txt

fetching data
using gate:  http://www.vpngate.net

Connection to gate http://www.vpngate.net failed

using gate:  http://p76ed4cd5.tokynt01.ap.so-net.ne.jp:16169
HTTPConnectionPool(host='p76ed4cd5.tokynt01.ap.so-net.ne.jp', port=16169): Max retries exceeded with url: /api/iphone/ (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x7f1a46597750>, 'Connection to p76ed4cd5.tokynt01.ap.so-net.ne.jp timed out. (connect timeout=3)'))
Connection to gate http://p76ed4cd5.tokynt01.ap.so-net.ne.jp:16169 failed

using gate:  http://103.1.249.67:29858
HTTPConnectionPool(host='103.1.249.67', port=29858): Max retries exceeded with url: /api/iphone/ (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x7f1a46597d90>, 'Connection to 103.1.249.67 timed out. (connect timeout=3)'))
Connection to gate http://103.1.249.67:29858 failed

using gate:  http://211.217.242.42:3230
HTTPConnectionPool(host='211.217.242.42', port=3230): Max retries exceeded with url: /api/iphone/ (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x7f1a46597c90>, 'Connection to 211.217.242.42 timed out. (connect timeout=3)'))
Connection to gate http://211.217.242.42:3230 failed

using gate:  http://zp018093.ppp.dion.ne.jp:36205
HTTPConnectionPool(host='zp018093.ppp.dion.ne.jp', port=36205): Max retries exceeded with url: /api/iphone/ (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x7f1a46597dd0>, 'Connection to zp018093.ppp.dion.ne.jp timed out. (connect timeout=3)'))
Connection to gate http://zp018093.ppp.dion.ne.jp:36205 failed

Failed to get VPN servers data
Check your network setting and proxy
Dragon2fly commented 7 years ago

Can you tell me what python version are you using. $ python --version Is your network behind a proxy? Can you access or any mirror through your browser?

log.write(m + '\n') UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 59274: ordinal not in range(128)

It is weird that m is unicode type not str type. For a temporary solution, please open file vpnproxy_tui.py, move to line 957 and change log.write(m + '\n') into log.write((m + '\n').encode('utf-8'))

Then, please test it again and paste the log to here.

lucasduete commented 7 years ago

yes, this solve my problem.