TUN-3261: Display connections on UI for free classic tunnels

This commit is contained in:
Rachel Williams 2020-08-17 15:43:20 -07:00 committed by Areg Harutyunyan
parent fee13dc62f
commit 71b98e6111
1 changed files with 6 additions and 1 deletions

View File

@ -500,7 +500,7 @@ func RegisterTunnel(
serverInfoPromise := tunnelrpc.TunnelServer{Client: tunnelServer.Client}.GetServerInfo(ctx, func(tunnelrpc.TunnelServer_getServerInfo_Params) error { serverInfoPromise := tunnelrpc.TunnelServer{Client: tunnelServer.Client}.GetServerInfo(ctx, func(tunnelrpc.TunnelServer_getServerInfo_Params) error {
return nil return nil
}) })
LogServerInfo(serverInfoPromise.Result(), connectionID, config.Metrics, logger) LogServerInfo(serverInfoPromise.Result(), connectionID, config.Metrics, logger, config.TunnelEventChan)
registration := tunnelServer.RegisterTunnel( registration := tunnelServer.RegisterTunnel(
ctx, ctx,
config.OriginCert, config.OriginCert,
@ -588,6 +588,7 @@ func LogServerInfo(
connectionID uint8, connectionID uint8,
metrics *TunnelMetrics, metrics *TunnelMetrics,
logger logger.Service, logger logger.Service,
tunnelEventChan chan<- ui.TunnelEvent,
) { ) {
serverInfoMessage, err := promise.Struct() serverInfoMessage, err := promise.Struct()
if err != nil { if err != nil {
@ -599,6 +600,10 @@ func LogServerInfo(
logger.Errorf("Failed to retrieve server information: %s", err) logger.Errorf("Failed to retrieve server information: %s", err)
return return
} }
// If launch-ui flag is set, send connect msg
if tunnelEventChan != nil {
tunnelEventChan <- ui.TunnelEvent{Index: connectionID, EventType: ui.Connected, Location: serverInfo.LocationName}
}
logger.Infof("Connected to %s", serverInfo.LocationName) logger.Infof("Connected to %s", serverInfo.LocationName)
metrics.registerServerLocation(uint8ToString(connectionID), serverInfo.LocationName) metrics.registerServerLocation(uint8ToString(connectionID), serverInfo.LocationName)
} }