fixed nil pointer dererence in main
This commit is contained in:
parent
feedff3f04
commit
f87db5ac41
29
cmd/main.go
29
cmd/main.go
@ -145,6 +145,7 @@ func server_main(ctl_addrs []string, rpc_addrs []string, cfg *ServerConfig) erro
|
|||||||
var s *hodu.Server
|
var s *hodu.Server
|
||||||
var ctltlscfg *tls.Config
|
var ctltlscfg *tls.Config
|
||||||
var rpctlscfg *tls.Config
|
var rpctlscfg *tls.Config
|
||||||
|
var ctl_prefix string
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if cfg != nil {
|
if cfg != nil {
|
||||||
@ -156,16 +157,19 @@ func server_main(ctl_addrs []string, rpc_addrs []string, cfg *ServerConfig) erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if len(ctl_addrs) <= 0 {
|
if len(ctl_addrs) <= 0 {
|
||||||
ctl_addrs = cfg.CTL.Service.Addrs
|
ctl_addrs = cfg.CTL.Service.Addrs
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len(rpc_addrs) <= 0) {
|
if len(rpc_addrs) <= 0 {
|
||||||
rpc_addrs = cfg.RPC.Service.Addrs
|
rpc_addrs = cfg.RPC.Service.Addrs
|
||||||
}
|
}
|
||||||
if (len(rpc_addrs) <= 0) {
|
|
||||||
|
ctl_prefix = cfg.CTL.Service.Prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(rpc_addrs) <= 0 {
|
||||||
return fmt.Errorf("no rpc service addresses specified")
|
return fmt.Errorf("no rpc service addresses specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +178,7 @@ func server_main(ctl_addrs []string, rpc_addrs []string, cfg *ServerConfig) erro
|
|||||||
ctl_addrs,
|
ctl_addrs,
|
||||||
rpc_addrs,
|
rpc_addrs,
|
||||||
&AppLogger{id: "server", out: os.Stderr},
|
&AppLogger{id: "server", out: os.Stderr},
|
||||||
cfg.CTL.Service.Prefix,
|
ctl_prefix,
|
||||||
ctltlscfg,
|
ctltlscfg,
|
||||||
rpctlscfg)
|
rpctlscfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -195,6 +199,7 @@ func client_main(ctl_addrs []string, rpc_addrs []string, peer_addrs []string, cf
|
|||||||
var c *hodu.Client
|
var c *hodu.Client
|
||||||
var ctltlscfg *tls.Config
|
var ctltlscfg *tls.Config
|
||||||
var rpctlscfg *tls.Config
|
var rpctlscfg *tls.Config
|
||||||
|
var ctl_prefix string
|
||||||
var cc hodu.ClientConfig
|
var cc hodu.ClientConfig
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -207,28 +212,30 @@ func client_main(ctl_addrs []string, rpc_addrs []string, peer_addrs []string, cf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if len(ctl_addrs) <= 0 { ctl_addrs = cfg.CTL.Service.Addrs }
|
if len(ctl_addrs) <= 0 { ctl_addrs = cfg.CTL.Service.Addrs }
|
||||||
if len(rpc_addrs) <= 0 { rpc_addrs = cfg.RPC.Endpoint.Addrs }
|
if len(rpc_addrs) <= 0 { rpc_addrs = cfg.RPC.Endpoint.Addrs }
|
||||||
|
ctl_prefix = cfg.CTL.Service.Prefix
|
||||||
|
|
||||||
|
cc.ServerSeedTimeout = cfg.RPC.Endpoint.SeedTimeout
|
||||||
|
cc.ServerAuthority = cfg.RPC.Endpoint.Authority
|
||||||
|
}
|
||||||
|
|
||||||
if len(rpc_addrs) <= 0 {
|
if len(rpc_addrs) <= 0 {
|
||||||
return fmt.Errorf("no rpc server address specified")
|
return fmt.Errorf("no rpc server address specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc.ServerAddrs = rpc_addrs
|
||||||
|
cc.PeerAddrs = peer_addrs
|
||||||
|
|
||||||
c = hodu.NewClient(
|
c = hodu.NewClient(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
ctl_addrs,
|
ctl_addrs,
|
||||||
&AppLogger{id: "client", out: os.Stderr},
|
&AppLogger{id: "client", out: os.Stderr},
|
||||||
cfg.CTL.Service.Prefix,
|
ctl_prefix,
|
||||||
ctltlscfg,
|
ctltlscfg,
|
||||||
rpctlscfg)
|
rpctlscfg)
|
||||||
|
|
||||||
cc.ServerAddrs = rpc_addrs
|
|
||||||
cc.PeerAddrs = peer_addrs
|
|
||||||
cc.ServerSeedTimeout = cfg.RPC.Endpoint.SeedTimeout
|
|
||||||
cc.ServerAuthority = cfg.RPC.Endpoint.Authority
|
|
||||||
|
|
||||||
c.StartService(&cc)
|
c.StartService(&cc)
|
||||||
c.StartCtlService() // control channel
|
c.StartCtlService() // control channel
|
||||||
c.StartExtService(&signal_handler{svc:c}, nil) // signal handler task
|
c.StartExtService(&signal_handler{svc:c}, nil) // signal handler task
|
||||||
|
Loading…
x
Reference in New Issue
Block a user