Fixed crach when no XDS Server connected.
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 24 Jan 2018 14:18:04 +0000 (15:18 +0100)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 24 Jan 2018 14:18:04 +0000 (15:18 +0100)
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
main.go

diff --git a/main.go b/main.go
index 72a9d22..668738c 100644 (file)
--- a/main.go
+++ b/main.go
@@ -389,6 +389,9 @@ func XdsConnInit(ctx *cli.Context) error {
        if err := XdsConfigGet(&xdsConf); err != nil {
                return cli.NewExitError("ERROR while getting XDS config: "+err.Error(), 1)
        }
+       if len(xdsConf.Servers) < 1 {
+               return cli.NewExitError("No XDS Server connected", 1)
+       }
        svrCfg := xdsConf.Servers[XdsServerIndexGet()]
        if (serverURL != "" && svrCfg.URL != serverURL) || !svrCfg.Connected {
                Log.Infof("Update XDS Server config: serverURL=%v, svrCfg=%v", serverURL, svrCfg)