flamusdiu / python-pia

Commandline tool to auto configure PIA services
42 stars 9 forks source link

IndexError when attempting to automatically generate configurations #6

Closed cryzed closed 8 years ago

cryzed commented 8 years ago
cryzed@arch ~ sudo pia -a
[sudo] password for cryzed: 
Traceback (most recent call last):
  File "/usr/bin/pia", line 9, in <module>
    load_entry_point('pia==2.6', 'console_scripts', 'pia')()
  File "/usr/lib/python3.5/site-packages/pia/command_line.py", line 23, in main
    pia.run.run()
  File "/usr/lib/python3.5/site-packages/pia/run.py", line 60, in run
    [globals()[k]() for k, v in props.commandline.__dict__.items() if
  File "/usr/lib/python3.5/site-packages/pia/run.py", line 61, in <listcomp>
    not k == 'hosts' and getattr(props.commandline, k, None)]
  File "/usr/lib/python3.5/site-packages/pia/run.py", line 110, in auto_configure
    app.config(*getattr(openvpn, config))
  File "/usr/lib/python3.5/site-packages/pia/applications/appstrategy.py", line 74, in config
    self.app.config(config_id, filename)
  File "/usr/lib/python3.5/site-packages/pia/applications/hooks.py", line 153, in config
    "##port##": properties.props.port.split('/')[1],
IndexError: list index out of range

I am using NetworkManager and previously had an older PKGBUILD of private-internet-access-vpn installed.

flamusdiu commented 8 years ago

Well, oops. I broken it. This is what I get for trying to fix things when I haven't gotten enough sleep. =\ I'll see what I can do about this.

cryzed commented 8 years ago

Thank you!

flamusdiu commented 8 years ago

I have an Ingress event tomorrow but I'll try and fix it up this weekend. It's broken for me (different error) and I'll work something out.

oakular commented 8 years ago

I am also receiving the same error as the original when running pia -a as root

flamusdiu commented 8 years ago

Should be fixed now ... let me know.

maximbaz commented 8 years ago

@flamusdiu which commit should we test, f5c7ebcaaa747b277f5ad91cd97650b9a597020e (which is the latest pushed as of now)? It doesn't look like it contains a fix, and the issue is still reproducible... Maybe you forgot to push?

StickAndBindleGames commented 8 years ago

I'm still able to reproduce error on 2.6.1-1 here as well, fwiw.

flamusdiu commented 8 years ago

haha ... wth ... let me see why it did it pushed. I swear I did!

flamusdiu commented 8 years ago

Some how my changes got reverted ... let me fix it and I'll repush the version again

flamusdiu commented 8 years ago

Lets try that again ... since I apparently messed up my merge ... =P Should be right now.

flamusdiu commented 8 years ago

You will have to reinstall it though, I didn't change the version number .. just fixed my commits so it actually had the real comment that I missed.

maximbaz commented 8 years ago

I used commit 740438d7846b756b74ddbca2966f72b8ad6d14fe, the issue is still reproducible, the error is exactly the same as before in line 153, only now pia is 2.6.1:

$ sudo pia -a                          
Traceback (most recent call last):
  File "/usr/bin/pia", line 9, in <module>
    load_entry_point('pia==2.6.1', 'console_scripts', 'pia')()
  File "/usr/lib/python3.5/site-packages/pia/command_line.py", line 23, in main
    pia.run.run()
  File "/usr/lib/python3.5/site-packages/pia/run.py", line 60, in run
    [globals()[k]() for k, v in props.commandline.__dict__.items() if
  File "/usr/lib/python3.5/site-packages/pia/run.py", line 61, in <listcomp>
    not k == 'hosts' and getattr(props.commandline, k, None)]
  File "/usr/lib/python3.5/site-packages/pia/run.py", line 110, in auto_configure
    app.config(*getattr(openvpn, config))
  File "/usr/lib/python3.5/site-packages/pia/applications/appstrategy.py", line 74, in config
    self.app.config(config_id, filename)
  File "/usr/lib/python3.5/site-packages/pia/applications/hooks.py", line 153, in config
    "##port##": properties.props.port.split('/')[1],
IndexError: list index out of range
maximbaz commented 8 years ago

Does it not reproduce for you @flamusdiu ?

flamusdiu commented 8 years ago

grr ... one sec

StickAndBindleGames commented 8 years ago

If it's of any help, mine errors on ln 65 instead:

