Skip to content

Commit

Permalink
Implement detection of WireGuard connection on startup. This change s…
Browse files Browse the repository at this point in the history
…hould also fix issue #464.
  • Loading branch information
alvra committed Mar 21, 2022
1 parent e2bc098 commit 49eb869
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions eduvpn/nm.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,22 @@ def connection_status(client: 'NM.Client') -> Tuple[Optional[str], Optional['NM.

def get_connection_state() -> ConnectionState:
client = get_client()
connection = client.get_primary_connection()
if type(connection) != NM.VpnConnection:
uuid = get_uuid()
connections = [connection for connection
in client.get_active_connections()
if connection.get_uuid() == uuid]
if len(connections) == 1:
connection = connections[0]
else:
return ConnectionState.DISCONNECTED
connection_type = connection.get_connection_type()
if connection_type == 'vpn':
return ConnectionState.from_vpn_state(connection.get_vpn_state())
elif connection_type == 'wireguard':
return ConnectionState.from_active_state(connection.get_state())
else:
_logger.warning(f"connection of unknown type {connection_type}")
return ConnectionState.UNKNOWN
state = connection.get_state()
return ConnectionState.from_active_state(state)


def get_vpn_status(client: 'NM.Client') -> Tuple['NM.VpnConnectionState', 'NM.VpnConnectionStateReason']:
Expand Down

0 comments on commit 49eb869

Please sign in to comment.