Skip to content

Commit

Permalink
Network: Fix bug when reconnecting with OpenVPN
Browse files Browse the repository at this point in the history
This fixes a major bug where OpenVPN doesn't work on a reconnect. This
bug is not introduced by this PR, it's already present on master. The
problem was that we only got a new connect configuration in the case
of WireGuard, which is not right. We should always get a new connect
configuration as '/disconnect' is called.
  • Loading branch information
jwijenbergh committed Jun 22, 2022
1 parent 7ec6ca8 commit 247cd00
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions eduvpn/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .app import Application
from .server import ConfiguredServer as Server, Protocol
from .utils import translated_property
from .interface.event import on_start_connection, on_chosen_profile

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -119,37 +120,27 @@ def connect(app: Application) -> NetworkState:
assert app.current_network_uuid is not None

server = app.session_state.server
if storage.get_connection_protocol(server) is Protocol.WIREGUARD:
from eduvpn.interface.event import on_start_connection, on_chosen_profile
oauth_session = storage.load_oauth_session(server)
server_info = app.server_db.get_server_info(server)
metadata = storage.get_current_metadata(server.oauth_login_url)
assert metadata is not None
profile_id = metadata[6]
profile = server_info.get_profile(oauth_session, profile_id)
if profile is None:
# Profile was removed, redo profile choice.
on_start_connection(
app,
server,
oauth_session,
)
else:
on_chosen_profile(
app,
server,
oauth_session,
profile,
)
return DisconnectedState()
oauth_session = storage.load_oauth_session(server)
server_info = app.server_db.get_server_info(server)
metadata = storage.get_current_metadata(server.oauth_login_url)
assert metadata is not None
profile_id = metadata[6]
profile = server_info.get_profile(oauth_session, profile_id)
if profile is None:
# Profile was removed, redo profile choice.
on_start_connection(
app,
server,
oauth_session,
)
else:
nm.activate_connection(
client,
app.current_network_uuid,
partial(on_any_update_callback, app),
on_chosen_profile(
app,
server,
oauth_session,
profile,
)

return ConnectingState()
return DisconnectedState()


def disconnect(app: Application, *, update_state=True) -> NetworkState:
Expand Down

0 comments on commit 247cd00

Please sign in to comment.