theinvisible / openfortigui

VPN-GUI to connect to Fortigate-Hardware, based on openfortivpn
https://hadler.me/linux/openfortigui/
GNU General Public License v3.0
492 stars 54 forks source link

OTP dialog only visible after clicking "Disconnect" #12

Closed carloslima closed 6 years ago

carloslima commented 7 years ago

Clicking on “Connect” the vpn goes into “Connecting” state but stays stuck there.

If I then choose “Disconnect”, it disconnects AND only then shows the OTP dialog. As you might expect, entering the OTP at that point is of no help

Running Debian Stretch, Xfce + xmonad.

theinvisible commented 7 years ago

Hello,

please enable "Debug" for the affected VPN-profile and post the log output here.

The OTP-features is implemented by looking for specific keywords in the output of openfortivpn and intercepts the console input with a GUI dialog.

So maybe you have a setup running where we need to adjust the keywords.

Thanks & Cheers Rene

carloslima commented 7 years ago

Hi Rene!

I initially thought it was something related to xmonad but after trying with a xfwm4 and getting the same results I don't think it is the case.

Here are the debug logs:

~/.openfortigui> tail -f logs/openfortigui.log logs/vpn/VPN.log 
==> logs/openfortigui.log <==

==> logs/vpn/VPN.log <==

==> logs/openfortigui.log <==
Sep 21 01:33:59 openfortiGUI::Debug: "start-main::"
Sep 21 01:33:59 openfortiGUI::Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnAddVPN_clicked()
Sep 21 01:33:59 openfortiGUI::Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnDeleteVPN_clicked()
Sep 21 01:33:59 openfortiGUI::Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnEditVPN_clicked()
Sep 21 01:33:59 openfortiGUI::Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnCopyVPN_clicked()
Sep 21 01:33:59 openfortiGUI::Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnAddGroup_clicked()
Sep 21 01:33:59 openfortiGUI::Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnDeleteGroup_clicked()
Sep 21 01:33:59 openfortiGUI::Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnEditGroup_clicked()
Sep 21 01:33:59 openfortiGUI::Warning: QMetaObject::connectSlotsByName: No matching signal for on_btnCopyGroup_clicked()
Sep 21 01:33:59 openfortiGUI::Warning: QObject::connect: No such signal vpnLogger::finished()
Sep 21 01:33:59 openfortiGUI::Warning: QObject::connect: No such signal vpnLogger::finished()
Sep 21 01:33:59 openfortiGUI::Debug: tiConfVpnProfile::readVpnProfiles() -> vpnprofile found: "/home/carlos/.openfortigui/vpnprofiles/VPN.conf"
Sep 21 01:33:59 openfortiGUI::Debug: MainWindow::refreshVpnProfileList() -> vpnprofiles found:: "VPN"
Sep 21 01:33:59 openfortiGUI::Warning: inotify_add_watch("/etc/openfortigui/vpnprofiles") failed: "No such file or directory"
Sep 21 01:34:14 openfortiGUI::Debug: active-tab:: 0
Sep 21 01:34:14 openfortiGUI::Debug: Start vpn:: "VPN"
Sep 21 01:34:14 openfortiGUI::Debug: add logger "/home/carlos/.openfortigui/main.conf"
Sep 21 01:34:14 openfortiGUI::Debug: vpnManager::onClientConnected()
Sep 21 01:34:14 openfortiGUI::Debug: client api helo command:: 0 ::name:: "VPN"
Sep 21 01:34:14 openfortiGUI::Debug: tiConfVpnProfile::readVpnProfiles() -> vpnprofile found: "/home/carlos/.openfortigui/vpnprofiles/VPN.conf"
Sep 21 01:34:17 openfortiGUI::Debug: vpnClientConnection::sendCMD:: "VPN" :: 4
Sep 21 01:34:18 openfortiGUI::Debug: vpnManager::onClientVPNStatusChanged() "VPN" status 1
Sep 21 01:34:18 openfortiGUI::Debug: MainWindow::onClientVPNStatusChanged:: "VPN" ::status:: 1
Sep 21 01:34:18 openfortiGUI::Debug: tiConfVpnProfile::readVpnProfiles() -> vpnprofile found: "/home/carlos/.openfortigui/vpnprofiles/VPN.conf"
Sep 21 01:34:18 openfortiGUI::Debug: MainWindow::refreshVpnProfileList() -> vpnprofiles found:: "VPN"

==> logs/vpn/VPN.log <==
INFO:   Connected to gateway.

==> logs/openfortigui.log <==
Sep 21 01:34:41 openfortiGUI::Debug: stop vpn:: 0
Sep 21 01:34:41 openfortiGUI::Debug: vpnManager::stopVPN:: "VPN" :: 1
Sep 21 01:34:41 openfortiGUI::Debug: vpnClientConnection::sendCMD:: "VPN" :: 1

==> logs/vpn/VPN.log <==
2factor authentication token: 
==> logs/openfortigui.log <==
Sep 21 01:34:41 openfortiGUI::Debug: otprequest from vpnmanager

==> logs/vpn/VPN.log <==
INFO:   Setting ppp interface down.
INFO:   Restoring routes...
INFO:   Removing VPN nameservers...

==> logs/openfortigui.log <==
Sep 21 01:34:43 openfortiGUI::Debug: client disconnected:: "VPN"
Sep 21 01:34:43 openfortiGUI::Debug: vpnManager::onClientVPNStatusChanged() "VPN" status 0
Sep 21 01:34:43 openfortiGUI::Debug: MainWindow::onClientVPNStatusChanged:: "VPN" ::status:: 0
Sep 21 01:34:43 openfortiGUI::Debug: tiConfVpnProfile::readVpnProfiles() -> vpnprofile found: "/home/carlos/.openfortigui/vpnprofiles/VPN.conf"
Sep 21 01:34:43 openfortiGUI::Debug: MainWindow::refreshVpnProfileList() -> vpnprofiles found:: "VPN"
^C

It hangs at INFO: Connected to gateway. and all the logs after that happens after I click the "Disconnect" button.

Let me know if there is anything else I can do to help!

Thanks!

theinvisible commented 7 years ago

Hi,

thanks for your log and information.

This seems to be the problem then. OpenFortiGUI scans for "2factor" and opens the OTP-Dialog then. But somehow the log seems to be blocked by something or there is a "race condition" bug.

Is your connection slow maybe or you use mobile connection?

I will also test here again.

Cheers Rene

carloslima commented 7 years ago

Hi Rene!

Thanks for checking!

Depends on what you mean by slow. I'm not using mobile network. I'm across the globe from the vpn server (SE Asia - US), latency is about ~200ms. I get the same behavior from office and home networks.

Cheers! ~Carlos

theinvisible commented 7 years ago

Hi Carlos,

thanks for your help, this could really be the problem.

I will try now first to flush stdout right after the "2factor" output but will keep your pull request in mind.

Thanks & Cheers Rene

theinvisible commented 7 years ago

Version 0.3.4 is released with this possible fix, please give it a try.