From 336560b8ab3bc59ca13794ccf70f1bb21334f7cf Mon Sep 17 00:00:00 2001 From: DanB Date: Mon, 4 Feb 2019 19:01:17 +0100 Subject: [PATCH] New default config in package --- data/conf/cgrates/cgrates.json | 130 +++++++++++++--------- data/conf/samples/dispatcher/cgrates.json | 65 ----------- dispatchers/attributes.go | 18 ++- utils/consts.go | 2 + 4 files changed, 93 insertions(+), 122 deletions(-) delete mode 100755 data/conf/samples/dispatcher/cgrates.json diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index 636d83a16..8ed61d1f1 100644 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -8,7 +8,7 @@ // "general": { // "node_id": "", // identifier of this instance in the cluster, if empty it will be autogenerated -// "logger": "*syslog", // controls the destination of logs <*syslog|*stdout> +// "logger":"*syslog", // controls the destination of logs <*syslog|*stdout> // "log_level": 6, // control the level of messages logged (0-emerg to 7-debug) // "http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate // "rounding_decimals": 5, // system level precision for floats @@ -29,17 +29,18 @@ // "locking_timeout": "0", // timeout internal locks to avoid deadlocks // "digest_separator": ",", // "digest_equal": ":", +// "rsr_separator": ";", // }, // "data_db": { // database used to store runtime data (eg: accounts, cdr stats) // "db_type": "redis", // data_db type: <*redis|*mongo|*internal> // "db_host": "127.0.0.1", // data_db host address -// "db_port": 6379, // data_db port to reach the database -// "db_name": "10", // data_db database name to connect to -// "db_user": "cgrates", // username to use when connecting to data_db -// "db_password": "", // password to use when connecting to data_db -// "redis_sentinel": "", // redis_sentinel is the name of sentinel +// "db_port": 6379, // data_db port to reach the database +// "db_name": "10", // data_db database name to connect to +// "db_user": "cgrates", // username to use when connecting to data_db +// "db_password": "", // password to use when connecting to data_db +// "redis_sentinel":"", // redis_sentinel is the name of sentinel // }, @@ -52,7 +53,7 @@ // "db_password": "", // password to use when connecting to stordb // "max_open_conns": 100, // maximum database connections opened, not applying for mongo // "max_idle_conns": 10, // maximum database connections idle, not applying for mongo -// "conn_max_lifetime": 0, // maximum amount of time in seconds a connection may be reused (0 for unlimited), not applying for mongo +// "conn_max_lifetime": 0, // maximum amount of time in seconds a connection may be reused (0 for unlimited), not applying for mongo // "cdrs_indexes": [], // indexes on cdrs table to speed up queries, used only in case of mongo // }, @@ -61,13 +62,9 @@ // "rpc_json": "127.0.0.1:2012", // RPC JSON listening address // "rpc_gob": "127.0.0.1:2013", // RPC GOB listening address // "http": "127.0.0.1:2080", // HTTP listening address -// "rpc_json_tls": "127.0.0.1:2022", // RPC JSON TLS listening address +// "rpc_json_tls" : "127.0.0.1:2022", // RPC JSON TLS listening address // "rpc_gob_tls": "127.0.0.1:2023", // RPC GOB TLS listening address // "http_tls": "127.0.0.1:2280", // HTTP TLS listening address -// "tls_server_certificate": "", // path to server certificate(must conatin server.crt + ca.crt) -// "tls_server_key": "", // path to server key -// "tls_client_certificate": "", // path to client certificate(must conatin client.crt + ca.crt) -// "tls_client_key": "", // path to client key // }, @@ -82,7 +79,7 @@ // }, -// "http": { // HTTP server configuration +// "http": { // HTTP server configuration // "json_rpc_url": "/jsonrpc", // JSON RPC relative URL ("" to disable) // "ws_url": "/ws", // WebSockets relative URL ("" to disable) // "freeswitch_cdrs_url": "/freeswitch_json", // Freeswitch CDRS relative URL ("" to disable) @@ -103,8 +100,6 @@ // "reverse_destinations": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // reverse destinations index caching // "rating_plans": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // rating plans caching // "rating_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // rating profiles caching -// "lcr_rules": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // lcr rules caching -// "cdr_stats": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // cdr stats queues caching // "actions": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // actions caching // "action_plans": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // action plans caching // "account_action_plans": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // account action plans index caching @@ -116,21 +111,25 @@ // "timings": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // timings caching // "resource_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control resource profiles caching // "resources": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control resources caching -// "event_resources": {"limit": -1, "ttl": "1m", "static_ttl": false}, // matching resources to events -// "statqueue_profiles": {"limit": -1, "ttl": "1m", "static_ttl": false, "precache": false}, // statqueue profiles -// "statqueues": {"limit": -1, "ttl": "1m", "static_ttl": false, "precache": false}, // statqueues with metrics +// "event_resources": {"limit": -1, "ttl": "", "static_ttl": false}, // matching resources to events +// "statqueue_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // statqueue profiles +// "statqueues": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // statqueues with metrics // "threshold_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control threshold profiles caching // "thresholds": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control thresholds caching // "filters": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control filters caching // "supplier_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control supplier profile caching // "attribute_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control attribute profile caching // "charger_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control charger profile caching +// "dispatcher_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control dispatcher profile caching // "resource_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control resource filter indexes caching // "stat_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control stat filter indexes caching // "threshold_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control threshold filter indexes caching // "supplier_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control supplier filter indexes caching // "attribute_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control attribute filter indexes caching // "charger_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control charger filter indexes caching +// "dispatcher_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control dispatcher filter indexes caching +// "dispatcher_routes": {"limit": -1, "ttl": "", "static_ttl": false}, // control dispatcher routes caching +// "diameter_messages": {"limit": -1, "ttl": "3h", "static_ttl": false}, // diameter messages caching // }, @@ -173,7 +172,7 @@ // "aliases_conns": [], // address where to reach the aliases service, empty to disable aliases functionality: <""|*internal|x.y.z.y:1234> // "thresholds_conns": [], // address where to reach the thresholds service, empty to disable thresholds functionality: <""|*internal|x.y.z.y:1234> // "stats_conns": [], // address where to reach the stat service, empty to disable stats functionality: <""|*internal|x.y.z.y:1234> -// "online_cdr_exports": [], // list of CDRE profiles to use for real-time CDR exports +// "online_cdr_exports":[], // list of CDRE profiles to use for real-time CDR exports // }, @@ -220,7 +219,7 @@ // "cdrs_conns": [ // {"address": "*internal"} // address where to reach CDR server. <*internal|x.y.z.y:1234> // ], -// "cdr_format": "csv", // CDR file format <*csv|*freeswitch_csv|*fwv|*opensips_flatstore|*partial_csv> +// "cdr_format": "*csv", // CDR file format <*csv|*freeswitch_csv|*fwv|*opensips_flatstore|*partial_csv> // "field_separator": ",", // separator used in case of csv files // "timezone": "", // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> // "run_delay": 0, // sleep interval in seconds between consecutive runs, 0 to use automation via inotify @@ -231,7 +230,7 @@ // "failed_calls_prefix": "missed_calls", // used in case of flatstore CDRs to avoid searching for BYE records // "cdr_path": "", // path towards one CDR element in case of XML CDRs // "cdr_source_id": "freeswitch_csv", // free form field, tag identifying the source of the CDRs within CDRS database -// "filters": [], // new filters used in FilterS subsystem +// "filters" :[], // new filters used in FilterS subsystem // "tenant": "cgrates.org", // default tenant // "continue_on_success": false, // continue to the next template if executed // "partial_record_cache": "10s", // duration to cache partial records when not pairing @@ -325,7 +324,7 @@ // "empty_balance_context": "", // if defined, prepaid calls will be transferred to this context on empty balance // "empty_balance_ann_file": "", // file to be played before disconnecting prepaid calls on empty balance (applies only if no context defined) // "max_wait_connection": "2s", // maximum duration to wait for a connection to be retrieved from the pool -// "event_socket_conns": [ // instantiate connections to multiple FreeSWITCH servers +// "event_socket_conns":[ // instantiate connections to multiple FreeSWITCH servers // {"address": "127.0.0.1:8021", "password": "ClueCon", "reconnects": 5,"alias":""} // ], // }, @@ -338,7 +337,7 @@ // ], // "create_cdr": false, // create CDR out of events and sends them to CDRS component // "timezone": "", // timezone of the Kamailio server -// "evapi_conns": [ // instantiate connections to multiple Kamailio servers +// "evapi_conns":[ // instantiate connections to multiple Kamailio servers // {"address": "127.0.0.1:8448", "reconnects": 5} // ], // }, @@ -346,7 +345,8 @@ // "diameter_agent": { // "enabled": false, // enables the diameter agent: -// "listen": "127.0.0.1:3868", // address where to listen for diameter requests +// "listen": "127.0.0.1:3868", // address where to listen for diameter requests +// "listen_net": "tcp", // transport type for diameter // "dictionaries_path": "/usr/share/cgrates/diameter/dict/", // path towards directory holding additional dictionaries to load // "sessions_conns": [ // {"address": "*internal"} // connection towards SessionService @@ -355,10 +355,22 @@ // "origin_realm": "cgrates.org", // diameter Origin-Realm AVP used in replies // "vendor_id": 0, // diameter Vendor-Id AVP used in replies // "product_name": "CGRateS", // diameter Product-Name AVP used in replies -// "templates": { +// "max_active_requests": -1, // limit the number of active requests processed by the server <-1|0-n> +// "asr_template": "", // enable AbortSession message being sent to client on DisconnectSession +// "templates":{ +// "*err": [ +// {"tag": "SessionId", "field_id": "Session-Id", "type": "*composed", +// "value": "~*req.Session-Id", "mandatory": true}, +// {"tag": "OriginHost", "field_id": "Origin-Host", "type": "*composed", +// "value": "~*vars.OriginHost", "mandatory": true}, +// {"tag": "OriginRealm", "field_id": "Origin-Realm", "type": "*composed", +// "value": "~*vars.OriginRealm", "mandatory": true}, +// ], // "*cca": [ // {"tag": "SessionId", "field_id": "Session-Id", "type": "*composed", // "value": "~*req.Session-Id", "mandatory": true}, +// {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", +// "value": "2001"}, // {"tag": "OriginHost", "field_id": "Origin-Host", "type": "*composed", // "value": "~*vars.OriginHost", "mandatory": true}, // {"tag": "OriginRealm", "field_id": "Origin-Realm", "type": "*composed", @@ -369,6 +381,24 @@ // "value": "~*req.CC-Request-Type", "mandatory": true}, // {"tag": "CCRequestNumber", "field_id": "CC-Request-Number", "type": "*composed", // "value": "~*req.CC-Request-Number", "mandatory": true}, +// ], +// "*asr": [ +// {"tag": "SessionId", "field_id": "Session-Id", "type": "*variable", +// "value": "~*req.Session-Id", "mandatory": true}, +// {"tag": "OriginHost", "field_id": "Origin-Host", "type": "*variable", +// "value": "~*req.Destination-Host", "mandatory": true}, +// {"tag": "OriginRealm", "field_id": "Origin-Realm", "type": "*variable", +// "value": "~*req.Destination-Realm", "mandatory": true}, +// {"tag": "DestinationRealm", "field_id": "Destination-Realm", "type": "*variable", +// "value": "~*req.Origin-Realm", "mandatory": true}, +// {"tag": "DestinationHost", "field_id": "Destination-Host", "type": "*variable", +// "value": "~*req.Origin-Host", "mandatory": true}, +// {"tag": "AuthApplicationId", "field_id": "Auth-Application-Id", "type": "*variable", +// "value": "~*vars.*appid", "mandatory": true}, +// {"tag": "UserName", "field_id": "User-Name", "type": "*variable", +// "value": "~*req.User-Name", "mandatory": true}, +// {"tag": "OriginStateID", "field_id": "Origin-State-Id", "type": "*constant", +// "value": "1"}, // ] // }, // "request_processors": [], @@ -389,12 +419,12 @@ // "sessions_conns": [ // {"address": "*internal"} // connection towards SessionService // ], -// "cdr_requires_session": false, // only create CDR if there is an active session at terminate // "request_processors": [], // }, -// "http_agent": [], // HTTP Agents, ie towards cnc.to MVNE platform +// "http_agent": [ // HTTP Agents, ie towards cnc.to MVNE platform +// ], // "pubsubs": { @@ -413,7 +443,7 @@ // }, -// "attributes": { // Attribute service +// "attributes": { // Attribute service // "enabled": false, // starts attribute service: . // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing @@ -421,7 +451,7 @@ // }, -// "chargers": { // Charger service +// "chargers": { // Charger service // "enabled": false, // starts charger service: . // "attributes_conns": [], // address where to reach the AttributeS <""|127.0.0.1:2013> // //"string_indexed_fields": [], // query indexes based on these fields for faster processing @@ -429,7 +459,7 @@ // }, -// "resources": { // Resource service (*new) +// "resources": { // Resource service (*new) // "enabled": false, // starts ResourceLimiter service: . // "store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur> // "thresholds_conns": [], // address where to reach the thresholds service, empty to disable thresholds functionality: <""|*internal|x.y.z.y:1234> @@ -438,7 +468,7 @@ // }, -// "stats": { // Stat service (*new) +// "stats": { // Stat service (*new) // "enabled": false, // starts Stat service: . // "store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur> // "thresholds_conns": [], // address where to reach the thresholds service, empty to disable thresholds functionality: <""|*internal|x.y.z.y:1234> @@ -447,7 +477,7 @@ // }, -// "thresholds": { // Threshold service (*new) +// "thresholds": { // Threshold service (*new) // "enabled": false, // starts ThresholdS service: . // "store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur> // //"string_indexed_fields": [], // query indexes based on these fields for faster processing @@ -455,7 +485,7 @@ // }, -// "suppliers": { // Supplier service (*new) +// "suppliers": { // Supplier service (*new) // "enabled": false, // starts SupplierS service: . // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing @@ -482,7 +512,7 @@ // "field_separator": ",", // separator used in case of csv files // "tp_in_dir": "/var/spool/cgrates/loader/in", // absolute path towards the directory where the CDRs are stored // "tp_out_dir": "/var/spool/cgrates/loader/out", // absolute path towards the directory where processed CDRs will be moved -// "data": [ // data profiles to load +// "data":[ // data profiles to load // { // "type": "*attributes", // data source type // "file_name": "Attributes.csv", // file name in the tp_in_dir @@ -500,8 +530,8 @@ // ], // }, // { -// "type": "*filters", // data source type -// "file_name": "Filters.csv", // file name in the tp_in_dir +// "type": "*filters", // data source type +// "file_name": "Filters.csv", // file name in the tp_in_dir // "fields": [ // {"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~0", "mandatory": true}, // {"tag": "ID", "field_id": "ID", "type": "*composed", "value": "~1", "mandatory": true}, @@ -529,8 +559,8 @@ // ], // }, // { -// "type": "*stats", // data source type -// "file_name": "Stats.csv", // file name in the tp_in_dir +// "type": "*stats", // data source type +// "file_name": "Stats.csv", // file name in the tp_in_dir // "fields": [ // {"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "~0", "mandatory": true}, // {"tag": "ID", "field_id": "ID", "type": "*composed", "value": "~1", "mandatory": true}, @@ -642,11 +672,12 @@ // }, -// "loader": { // loader for tariff plans out of .csv files +// "loader": { // loader for tariff plans out of .csv files // "tpid": "", // tariff plan identificator -// "data_path": "", // path towards tariff plan files +// "data_path": "./", // path towards tariff plan files // "disable_reverse": false, // disable reverse computing -// "caches_conns": [ // addresses towards cacheS components for reloads +// "field_separator": ",", // separator used in case of csv files +// "caches_conns":[ // addresses towards cacheS components for reloads // {"address": "127.0.0.1:2012", "transport": "*json"} // ], // "scheduler_conns": [ @@ -662,7 +693,7 @@ // "out_datadb_name": "10", // "out_datadb_user": "cgrates", // "out_datadb_password": "", -// "out_datadb_encoding": "msgpack", +// "out_datadb_encoding" : "msgpack", // "out_stordb_type": "mysql", // "out_stordb_host": "127.0.0.1", // "out_stordb_port": "3306", @@ -672,17 +703,12 @@ // }, -// "dispatcher":{ +// "dispatchers":{ // "enabled": false, // starts DispatcherS service: . -// "rals_conns": [], // address where to reach the RALs for dispatcherS <*internal> -// "resources_conns": [], // address where to reach the ResourceS <""|127.0.0.1:2013> -// "thresholds_conns": [], // address where to reach the ThresholdS <""|127.0.0.1:2013> -// "stats_conns": [], // address where to reach the StatS <""|127.0.0.1:2013> -// "suppliers_conns": [], // address where to reach the SupplierS <""|127.0.0.1:2013> -// "attributes_conns": [], // address where to reach the AttributeS <""|127.0.0.1:2013> -// "sessions_conns": [], // connection towards SessionService -// "chargers_conns": [], // address where to reach the ChargerS <""|127.0.0.1:2013> -// "dispatching_strategy": "*first", // strategy for dispatching <*first|*random|*next|*broadcast> +// //"string_indexed_fields": [], // query indexes based on these fields for faster processing +// "prefix_indexed_fields": [], // query indexes based on these fields for faster processing +// "attributes_conns": [], // address where to reach the attribute service, empty to disable auth functionality: <""|*internal|x.y.z.y:1234> +// "conns": {}, // }, diff --git a/data/conf/samples/dispatcher/cgrates.json b/data/conf/samples/dispatcher/cgrates.json deleted file mode 100755 index 58306c25a..000000000 --- a/data/conf/samples/dispatcher/cgrates.json +++ /dev/null @@ -1,65 +0,0 @@ -{ -// CGRateS Configuration file -// - - -"general": { - "log_level": 7, - "node_id":"Dispatcher", -}, - - -"listen": { - "rpc_json": ":2112", - "rpc_gob": ":2113", - "http": ":2180", -}, - -"data_db": { // database used to store runtime data (eg: accounts, cdr stats) - "db_type": "redis", // data_db type: - "db_port": 6379, // data_db port to reach the database - "db_name": "10", // data_db database name to connect to - -}, - -"stor_db": { - "db_password": "CGRateS.org", -}, - - -"rals": { - "enabled": true, -}, - - -"dispatcher":{ - "enabled": true, // starts DispatcherS service: . - "rals_conns": [ - {"address": "*internal"}, - ], - "resources_conns": [ - {"address": "192.168.56.203:2012", "transport": "*json"}, - ], - "thresholds_conns": [ - {"address": "192.168.56.203:2012", "transport": "*json"}, - ], - "stats_conns": [ - {"address": "192.168.56.203:2012", "transport": "*json"}, - ], - "suppliers_conns": [ - {"address": "192.168.56.203:2012", "transport": "*json"}, - ], - "attributes_conns": [ - {"address": "192.168.56.203:2012", "transport": "*json"}, - ], - "sessions_conns": [ - {"address": "192.168.56.203:2012", "transport": "*json"}, - ], - "chargers_conns": [ - {"address": "192.168.56.203:2012", "transport": "*json"}, - ], - "dispatching_strategy":"*first", -}, - - -} diff --git a/dispatchers/attributes.go b/dispatchers/attributes.go index bf50f3e8a..ebc1f7ba7 100755 --- a/dispatchers/attributes.go +++ b/dispatchers/attributes.go @@ -23,13 +23,21 @@ import ( "github.com/cgrates/cgrates/utils" ) -/* -func (dS *DispatcherService) AttributeSv1Ping(ign string, reply *string) error { - return dS.Dispatch(nil, utils.MetaAttributes, - utils.AttributeSv1Ping, ign, reply) +// AttributeSv1Ping interogates AttributeS server responsible to process the event +func (dS *DispatcherService) AttributeSv1Ping(args *ArgsAttrProcessEventWithApiKey, + reply *string) error { + if dS.attrS != nil { + if err = dS.authorize(utils.AttributeSv1Ping, + args.AttrArgsProcessEvent.CGREvent.Tenant, + args.APIKey, args.AttrArgsProcessEvent.CGREvent.Time); err != nil { + return + } + } + return dS.Dispatch(&args.CGREvent, utils.MetaAttributes, + utils.AttributeSv1Ping, args.AttrArgsProcessEvent, reply) } -*/ +// AttributeSv1GetAttributeForEvent is the dispatcher method for AttributeSv1.GetAttributeForEvent func (dS *DispatcherService) AttributeSv1GetAttributeForEvent(args *ArgsAttrProcessEventWithApiKey, reply *engine.AttributeProfile) (err error) { if dS.attrS != nil { diff --git a/utils/consts.go b/utils/consts.go index 85951b485..d59eb2d8c 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -503,6 +503,7 @@ const ( CGR_ACD = "cgr_acd" FilterIDs = "FilterIDs" FieldName = "FieldName" + APIMethod = "APIMethod" Initial = "Initial" Substitute = "Substitute" Append = "Append" @@ -692,6 +693,7 @@ const ( MetaAuth = "*auth" APIKey = "APIKey" APIMethods = "APIMethods" + APIMethod = "APIMethod" NestingSep = "." )