Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
(fix) new UI: 'pause' button not shown when the connection was perfor…
Browse files Browse the repository at this point in the history
…med by CLI
  • Loading branch information
stenya committed Dec 9, 2020
1 parent a3afa22 commit 740a378
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit 740a378

Please sign in to comment.