mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated RemoteHost structure
This commit is contained in:
committed by
Dan Christian Bogos
parent
d6e9d13ef8
commit
c75482a6dc
@@ -45,7 +45,7 @@ var (
|
||||
certificatePath = cgrConsoleFlags.String("crt_path", "", "path to certificate for tls connection")
|
||||
keyPath = cgrConsoleFlags.String("key_path", "", "path to key for tls connection")
|
||||
caPath = cgrConsoleFlags.String("ca_path", "", "path to CA for tls connection(only for self sign certificate)")
|
||||
tls = cgrConsoleFlags.Bool("tls", false, "Tls connection")
|
||||
tls = cgrConsoleFlags.Bool("tls", false, "TLS connection")
|
||||
client *rpcclient.RpcClient
|
||||
)
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ func main() {
|
||||
if len(ldrCfg.LoaderCgrCfg().CachesConns) != 0 { // Init connection to CacheS so we can reload it's data
|
||||
if cacheS, err = rpcclient.NewRpcClient("tcp",
|
||||
ldrCfg.LoaderCgrCfg().CachesConns[0].Address,
|
||||
ldrCfg.LoaderCgrCfg().CachesConns[0].Tls, ldrCfg.TlsCfg().ClientKey,
|
||||
ldrCfg.LoaderCgrCfg().CachesConns[0].TLS, ldrCfg.TlsCfg().ClientKey,
|
||||
ldrCfg.TlsCfg().ClientCerificate, ldrCfg.TlsCfg().CaCertificate, 3, 3,
|
||||
time.Duration(1*time.Second), time.Duration(5*time.Minute),
|
||||
strings.TrimPrefix(ldrCfg.LoaderCgrCfg().CachesConns[0].Transport, utils.Meta),
|
||||
@@ -323,7 +323,7 @@ func main() {
|
||||
if len(ldrCfg.LoaderCgrCfg().SchedulerConns) != 0 { // Init connection to Scheduler so we can reload it's data
|
||||
if schedulerS, err = rpcclient.NewRpcClient("tcp",
|
||||
ldrCfg.LoaderCgrCfg().SchedulerConns[0].Address,
|
||||
ldrCfg.LoaderCgrCfg().SchedulerConns[0].Tls, ldrCfg.TlsCfg().ClientKey,
|
||||
ldrCfg.LoaderCgrCfg().SchedulerConns[0].TLS, ldrCfg.TlsCfg().ClientKey,
|
||||
ldrCfg.TlsCfg().ClientCerificate, ldrCfg.TlsCfg().CaCertificate, 3, 3,
|
||||
time.Duration(1*time.Second), time.Duration(5*time.Minute),
|
||||
strings.TrimPrefix(ldrCfg.LoaderCgrCfg().SchedulerConns[0].Transport, utils.Meta),
|
||||
|
||||
@@ -38,7 +38,7 @@ type RemoteHost struct {
|
||||
Address string
|
||||
Transport string
|
||||
Synchronous bool
|
||||
Tls bool
|
||||
TLS bool
|
||||
}
|
||||
|
||||
func (self *RemoteHost) loadFromJsonCfg(jsnCfg *HaPoolJsonCfg) error {
|
||||
@@ -55,7 +55,7 @@ func (self *RemoteHost) loadFromJsonCfg(jsnCfg *HaPoolJsonCfg) error {
|
||||
self.Synchronous = *jsnCfg.Synchronous
|
||||
}
|
||||
if jsnCfg.Tls != nil {
|
||||
self.Tls = *jsnCfg.Tls
|
||||
self.TLS = *jsnCfg.Tls
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ func (dps DispatcherProfiles) Sort() {
|
||||
type DispatcherHostConn struct {
|
||||
Address string
|
||||
Transport string
|
||||
Tls bool
|
||||
TLS bool
|
||||
}
|
||||
type DispatcherHost struct {
|
||||
Tenant string
|
||||
|
||||
@@ -44,14 +44,14 @@ func NewRPCPool(dispatchStrategy string, keyPath, certPath, caPath string, connA
|
||||
case <-time.After(ttl):
|
||||
return nil, errors.New("TTL triggered")
|
||||
}
|
||||
rpcClient, err = rpcclient.NewRpcClient("", "", rpcConnCfg.Tls, keyPath, certPath, caPath, connAttempts,
|
||||
rpcClient, err = rpcclient.NewRpcClient("", "", rpcConnCfg.TLS, keyPath, certPath, caPath, connAttempts,
|
||||
reconnects, connectTimeout, replyTimeout, rpcclient.INTERNAL_RPC, internalConn, lazyConnect)
|
||||
} else if utils.IsSliceMember([]string{utils.MetaJSONrpc, utils.MetaGOBrpc, ""}, rpcConnCfg.Transport) {
|
||||
codec := utils.GOB
|
||||
if rpcConnCfg.Transport != "" {
|
||||
codec = rpcConnCfg.Transport[1:] // Transport contains always * before codec understood by rpcclient
|
||||
}
|
||||
rpcClient, err = rpcclient.NewRpcClient("tcp", rpcConnCfg.Address, rpcConnCfg.Tls, keyPath, certPath, caPath,
|
||||
rpcClient, err = rpcclient.NewRpcClient("tcp", rpcConnCfg.Address, rpcConnCfg.TLS, keyPath, certPath, caPath,
|
||||
connAttempts, reconnects, connectTimeout, replyTimeout, codec, nil, lazyConnect)
|
||||
} else {
|
||||
return nil, fmt.Errorf("Unsupported transport: <%s>", rpcConnCfg.Transport)
|
||||
|
||||
@@ -271,7 +271,7 @@ cgrates.org,D1,*any,*string:Account:1001,2014-07-29T15:00:00Z,*first,,C1,*gt:Usa
|
||||
cgrates.org,D1,,,,*first,,C2,*lt:Usage:10,10,false,192.168.56.204,
|
||||
`
|
||||
dispatcherHosts = `
|
||||
#Tenant[0],ID[1],Address[2],Transport[3],Tls[4]
|
||||
#Tenant[0],ID[1],Address[2],Transport[3],TLS[4]
|
||||
cgrates.org,ALL1,127.0.0.1:2012,*json,true
|
||||
cgrates.org,ALL1,127.0.0.1:3012,*json,false
|
||||
`
|
||||
@@ -1643,12 +1643,12 @@ func TestLoadDispatcherHosts(t *testing.T) {
|
||||
&utils.TPDispatcherHostConn{
|
||||
Address: "127.0.0.1:2012",
|
||||
Transport: utils.MetaJSONrpc,
|
||||
Tls: true,
|
||||
TLS: true,
|
||||
},
|
||||
&utils.TPDispatcherHostConn{
|
||||
Address: "127.0.0.1:3012",
|
||||
Transport: utils.MetaJSONrpc,
|
||||
Tls: false,
|
||||
TLS: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -2618,7 +2618,7 @@ func (tps TPDispatcherHosts) AsTPDispatcherHosts() (result []*utils.TPDispatcher
|
||||
{
|
||||
Address: tp.Address,
|
||||
Transport: tp.Transport,
|
||||
Tls: tp.Tls,
|
||||
TLS: tp.TLS,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -2627,7 +2627,7 @@ func (tps TPDispatcherHosts) AsTPDispatcherHosts() (result []*utils.TPDispatcher
|
||||
hostsMap[tenantID].Conns = append(hostsMap[tenantID].Conns, &utils.TPDispatcherHostConn{
|
||||
Address: tp.Address,
|
||||
Transport: tp.Transport,
|
||||
Tls: tp.Tls,
|
||||
TLS: tp.TLS,
|
||||
})
|
||||
}
|
||||
for _, host := range hostsMap {
|
||||
@@ -2648,7 +2648,7 @@ func APItoModelTPDispatcherHost(tpDPH *utils.TPDispatcherHost) (mdls TPDispatche
|
||||
ID: tpDPH.ID,
|
||||
Address: conn.Address,
|
||||
Transport: conn.Transport,
|
||||
Tls: conn.Tls,
|
||||
TLS: conn.TLS,
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -2667,7 +2667,7 @@ func APItoDispatcherHost(tpDPH *utils.TPDispatcherHost) (dpp *DispatcherHost) {
|
||||
dpp.Conns[i] = &DispatcherHostConn{
|
||||
Address: conn.Address,
|
||||
Transport: conn.Transport,
|
||||
Tls: conn.Tls,
|
||||
TLS: conn.TLS,
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -412,6 +412,6 @@ type TPDispatcherHost struct {
|
||||
ID string `index:"1" re:""`
|
||||
Address string `index:"2" re:""`
|
||||
Transport string `index:"3" re:""`
|
||||
Tls bool `index:"4" re:""`
|
||||
TLS bool `index:"4" re:""`
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func NewSReplConns(conns []*config.RemoteHost, reconnects int,
|
||||
connTimeout, replyTimeout time.Duration) (sReplConns []*SReplConn, err error) {
|
||||
sReplConns = make([]*SReplConn, len(conns))
|
||||
for i, replConnCfg := range conns {
|
||||
if replCon, err := rpcclient.NewRpcClient("tcp", replConnCfg.Address, replConnCfg.Tls, "", "", "", 0, reconnects,
|
||||
if replCon, err := rpcclient.NewRpcClient("tcp", replConnCfg.Address, replConnCfg.TLS, "", "", "", 0, reconnects,
|
||||
connTimeout, replyTimeout, replConnCfg.Transport[1:], nil, true); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
|
||||
@@ -1209,7 +1209,7 @@ type TPDispatcherProfile struct {
|
||||
type TPDispatcherHostConn struct {
|
||||
Address string
|
||||
Transport string
|
||||
Tls bool
|
||||
TLS bool
|
||||
}
|
||||
|
||||
// TPDispatcherHostTPDispatcherHost is used in APIs to manage remotely offline DispatcherHost
|
||||
|
||||
Reference in New Issue
Block a user