`Traceback (most recent call last):

File "/usr/bin/pia", line 9, in load_entry_point('pia==2.6.1', 'console_scripts', 'pia')() File "/usr/lib/python3.5/site-packages/pia/command_line.py", line 23, in main pia.run.run() File "/usr/lib/python3.5/site-packages/pia/run.py", line 60, in run [globals()[k]() for k, v in props.commandline.dict.items() if File "/usr/lib/python3.5/site-packages/pia/run.py", line 61, in not k == 'hosts' and getattr(props.commandline, k, None)] File "/usr/lib/python3.5/site-packages/pia/run.py", line 110, in auto_configure app.config(_getattr(openvpn, config)) File "/usr/lib/python3.5/site-packages/pia/applications/appstrategy.py", line 74, in config self.app.config(configid, filename) File "/usr/lib/python3.5/site-packages/pia/applications/hooks.py", line 65, in config content = re.sub(r'(remote\s..privateinternetaccess.com\s)(?:\d*)', '\g<1>' + properties.props.port.split('/')[1], content) IndexError: list index out of range`

flamusdiu commented 8 years ago

(sigh) let me see about these ... it seems to work in my virtual env but then it doesn't work when directly installed ... for the record I am getting this:

Traceback (most recent call last):
  File "/usr/bin/pia", line 9, in <module>
    load_entry_point('pia==2.6.1', 'console_scripts', 'pia')()
  File "/usr/lib/python3.5/site-packages/pia/command_line.py", line 23, in main
    pia.run.run()
  File "/usr/lib/python3.5/site-packages/pia/run.py", line 60, in run
    [globals()[k]() for k, v in props.commandline.__dict__.items() if
  File "/usr/lib/python3.5/site-packages/pia/run.py", line 61, in <listcomp>
    not k == 'hosts' and getattr(props.commandline, k, None)]
  File "/usr/lib/python3.5/site-packages/pia/run.py", line 110, in auto_configure
    app.config(*getattr(openvpn, config))
AttributeError: 'ApplicationStrategyOPENVPN' object has no attribute 'UKLondon'
flamusdiu commented 8 years ago

@StickAndBindleGames Can you fix your comment? The formatting is all messed up. =\

StickAndBindleGames commented 8 years ago

Ha, apologies. It was hating every formatting I tried.

maximbaz commented 8 years ago

The root cause seems to be exactly the same, properties.props.port.split('/') does not have two elements in the list. It can only be if the / character is completely missing from that string (see below a few examples), but I don't know what kind of data properties.props.port holds and where it gets filled in, and therefore why it does not have / in it.

@flamusdiu does it ring any bell? Or is it possible that we are missing some configuration simply, that you have in your virtual environment?


$ python
Python 3.5.1 (default, Mar  3 2016, 09:29:07) 
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> "a/b".split('/')
['a', 'b']
>>> "ab/".split('/')
['ab', '']
>>> "/ab".split('/')
['', 'ab']
>>> "ab".split('/')
['ab']
flamusdiu commented 8 years ago

Maybe. it's pulling that from the pia.conf file if you have the port configured (ie `tcp\8080') I guess I need to insure it's not empty.

Sorry, I was working on pacman hooks already for this before I got to head of myself. lol. Let me see about getting this fixed. Thanks!

maximbaz commented 8 years ago

I confirm, creating the /etc/private-internet-access/pia.conf (even as a complete copy of /etc/private-internet-access/pia-example.conf) fixes this issue, so can be considered as a workaround until this bug is resolved.

Thanks @flamusdiu!

flamusdiu commented 8 years ago

Ooo ... good find ... that's why I am not seeing it. Thanks!

flamusdiu commented 8 years ago

@maximbaz can you try it again?

Just a note: I need to change pia -r to attempt to remove all configurations. Seems it only removes all if you have no customized ones in pia.conf or ONLY the ones in pia.conf if configured. Not exactly how I want that to work. =\

maximbaz commented 8 years ago

It works now, pia -a generated all configurations as expected even without pia.conf file.

Thanks @flamusdiu!

flamusdiu commented 8 years ago

Np. Just push another change due to update-resolv-conf missing. Let me know if you find anything else.

StickAndBindleGames commented 8 years ago

Thanks for the update-resolv-conf fix. I was about to mention I had to manually make that executable to get the previous fix to work, but was trying to figure out if It was a local error with my setup before commenting (had previously been toying with the file).

All is working smoothly on my end now.

cryzed commented 8 years ago

Thank you!