russdill / juniper-vpn-py

Python Juniper VPN Authenticator
GNU Lesser General Public License v2.1
103 stars 80 forks source link

Actually terminate existing VPN sessions. #11

Open jlinton opened 8 years ago

jlinton commented 8 years ago

With some(?) versions of juniper, the existing code simply submits the continue button, which does not terminate existing connections. If only a single session is allowed, this results in the terminate connections page being redisplayed.

With this change, we select the first connection, clear the disabled attribute from the terminate button and then submit it. While this appears to be what the juniper client normally does, this behavior is only enabled with a new terminate option, as I'm not sure that if multiple sessions are allowed for the current user we want to be arbitrary terminating them.

It also seems that juniper may send invalid HTML that mechanize can't clearly parse. We fix this by removing the comma, and recreating the response.

Also, added a debug option which turns on some basic logging.

Signed-off-by: Jeremy Linton lintonrjeremy@gmail.com