mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 23:28:44 +05:00
Add script for create certificate for server and client and add test test tls connection
This commit is contained in:
committed by
Dan Christian Bogos
parent
43a979eb12
commit
f0cace6fc0
@@ -65,7 +65,8 @@ func (fS *FilterS) connStatS() (err error) {
|
||||
if fS.statSConns != nil { // connection was populated between locks
|
||||
return
|
||||
}
|
||||
fS.statSConns, err = NewRPCPool(rpcclient.POOL_FIRST, fS.cfg.ConnectAttempts, fS.cfg.Reconnects, fS.cfg.ConnectTimeout, fS.cfg.ReplyTimeout,
|
||||
fS.statSConns, err = NewRPCPool(rpcclient.POOL_FIRST, fS.cfg.TLSClientKey, fS.cfg.TLSClientCerificate,
|
||||
fS.cfg.ConnectAttempts, fS.cfg.Reconnects, fS.cfg.ConnectTimeout, fS.cfg.ReplyTimeout,
|
||||
fS.cfg.FilterSCfg().StatSConns, fS.statSChan, fS.cfg.InternalTtl)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,8 +28,9 @@ import (
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
func NewRPCPool(dispatchStrategy string, connAttempts, reconnects int, connectTimeout, replyTimeout time.Duration,
|
||||
rpcConnCfgs []*config.HaPoolConfig, internalConnChan chan rpcclient.RpcClientConnection, ttl time.Duration) (*rpcclient.RpcClientPool, error) {
|
||||
func NewRPCPool(dispatchStrategy, key_path, cert_path string, connAttempts, reconnects int,
|
||||
connectTimeout, replyTimeout time.Duration, rpcConnCfgs []*config.HaPoolConfig,
|
||||
internalConnChan chan rpcclient.RpcClientConnection, ttl time.Duration) (*rpcclient.RpcClientPool, error) {
|
||||
var rpcClient *rpcclient.RpcClient
|
||||
var err error
|
||||
rpcPool := rpcclient.NewRpcClientPool(dispatchStrategy, replyTimeout)
|
||||
@@ -43,13 +44,13 @@ func NewRPCPool(dispatchStrategy string, connAttempts, reconnects int, connectTi
|
||||
case <-time.After(ttl):
|
||||
return nil, errors.New("TTL triggered")
|
||||
}
|
||||
rpcClient, err = rpcclient.NewRpcClient("", "", "", "", connAttempts, reconnects, connectTimeout, replyTimeout, rpcclient.INTERNAL_RPC, internalConn, false)
|
||||
rpcClient, err = rpcclient.NewRpcClient("", "", key_path, cert_path, connAttempts, reconnects, connectTimeout, replyTimeout, rpcclient.INTERNAL_RPC, internalConn, false)
|
||||
} 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, "", "", connAttempts, reconnects, connectTimeout, replyTimeout, codec, nil, false)
|
||||
rpcClient, err = rpcclient.NewRpcClient("tcp", rpcConnCfg.Address, key_path, cert_path, connAttempts, reconnects, connectTimeout, replyTimeout, codec, nil, false)
|
||||
} else {
|
||||
return nil, fmt.Errorf("Unsupported transport: <%s>", rpcConnCfg.Transport)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user