From 740a378a88f6c8e6d87d2be6078f70a3b7b6aee3 Mon Sep 17 00:00:00 2001 From: Alexandr Stelnykovych Date: Wed, 9 Dec 2020 16:46:10 +0200 Subject: [PATCH] (fix) new UI: 'pause' button not shown when the connection was performed by CLI --- protocol/protocol.go | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/protocol/protocol.go b/protocol/protocol.go index c72059e..3106efe 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -356,6 +356,21 @@ func (p *Protocol) processRequest(conn net.Conn, message string) { log.Info("[<--] ", p.connLogID(conn), reqCmd.Command) + sendStateIfConnected := func(reqIdx int) { + vpnState := p._lastVPNState + if vpnState.State == vpn.CONNECTED { + p.sendResponse(conn, &types.ConnectedResp{ + TimeSecFrom1970: vpnState.Time, + ClientIP: vpnState.ClientIP.String(), + ServerIP: vpnState.ServerIP.String(), + VpnType: vpnState.VpnType, + ExitServerID: vpnState.ExitServerID, + ManualDNS: dns.GetLastManualDNS(), + IsCanPause: vpnState.IsCanPause}, + reqIdx) + } + } + switch reqCmd.Command { case "Hello": var req types.Hello @@ -395,17 +410,8 @@ func (p *Protocol) processRequest(conn net.Conn, message string) { if req.GetStatus == true { // send VPN connection state - vpnState := p._lastVPNState - if vpnState.State == vpn.CONNECTED { - p.sendResponse(conn, &types.ConnectedResp{ - TimeSecFrom1970: vpnState.Time, - ClientIP: vpnState.ClientIP.String(), - ServerIP: vpnState.ServerIP.String(), - VpnType: vpnState.VpnType, - ExitServerID: vpnState.ExitServerID, - ManualDNS: dns.GetLastManualDNS()}, - req.Idx) - } + sendStateIfConnected(req.Idx) + // send Firewall state if isEnabled, isPersistant, isAllowLAN, isAllowLanMulticast, err := p._service.KillSwitchState(); err == nil { p.sendResponse(conn, &types.KillSwitchStatusResp{IsEnabled: isEnabled, IsPersistent: isPersistant, IsAllowLAN: isAllowLAN, IsAllowMulticast: isAllowLanMulticast}, reqCmd.Idx) @@ -426,14 +432,7 @@ func (p *Protocol) processRequest(conn net.Conn, message string) { // send VPN connection state vpnState := p._lastVPNState if vpnState.State == vpn.CONNECTED { - p.sendResponse(conn, &types.ConnectedResp{ - TimeSecFrom1970: vpnState.Time, - ClientIP: vpnState.ClientIP.String(), - ServerIP: vpnState.ServerIP.String(), - VpnType: vpnState.VpnType, - ExitServerID: vpnState.ExitServerID, - ManualDNS: dns.GetLastManualDNS()}, - reqCmd.Idx) + sendStateIfConnected(reqCmd.Idx) } else if vpnState.State == vpn.DISCONNECTED { p.sendResponse(conn, &types.DisconnectedResp{Failure: false, Reason: 0, ReasonDescription: ""}, reqCmd.Idx) } else {