├── packages ├── jessie │ ├── docs │ ├── compat │ ├── source │ │ ├── format │ │ └── options │ ├── copyright │ ├── control │ ├── cgrates.service │ └── changelog ├── squeeze │ ├── docs │ ├── compat │ ├── source │ │ ├── format │ │ └── options │ ├── copyright │ ├── cgrates.default │ ├── control │ └── changelog ├── Makefile └── redhat_fedora │ ├── cgrates.options │ ├── cgrates.service │ └── readme.txt ├── api └── v1 │ ├── mediator.go │ ├── cdrc.go │ ├── smv1.go │ └── costs.go ├── data ├── tariffplans │ ├── testtp │ │ ├── LcrRules.csv │ │ ├── SharedGroups.csv │ │ ├── Timings.csv │ │ ├── Destinations.csv │ │ ├── Rates.csv │ │ ├── RatingPlans.csv │ │ ├── Aliases.csv │ │ ├── DestinationRates.csv │ │ ├── ActionPlans.csv │ │ ├── RatingProfiles.csv │ │ ├── AccountActions.csv │ │ ├── README.md │ │ ├── CdrStats.csv │ │ ├── Users.csv │ │ ├── DerivedChargers.csv │ │ └── ActionTriggers.csv │ ├── test │ │ └── destinations │ │ │ ├── cacheone │ │ │ ├── Destinations.csv │ │ │ ├── Rates.csv │ │ │ ├── RatingPlans.csv │ │ │ ├── Timings.csv │ │ │ ├── DestinationRates.csv │ │ │ └── RatingProfiles.csv │ │ │ ├── cacheall │ │ │ ├── Rates.csv │ │ │ ├── Destinations.csv │ │ │ ├── RatingPlans.csv │ │ │ ├── Timings.csv │ │ │ ├── DestinationRates.csv │ │ │ └── RatingProfiles.csv │ │ │ ├── multiid │ │ │ ├── Destinations.csv │ │ │ ├── Timings.csv │ │ │ ├── Rates.csv │ │ │ ├── RatingPlans.csv │ │ │ ├── RatingProfiles.csv │ │ │ └── DestinationRates.csv │ │ │ ├── removesome │ │ │ └── Destinations.csv │ │ │ ├── addback │ │ │ └── Destinations.csv │ │ │ ├── alldests │ │ │ └── Destinations.csv │ │ │ └── addone │ │ │ └── Destinations.csv │ ├── cdrstats │ │ ├── Actions.csv │ │ ├── RatingPlans.csv │ │ ├── Rates.csv │ │ ├── Destinations.csv │ │ ├── Timings.csv │ │ ├── DestinationRates.csv │ │ ├── RatingProfiles.csv │ │ ├── ActionTriggers.csv │ │ └── CdrStats.csv │ ├── osips_training │ │ ├── Destinations.csv │ │ ├── RatingPlans.csv │ │ ├── ActionPlans.csv │ │ ├── Rates.csv │ │ ├── DestinationRates.csv │ │ ├── RatingProfiles.csv │ │ ├── AccountActions.csv │ │ ├── Actions.csv │ │ ├── CdrStats.csv │ │ └── ActionTriggers.csv │ ├── phoenix │ │ ├── AccountActions.json │ │ ├── RatingPlans.json │ │ ├── RatingProfiles.json │ │ └── Users.json │ └── tutorial │ │ ├── SharedGroups.csv │ │ ├── Destinations.csv │ │ ├── Aliases.csv │ │ ├── Timings.csv │ │ ├── AccountActions.csv │ │ ├── Rates.csv │ │ ├── ActionPlans.csv │ │ ├── Destinations.json │ │ ├── ResourceLimits.csv │ │ ├── DerivedChargers.csv │ │ ├── DestinationRates.csv │ │ ├── RatingProfiles.csv │ │ ├── RatingPlans.csv │ │ ├── Users.csv │ │ ├── Actions.csv │ │ ├── LcrRules.csv │ │ └── ActionTriggers.csv ├── vagrant │ ├── cgrates_devel.retry │ ├── my.cnf │ └── golang.sh ├── docker │ ├── prod │ │ ├── my.cnf │ │ ├── README.md │ │ ├── start.sh │ │ └── Dockerfile │ ├── osips_training │ │ ├── my.cnf │ │ ├── README.md │ │ └── start.sh │ └── devel │ │ ├── README.md │ │ ├── docker-compose.yml │ │ └── Dockerfile ├── tutorials │ ├── asterisk_events │ │ └── asterisk │ │ │ └── etc │ │ │ └── asterisk │ │ │ ├── http.conf │ │ │ ├── musiconhold.conf │ │ │ ├── confbridge.conf │ │ │ ├── ari.conf │ │ │ ├── cdr.conf │ │ │ ├── logger.conf │ │ │ ├── extensions.conf │ │ │ ├── asterisk.conf │ │ │ ├── voicemail.conf │ │ │ ├── cdr_custom.conf │ │ │ ├── queues.conf │ │ │ ├── indications.conf │ │ │ └── README │ ├── fs_evsock │ │ ├── freeswitch │ │ │ └── etc │ │ │ │ └── freeswitch.tar.gz │ │ └── README.md │ └── osips_async │ │ └── opensips │ │ └── etc │ │ └── default │ │ └── opensips ├── daemontools │ └── run ├── scripts │ ├── optimize_proc.sh │ ├── freeswitch_cdr_csv_rotate.sh │ ├── header.sh │ ├── pkg │ │ └── pkg_cgrates_deb.sh │ └── copyright_header.txt ├── storage │ ├── mongo │ │ ├── create_user.js │ │ └── setup_cgr_db.sh │ ├── mysql │ │ ├── create_db_with_users.sql │ │ └── setup_cgr_db.sh │ └── postgres │ │ ├── create_db_with_users.sh │ │ └── setup_cgr_db.sh ├── conf │ └── samples │ │ ├── hapool │ │ ├── dagent │ │ │ └── cgr.json │ │ ├── cgrrater1 │ │ │ └── cgr.json │ │ ├── cgrrater2 │ │ │ └── cgr.json │ │ ├── cgrsmg1 │ │ │ └── cgr.json │ │ └── cgrsmg2 │ │ │ └── cgr.json │ │ ├── storage │ │ ├── mongo │ │ │ └── cgrates.json │ │ ├── mysql │ │ │ └── cgrates.json │ │ └── postgres │ │ │ └── cgrates.json │ │ ├── multiral2 │ │ └── cgrates.json │ │ ├── multiral1 │ │ └── cgrates.json │ │ ├── cdrsv2mysql │ │ └── cdrsv2mysql.json │ │ ├── smfs │ │ └── smfs.json │ │ ├── cdrsreplicationslave │ │ └── cdrsreplicationslave.json │ │ ├── cdrstats │ │ └── cdrstats.json │ │ ├── cdrsreplicationmaster │ │ └── cdrsreplicationmaster.json │ │ ├── cdrsv2mongo │ │ └── cdrsv2psql.json │ │ ├── cdrsv2psql │ │ └── cdrsv2psql.json │ │ ├── smg │ │ └── cgrates.json │ │ ├── fscsv │ │ └── cgrates.json │ │ ├── multifiles │ │ ├── b │ │ │ └── b.json │ │ └── c.json │ │ ├── actions │ │ └── cgradmin.json │ │ ├── osips_training │ │ └── cgrates.json │ │ └── apier │ │ └── apier.json ├── diameter │ └── dict │ │ └── huawei │ │ └── nokia.xml ├── monit │ └── cgrates.monit └── freeswitch │ └── conf │ └── directory │ └── default │ └── 1000.xml ├── cdre └── cdrexporter_test.go ├── general_tests └── placeholder.go ├── test.sh ├── docs ├── images │ ├── logo.png │ ├── Normal.png │ ├── Simple.png │ ├── accurate.png │ ├── Normal_ha.png │ ├── Complicated.png │ ├── cgrates-arch.png │ ├── Complicated_ha.png │ └── FSTypicalUsage.png ├── miscellaneous.rst ├── tutorials.rst ├── advanced.rst ├── tut_jitsi_installs.rst ├── cgrates_json.rst ├── tut_freeswitch.rst ├── administration.rst ├── csv_tpdestinations.rst ├── index.rst ├── tut_kamailio.rst ├── tut_opensips.rst ├── tut_opensips_installs.rst ├── tut_kamailio_installs.rst ├── api_tp.rst ├── configuration.rst ├── api_scheduler.rst ├── csv_tpdestinationrates.rst ├── api_ratingprofiles.rst ├── api_accounts.rst ├── tut_freeswitch_installs.rst └── csv_tpdestratetimings.rst ├── balancer2go ├── .travis.yml └── README.md ├── cmd ├── cc-tester │ ├── README.md │ └── cdr_repl │ │ └── post_server.py └── cc-engine │ └── engine_test.go ├── .travis.yml ├── sessionmanager ├── osipssm_test.go ├── fssessionmanager_test.go ├── kamailiosm_test.go └── sessionmanager.go ├── calls_test.sh ├── engine ├── rawcdr.go ├── groups.go ├── history_test.go ├── event.go └── handler_derivedcharging.go ├── run_devel_docker.sh ├── utils ├── logger.go ├── loader_json.go ├── researchreplace.go ├── cgrrecordwriter.go ├── errors_test.go ├── README.md ├── slice_test.go ├── rpc_params.go └── slice.go ├── .gitignore ├── cache2go └── response_cache_test.go ├── console ├── publish.go ├── subscribe.go ├── user_addindex.go ├── cdrs_rem.go ├── user_set.go ├── scheduler_reload.go ├── cdrs_rate.go ├── unsubscribe.go ├── cdrstats_queue.go ├── user_indexes.go ├── account_set.go ├── user_remove.go ├── user_update.go ├── sharedgroup.go ├── subscribers.go ├── cdrs_export.go ├── users.go ├── console_old │ ├── cache_stats.go │ ├── actions_remove.go │ ├── destination_set.go │ ├── trigger_set.go │ ├── actionplan_set.go │ ├── load_tp_from_folder.go │ ├── ratingprofile_set.go │ ├── trigger_remove.go │ ├── load_history.go │ ├── triggers.go │ ├── account_actionplan_get.go │ ├── account_trigger_add.go │ ├── account_trigger_set.go │ ├── actionplan_get.go │ ├── ratingprofile_rem.go │ ├── account_trigger_reset.go │ └── account_trigger_remove.go ├── cache_reload.go ├── balance_debit.go ├── account_remove.go ├── cdrstats_reset.go ├── cdrstats_metrics.go ├── status.go ├── cdrstats_queue_triggers.go ├── cdrstats_reload.go ├── balance_set.go ├── cdrc_config_reload.go ├── cdre_config_reload.go ├── actions.go ├── action_execute.go ├── balance_add.go ├── lcr.go ├── cdrstats_queueids.go ├── destinations.go ├── indexes_ensure.go ├── accounts.go ├── aliases.go ├── balance_remove.go ├── aliases_reverse.go ├── callcost.go ├── maxusage.go ├── aliases_remove.go ├── scheduler_queue.go ├── active_sessions.go ├── aliases_set.go ├── scheduler_execute.go ├── debit.go ├── cost.go └── debit_max.go ├── history └── scribe_test.go ├── glide.yaml └── manifest.json /packages/jessie/docs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/squeeze/docs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/jessie/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /packages/squeeze/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /api/v1/mediator.go: -------------------------------------------------------------------------------- 1 | 2 | package v1 3 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/LcrRules.csv: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/SharedGroups.csv: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cdre/cdrexporter_test.go: -------------------------------------------------------------------------------- 1 | 2 | package cdre 3 | -------------------------------------------------------------------------------- /data/vagrant/cgrates_devel.retry: -------------------------------------------------------------------------------- 1 | default 2 | -------------------------------------------------------------------------------- /packages/jessie/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /packages/squeeze/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /general_tests/placeholder.go: -------------------------------------------------------------------------------- 1 | 2 | package general_tests 3 | -------------------------------------------------------------------------------- /data/docker/prod/my.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | user=root 3 | password=accuRate 4 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheone/Destinations.csv: -------------------------------------------------------------------------------- 1 | DST_100x,1001 2 | -------------------------------------------------------------------------------- /data/docker/osips_training/my.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | user=root 3 | password=accuRate 4 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheall/Rates.csv: -------------------------------------------------------------------------------- 1 | R_100x,0,10,60s,1s,0s 2 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheone/Rates.csv: -------------------------------------------------------------------------------- 1 | R_100x,0,10,60s,1s,0s 2 | -------------------------------------------------------------------------------- /data/vagrant/my.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | user=root 3 | password={{ root_db_password }} 4 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | ./build.sh 3 | go test $(glide novendor) 4 | exit $? -------------------------------------------------------------------------------- /data/tariffplans/cdrstats/Actions.csv: -------------------------------------------------------------------------------- 1 | CDRST_LOG,*log,,,,,,,,,,,,,,false,false,10 2 | -------------------------------------------------------------------------------- /data/tariffplans/osips_training/Destinations.csv: -------------------------------------------------------------------------------- 1 | #Id,Prefix 2 | DST_ON_NET,10 3 | 4 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheall/Destinations.csv: -------------------------------------------------------------------------------- 1 | DST_100x,1001 2 | DST_100x,1002 -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheall/RatingPlans.csv: -------------------------------------------------------------------------------- 1 | RPL_100x,DR_100x,always,10 2 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheone/RatingPlans.csv: -------------------------------------------------------------------------------- 1 | RPL_100x,DR_100x,always,10 2 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheall/Timings.csv: -------------------------------------------------------------------------------- 1 | always,*any,*any,*any,*any,00:00:00 2 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheone/Timings.csv: -------------------------------------------------------------------------------- 1 | always,*any,*any,*any,*any,00:00:00 2 | -------------------------------------------------------------------------------- /data/tariffplans/phoenix/AccountActions.json: -------------------------------------------------------------------------------- 1 | {"Tenant":"t1", "Account":"t1", "AllowNegative":true} 2 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheall/DestinationRates.csv: -------------------------------------------------------------------------------- 1 | DR_100x,DST_100x,R_100x,*up,4,0, 2 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheone/DestinationRates.csv: -------------------------------------------------------------------------------- 1 | DR_100x,DST_100x,R_100x,*up,4,0, 2 | -------------------------------------------------------------------------------- /docs/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/accurateproject/accurate/HEAD/docs/images/logo.png -------------------------------------------------------------------------------- /docs/images/Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/accurateproject/accurate/HEAD/docs/images/Normal.png -------------------------------------------------------------------------------- /docs/images/Simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/accurateproject/accurate/HEAD/docs/images/Simple.png -------------------------------------------------------------------------------- /docs/images/accurate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/accurateproject/accurate/HEAD/docs/images/accurate.png -------------------------------------------------------------------------------- /data/tariffplans/tutorial/SharedGroups.csv: -------------------------------------------------------------------------------- 1 | #Id,Account,Strategy,RatingSubject 2 | SHARED_A,*any,*highest, 3 | -------------------------------------------------------------------------------- /docs/images/Normal_ha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/accurateproject/accurate/HEAD/docs/images/Normal_ha.png -------------------------------------------------------------------------------- /docs/images/Complicated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/accurateproject/accurate/HEAD/docs/images/Complicated.png -------------------------------------------------------------------------------- /docs/images/cgrates-arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/accurateproject/accurate/HEAD/docs/images/cgrates-arch.png -------------------------------------------------------------------------------- /data/tariffplans/cdrstats/RatingPlans.csv: -------------------------------------------------------------------------------- 1 | #Tag,DestinationRatesTag,TimingTag,Weight 2 | RP_RETAIL,DR_RETAIL,ALWAYS,10 3 | -------------------------------------------------------------------------------- /data/tariffplans/osips_training/RatingPlans.csv: -------------------------------------------------------------------------------- 1 | #Id,DestinationRatesId,TimingTag,Weight 2 | RP_TRAINING1,DR_ANY_1CNT,*any,10 -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/multiid/Destinations.csv: -------------------------------------------------------------------------------- 1 | #Tag,Prefix 2 | GERMANY,+49 3 | EUROPE,+40 4 | EUROPE,+49 5 | -------------------------------------------------------------------------------- /docs/images/Complicated_ha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/accurateproject/accurate/HEAD/docs/images/Complicated_ha.png -------------------------------------------------------------------------------- /docs/images/FSTypicalUsage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/accurateproject/accurate/HEAD/docs/images/FSTypicalUsage.png -------------------------------------------------------------------------------- /data/tariffplans/cdrstats/Rates.csv: -------------------------------------------------------------------------------- 1 | #Tag,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart 2 | RT_1CENT,0,1,1s,1s,0s 3 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheall/RatingProfiles.csv: -------------------------------------------------------------------------------- 1 | *out,cgrates.org,call,test,2014-01-14T00:00:00Z,RPL_100x,, 2 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/cacheone/RatingProfiles.csv: -------------------------------------------------------------------------------- 1 | *out,cgrates.org,call,test,2014-01-14T00:00:00Z,RPL_100x,, 2 | -------------------------------------------------------------------------------- /balancer2go/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | notifications: 4 | email: 5 | on_success: change 6 | on_failure: always 7 | -------------------------------------------------------------------------------- /docs/miscellaneous.rst: -------------------------------------------------------------------------------- 1 | 8. Miscellaneous 2 | ================ 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | freeswitch 8 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/multiid/Timings.csv: -------------------------------------------------------------------------------- 1 | #Tag,Years,Months,MonthDays,WeekDays,Time 2 | ALWAYS,*any,*any,*any,*any,00:00:00 -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/http.conf: -------------------------------------------------------------------------------- 1 | [general] 2 | enabled = yes 3 | bindaddr = 127.0.0.1 4 | bindport = 8088 -------------------------------------------------------------------------------- /data/vagrant/golang.sh: -------------------------------------------------------------------------------- 1 | export GOROOT=/home/vagrant/go GOPATH=/home/vagrant/code 2 | export PATH=$PATH:$GOROOT/bin:$GOPATH/bin 3 | 4 | -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/musiconhold.conf: -------------------------------------------------------------------------------- 1 | [general] 2 | 3 | [default] 4 | mode = files 5 | directory = moh 6 | -------------------------------------------------------------------------------- /data/tariffplans/cdrstats/Destinations.csv: -------------------------------------------------------------------------------- 1 | #Tag,Prefix 2 | GERMANY,+49 3 | GERMANY_MOBILE,+4915 4 | GERMANY_MOBILE,+4916 5 | GERMANY_MOBILE,+4917 6 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/Timings.csv: -------------------------------------------------------------------------------- 1 | #Tag,Years,Months,MonthDays,WeekDays,Time 2 | ALWAYS,*any,*any,*any,*any,00:00:00 3 | ASAP,*any,*any,*any,*any,*asap -------------------------------------------------------------------------------- /packages/jessie/source/options: -------------------------------------------------------------------------------- 1 | tar-ignore = .hg 2 | tar-ignore = .git 3 | tar-ignore = .bzr 4 | tar-ignore = .gitignore 5 | tar-ignore = .travis.yml 6 | -------------------------------------------------------------------------------- /packages/squeeze/source/options: -------------------------------------------------------------------------------- 1 | tar-ignore = .hg 2 | tar-ignore = .git 3 | tar-ignore = .bzr 4 | tar-ignore = .gitignore 5 | tar-ignore = .travis.yml 6 | -------------------------------------------------------------------------------- /data/daemontools/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo Firing up AccuRate engine 3 | exec setuidgid cgrates /usr/bin/cgr-engine -config /etc/cgrates/cgrates.cfg 4 | 5 | -------------------------------------------------------------------------------- /data/tariffplans/cdrstats/Timings.csv: -------------------------------------------------------------------------------- 1 | #Tag,Years,Months,MonthDays,WeekDays,Time 2 | ALWAYS,*any,*any,*any,*any,00:00:00 3 | ASAP,*any,*any,*any,*any,*asap 4 | -------------------------------------------------------------------------------- /data/tariffplans/osips_training/ActionPlans.csv: -------------------------------------------------------------------------------- 1 | #Id,ActionsId,TimingId,Weight 2 | TEST_ACCOUNT,TOPUP_MONETARY_5,*asap,10 3 | TEST_ACCOUNT,TOPUP_VOICE_200,*asap,10 4 | -------------------------------------------------------------------------------- /data/tariffplans/osips_training/Rates.csv: -------------------------------------------------------------------------------- 1 | #Id,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart 2 | RT_1CNT,0.05,0.01,1s,60s,0s 3 | RT_1CNT,0,0.01,1s,1s,60s 4 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/Destinations.csv: -------------------------------------------------------------------------------- 1 | #Tag,Prefix 2 | GERMANY,+49 3 | GERMANY_MOBILE,+4915 4 | GERMANY_MOBILE,+4916 5 | GERMANY_MOBILE,+4917 6 | DATA_DEST,222 7 | -------------------------------------------------------------------------------- /data/tariffplans/osips_training/DestinationRates.csv: -------------------------------------------------------------------------------- 1 | #Id,DestinationId,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy 2 | DR_ANY_1CNT,*any,RT_1CNT,*up,4,0, -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/multiid/Rates.csv: -------------------------------------------------------------------------------- 1 | #Tag,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart 2 | RT_1CENT,0,1,1s,1s,0s 3 | RT_SMS_5c,0,0.005,1,1,0 4 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/multiid/RatingPlans.csv: -------------------------------------------------------------------------------- 1 | #Tag,DestinationRatesTag,TimingTag,Weight 2 | RP_RETAIL,DR_RETAIL,ALWAYS,20 3 | RP_RETAIL,DR_SMS_1,ALWAYS,10 4 | -------------------------------------------------------------------------------- /docs/tutorials.rst: -------------------------------------------------------------------------------- 1 | 7. Tutorials 2 | ============ 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | tut_freeswitch 8 | tut_kamailio 9 | tut_opensips 10 | -------------------------------------------------------------------------------- /data/tariffplans/cdrstats/DestinationRates.csv: -------------------------------------------------------------------------------- 1 | #Tag,DestinationsTag,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy 2 | DR_RETAIL,GERMANY,RT_1CENT,*up,4,0, 3 | -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/confbridge.conf: -------------------------------------------------------------------------------- 1 | ; All conferences use default settings. This config must be present to load the confbridge application 2 | -------------------------------------------------------------------------------- /data/tutorials/fs_evsock/freeswitch/etc/freeswitch.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/accurateproject/accurate/HEAD/data/tutorials/fs_evsock/freeswitch/etc/freeswitch.tar.gz -------------------------------------------------------------------------------- /data/scripts/optimize_proc.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | 3 | for i in /sys/devices/system/cpu/cpu[0-9] 4 | do 5 | echo performance > $i/cpufreq/scaling_governor 6 | done 7 | 8 | -------------------------------------------------------------------------------- /data/tariffplans/phoenix/RatingPlans.json: -------------------------------------------------------------------------------- 1 | {"Tenant":"t1", "Tag":"STANDARD", "Bindings":[ 2 | {"DestinationRatesTag": "DR_STANDARD", "TimingTag": "*any", "Weight": 10} 3 | ]} 4 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/removesome/Destinations.csv: -------------------------------------------------------------------------------- 1 | #Tag,Prefix 2 | GERMANY,+49 3 | GERMANY_MOBILE,+4915 4 | GERMANY_MOBILE,+4916 5 | GERMANY_MOBILE,+4917 6 | DATA_DEST,222 7 | EUROPE,+49 8 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/Destinations.csv: -------------------------------------------------------------------------------- 1 | #Id,Prefix 2 | DST_1002,1002 3 | DST_1003,1003 4 | DST_1007,1007 5 | DST_FS,10 6 | DST_DE_MOBILE,+49151 7 | DST_DE_MOBILE,+49161 8 | DST_DE_MOBILE,+49171 9 | -------------------------------------------------------------------------------- /data/tariffplans/cdrstats/RatingProfiles.csv: -------------------------------------------------------------------------------- 1 | #Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject,CdrStatQueueIds 2 | *out,cgrates.org,call,*any,2012-01-01T00:00:00Z,RP_RETAIL,, 3 | -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/ari.conf: -------------------------------------------------------------------------------- 1 | [general] 2 | enabled = yes 3 | allowed_origins = http://cgrates.org 4 | 5 | [cgrates] 6 | type = user 7 | read_only = no 8 | password = CGRateS.org -------------------------------------------------------------------------------- /cmd/cc-tester/README.md: -------------------------------------------------------------------------------- 1 | * Stress testing tools 2 | 3 | All stress testing tools work with ../../data/tariffplans/fs_germany_prep1/. So start a rater and than issue a `cc-loader -flushdb -verbose` in that directory. 4 | -------------------------------------------------------------------------------- /data/tariffplans/osips_training/RatingProfiles.csv: -------------------------------------------------------------------------------- 1 | #Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject,CdrStatQueueIds 2 | *out,cgrates.org,call,*any,2016-08-01T00:00:00Z,RP_TRAINING1,, 3 | -------------------------------------------------------------------------------- /data/tariffplans/phoenix/RatingProfiles.json: -------------------------------------------------------------------------------- 1 | {"Tenant":"t1", "Direction":"*out", "Category":"call", "Subject":"t1", "Activations":[ 2 | {"ActivationTime":"2012-01-01T00:00:00Z", "RatingPlanTag":"STANDARD"} 3 | ]} 4 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/multiid/RatingProfiles.csv: -------------------------------------------------------------------------------- 1 | #Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject,CdrStatQueueIds 2 | *out,cgrates.org,call,*any,2012-01-01T00:00:00Z,RP_RETAIL,, -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/cdr.conf: -------------------------------------------------------------------------------- 1 | [general] 2 | enable=yes 3 | 4 | [custom] 5 | ; We log the unique ID as it can be useful for troubleshooting any issues 6 | ; that arise. 7 | loguniqueid=yes 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.7 5 | 6 | install: 7 | - go get github.com/Masterminds/glide 8 | - glide install 9 | 10 | script: go test -v $(glide novendor) 11 | 12 | branches: 13 | only: master 14 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/multiid/DestinationRates.csv: -------------------------------------------------------------------------------- 1 | #Tag,DestinationsTag,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy 2 | DR_RETAIL,GERMANY,RT_1CENT,*up,4,0, 3 | DR_SMS_1,EUROPE,RT_SMS_5c,*up,4,0, 4 | 5 | -------------------------------------------------------------------------------- /sessionmanager/osipssm_test.go: -------------------------------------------------------------------------------- 1 | 2 | package sessionmanager 3 | 4 | import ( 5 | "testing" 6 | ) 7 | 8 | func TestOsipsSMInterface(t *testing.T) { 9 | var _ SessionManager = SessionManager(new(OsipsSessionManager)) 10 | } 11 | -------------------------------------------------------------------------------- /data/storage/mongo/create_user.js: -------------------------------------------------------------------------------- 1 | 2 | db = db.getSiblingDB('admin') 3 | db.createUser( 4 | { 5 | user: "accurate", 6 | pwd: "accuRate", 7 | roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] 8 | } 9 | ) 10 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/Rates.csv: -------------------------------------------------------------------------------- 1 | #Tag,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart 2 | RT_1CENT,0,1,1s,1s,0s 3 | RT_DATA_2c,0,0.002,10,10,0 4 | RT_SMS_5c,0,0.005,1,1,0 5 | RT_DATA_r,0,0.1,1048576,10240,0 6 | RT_ZERO,0,0,1,1,0 7 | -------------------------------------------------------------------------------- /sessionmanager/fssessionmanager_test.go: -------------------------------------------------------------------------------- 1 | 2 | package sessionmanager 3 | 4 | import ( 5 | "testing" 6 | ) 7 | 8 | func TestFSSMInterface(t *testing.T) { 9 | var _ SessionManager = SessionManager(new(FSSessionManager)) 10 | } 11 | -------------------------------------------------------------------------------- /sessionmanager/kamailiosm_test.go: -------------------------------------------------------------------------------- 1 | 2 | package sessionmanager 3 | 4 | import ( 5 | "testing" 6 | ) 7 | 8 | func TestKamSMInterface(t *testing.T) { 9 | var _ SessionManager = SessionManager(new(KamailioSessionManager)) 10 | } 11 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/RatingPlans.csv: -------------------------------------------------------------------------------- 1 | #Tag,DestinationRatesTag,TimingTag,Weight 2 | RP_RETAIL,DR_RETAIL,ALWAYS,10 3 | RP_DATA1,DR_DATA_1,ALWAYS,10 4 | RP_SMS1,DR_SMS_1,ALWAYS,10 5 | RP_DATAr,DR_DATA_r,ALWAYS,10 6 | RP_FREE,DR_FREE,ALWAYS,10 7 | -------------------------------------------------------------------------------- /calls_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | 3 | ./local_test.sh 4 | lcl=$? 5 | echo 'go test github.com/accurateproject/accurate/general_tests -calls' 6 | go test github.com/accurateproject/accurate/general_tests -calls 7 | gnr=$? 8 | 9 | exit $gen && $gnr -------------------------------------------------------------------------------- /engine/rawcdr.go: -------------------------------------------------------------------------------- 1 | 2 | package engine 3 | 4 | // RawCDR is the original CDR received from external sources (eg: FreeSWITCH) 5 | type RawCdr interface { 6 | AsStoredCdr(string) *CDR // Convert the inbound Cdr into internally used one, CgrCdr 7 | } 8 | -------------------------------------------------------------------------------- /data/storage/mongo/setup_cgr_db.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | 3 | 4 | mongo --quiet create_user.js 5 | cu=$? 6 | 7 | if [ $cu = 0 ]; then 8 | echo "" 9 | echo "\t+++ CGR-DB successfully set-up! +++" 10 | echo "" 11 | exit 0 12 | fi 13 | 14 | 15 | -------------------------------------------------------------------------------- /data/conf/samples/hapool/dagent/cgr.json: -------------------------------------------------------------------------------- 1 | { 2 | "diameter_agent": { 3 | "enabled": true, 4 | "listen": "127.0.0.1:3868", 5 | "sm_generic_conns": [ 6 | {"address": "127.0.0.1:2018"}, 7 | {"address": "127.0.0.1:2020"} 8 | ], 9 | }, 10 | } 11 | -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/logger.conf: -------------------------------------------------------------------------------- 1 | [general] 2 | 3 | [logfiles] 4 | 5 | console = verbose,notice,warning,error 6 | 7 | ;messages = notice,warning,error 8 | ;full = verbose,notice,warning,error,debug 9 | ;security = security 10 | -------------------------------------------------------------------------------- /data/docker/devel/README.md: -------------------------------------------------------------------------------- 1 | Docker 2 | ======= 3 | 4 | From the project root: 5 | 6 | ``` bash 7 | # build the image 8 | docker build -t accurate data/docker/devel 9 | # create the container from the accurate project roor 10 | ./data/docker/devel/run.sh 11 | ``` 12 | -------------------------------------------------------------------------------- /data/docker/prod/README.md: -------------------------------------------------------------------------------- 1 | Docker 2 | ======= 3 | 4 | From the project root: 5 | 6 | ``` bash 7 | # build the image 8 | docker build -t accurate data/docker/prod 9 | # create the container 10 | docker run --rm -itv `pwd`:/root/code --name cgr accurate 11 | ``` 12 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/Aliases.csv: -------------------------------------------------------------------------------- 1 | #Direction,Tenant,Category,Account,Subject,DestinationId,Context,Target,Original,Alias,Weight 2 | *out,cgrates.org,call,1006,1006,*any,*rating,Subject,1006,1001,10 3 | *out,cgrates.org,call,1006,1006,*any,*rating,Account,1006,1002,10 4 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/Aliases.csv: -------------------------------------------------------------------------------- 1 | #Direction,Tenant,Category,Account,Subject,DestinationId,Context,Target,Original,Alias,Weight 2 | *out,cgrates.org,call,1006,1006,*any,*rating,Subject,1006,1001,10 3 | *out,cgrates.org,call,1006,1006,*any,*rating,Account,1006,1002,10 4 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/Timings.csv: -------------------------------------------------------------------------------- 1 | #Tag,Years,Months,MonthDays,WeekDays,Time 2 | PEAK,*any,*any,*any,1;2;3;4;5,08:00:00 3 | OFFPEAK_MORNING,*any,*any,*any,1;2;3;4;5,00:00:00 4 | OFFPEAK_EVENING,*any,*any,*any,1;2;3;4;5,19:00:00 5 | OFFPEAK_WEEKEND,*any,*any,*any,6;7,00:00:00 -------------------------------------------------------------------------------- /docs/advanced.rst: -------------------------------------------------------------------------------- 1 | 6. Advanced Topics 2 | ================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | apicalls 8 | cdrserver 9 | cdrclient 10 | cdrexporter 11 | cdrstats 12 | lcr 13 | derived_charging 14 | history 15 | ratinglogic 16 | 17 | 18 | -------------------------------------------------------------------------------- /run_devel_docker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ./build.sh 3 | 4 | docker run -d -p 27017:27017 --name db mongo 5 | docker run --rm -p 2012:2012 -p 2013:2013 -p 2080:2080 --link db:mongo -itv `pwd`:/go/src/github.com/accurateproject/accurate --name cc accurate 6 | #docker-compose run --rm accurate 7 | -------------------------------------------------------------------------------- /data/storage/mysql/create_db_with_users.sql: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- Sample db and users creation. Replace here with your own details 4 | -- 5 | 6 | DROP DATABASE IF EXISTS accurate; 7 | CREATE DATABASE accurate; 8 | 9 | GRANT ALL on accurate.* TO 'accurate'@'localhost' IDENTIFIED BY 'accuRate'; 10 | -------------------------------------------------------------------------------- /data/docker/osips_training/README.md: -------------------------------------------------------------------------------- 1 | Docker 2 | ======= 3 | 4 | From the project root: 5 | 6 | ``` bash 7 | # build the image 8 | docker build -t accurate data/docker/osips_training 9 | # create the container from the accurate project root 10 | ./data/docker/osips_training/start.sh 11 | ``` 12 | -------------------------------------------------------------------------------- /utils/logger.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "log" 5 | 6 | "go.uber.org/zap" 7 | ) 8 | 9 | var Logger *zap.Logger 10 | 11 | func init() { 12 | var err error 13 | Logger, err = zap.NewProduction() 14 | if err != nil { 15 | log.Print("Cannot initialize logging") 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/Makefile: -------------------------------------------------------------------------------- 1 | make deb: 2 | cd ..;\ 3 | ln -sf packages/jessie debian ;\ 4 | dpkg-buildpackage -rfakeroot -tc; \ 5 | rm debian 6 | 7 | make squeeze: 8 | cd ..;\ 9 | ln -sf packages/squeeze debian ;\ 10 | dpkg-buildpackage -rfakeroot -tc; \ 11 | rm debian 12 | 13 | .PHONY: deb squeeze 14 | -------------------------------------------------------------------------------- /data/conf/samples/storage/mongo/cgrates.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file used for testing mongo implementation 3 | 4 | "stor_db": { 5 | "db_type": "mongo", // stor database type to use: 6 | "db_port": 27017, // the port to reach the stordb 7 | }, 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /packages/redhat_fedora/cgrates.options: -------------------------------------------------------------------------------- 1 | # sysconfig file for CGRateS real-time charging system 2 | 3 | # what extra options to give cgrates binary? 4 | # See cgr-engine -h for options 5 | #OPTIONS='' 6 | 7 | # Don't forget to create an appropriate config file, 8 | # else the CGRateS system will not start. 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | a.out 2 | *.a 3 | *.6 4 | *.pyc 5 | *~ 6 | .settings 7 | *project 8 | *workspace 9 | docs/_* 10 | bin 11 | .idea 12 | dean* 13 | data/vagrant/.vagrant 14 | data/vagrant/vagrant_ansible_inventory_default 15 | data/tutorials/fs_evsock/freeswitch/etc/freeswitch/ 16 | vendor 17 | *.test 18 | glide.lock 19 | .tern-port 20 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/addback/Destinations.csv: -------------------------------------------------------------------------------- 1 | #Tag,Prefix 2 | GERMANY,+49 3 | GERMANY_MOBILE,+4915 4 | GERMANY_MOBILE,+4916 5 | GERMANY_MOBILE,+4917 6 | DATA_DEST,222 7 | ROMANIA,+40 8 | ROMANIA_MOBILE,+4072 9 | ROMANIA_MOBILE,+4073 10 | ROMANIA_MOBILE,+4074 11 | ROMANIA_MOBILE,+4072 12 | EUROPE,+40 13 | EUROPE,+49 14 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/alldests/Destinations.csv: -------------------------------------------------------------------------------- 1 | #Tag,Prefix 2 | GERMANY,+49 3 | GERMANY_MOBILE,+4915 4 | GERMANY_MOBILE,+4916 5 | GERMANY_MOBILE,+4917 6 | DATA_DEST,222 7 | ROMANIA,+40 8 | ROMANIA_MOBILE,+4072 9 | ROMANIA_MOBILE,+4073 10 | ROMANIA_MOBILE,+4074 11 | ROMANIA_MOBILE,+4072 12 | EUROPE,+40 13 | EUROPE,+49 14 | -------------------------------------------------------------------------------- /engine/groups.go: -------------------------------------------------------------------------------- 1 | package engine 2 | 3 | import ( 4 | "sort" 5 | ) 6 | 7 | type GroupLink struct { 8 | Id string 9 | Weight float64 10 | } 11 | 12 | type GroupLinks []*GroupLink 13 | 14 | func (gls GroupLinks) Sort() { 15 | sort.Slice(gls, func(j, i int) bool { 16 | return gls[i].Weight < gls[j].Weight 17 | }) 18 | } 19 | -------------------------------------------------------------------------------- /data/storage/postgres/create_db_with_users.sh: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Sample db and users creation. Replace here with your own details 4 | # 5 | 6 | sudo -u postgres dropdb -e accurate 7 | sudo -u postgres dropuser -e accurate 8 | sudo -u postgres psql -c "CREATE USER accurate password 'accuRate';" 9 | sudo -u postgres createdb -e -O accurate accurate 10 | -------------------------------------------------------------------------------- /balancer2go/README.md: -------------------------------------------------------------------------------- 1 | balancer2go 2 | =========== 3 | 4 | Simple golang balancer library 5 | 6 | See the test file for wroking examples. 7 | 8 | API docs [here](http://go.pkgdoc.org/github.com/rif/balancer2go). 9 | 10 | Continous integration: [![Build Status](https://secure.travis-ci.org/rif/balancer2go.png)](http://travis-ci.org/rif/balancer2go) -------------------------------------------------------------------------------- /data/tariffplans/phoenix/Users.json: -------------------------------------------------------------------------------- 1 | {"Tenant":"t1", "Name":"t1", "Weight":10, 2 | "Query":"{'sip_from_host':{'$in':['206.222.29.2','206.222.29.3','206.222.29.4','206.222.29.5','206.222.29.6']}, 'Destination':{'$crepl':['^9023(\\\\d+)','${1}']}, 'Account':{'$usr':'t1'}, 'Tenant':{'$usr':'t1'}, 'Subject':{'$usr':'t1'}, 'direction':{'$usr': 'outbound'}}"} 3 | -------------------------------------------------------------------------------- /data/diameter/dict/huawei/nokia.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/tut_jitsi_installs.rst: -------------------------------------------------------------------------------- 1 | SIP UA - Jitsi_ 2 | --------------- 3 | 4 | On our ubuntu desktop host, we have installed Jitsi_ to be used as SIP UA, out of stable provided packages on `Jitsi download `_ and had Jitsi_ configured with 4 accounts: 1001/1234, 1002/1234, 1003/1234 and 1004/1234. 5 | 6 | .. _Jitsi: http://www.jitsi.org/ -------------------------------------------------------------------------------- /packages/jessie/copyright: -------------------------------------------------------------------------------- 1 | Original packaging work by: 2 | Gustavo Niemeyer on Wed, 02 Feb 2011 11:38:38 -0200 3 | 4 | Downloaded from: 5 | http://launchpad.net/lbox 6 | 7 | The Debian packaging is: 8 | Copyright (C) 2011 Canonical Ltd. 9 | 10 | Further development: 11 | Copyright (C) 2016 Radu Ioan Fericean 12 | -------------------------------------------------------------------------------- /packages/squeeze/copyright: -------------------------------------------------------------------------------- 1 | Original packaging work by: 2 | Gustavo Niemeyer on Wed, 02 Feb 2011 11:38:38 -0200 3 | 4 | Downloaded from: 5 | http://launchpad.net/lbox 6 | 7 | The Debian packaging is: 8 | Copyright (C) 2011 Canonical Ltd. 9 | 10 | Further development: 11 | Copyright (C) 2016 Radu Ioan Fericean 12 | -------------------------------------------------------------------------------- /data/tariffplans/osips_training/AccountActions.csv: -------------------------------------------------------------------------------- 1 | #Tenant,Account,ActionPlanId,ActionTriggersId,AllowNegative,Disabled 2 | cgrates.org,101,TEST_ACCOUNT,TEST_THRESHOLDS,, 3 | cgrates.org,102,TEST_ACCOUNT,TEST_THRESHOLDS,, 4 | cgrates.org,103,TEST_ACCOUNT,TEST_THRESHOLDS,, 5 | cgrates.org,104,TEST_ACCOUNT,TEST_THRESHOLDS,, 6 | cgrates.org,105,TEST_ACCOUNT,TEST_THRESHOLDS,, 7 | -------------------------------------------------------------------------------- /data/tariffplans/test/destinations/addone/Destinations.csv: -------------------------------------------------------------------------------- 1 | #Tag,Prefix 2 | GERMANY,+49 3 | GERMANY_MOBILE,+4915 4 | GERMANY_MOBILE,+4916 5 | GERMANY_MOBILE,+4917 6 | DATA_DEST,222 7 | ROMANIA,+40 8 | ROMANIA_MOBILE,+4072 9 | ROMANIA_MOBILE,+4073 10 | ROMANIA_MOBILE,+4074 11 | ROMANIA_MOBILE,+4072 12 | HUNGARY,+36 13 | EUROPE,+40 14 | EUROPE,+49 15 | EUROPE,+36 16 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/DestinationRates.csv: -------------------------------------------------------------------------------- 1 | #Tag,DestinationsTag,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy 2 | DR_RETAIL,GERMANY,RT_1CENT,*up,4,0, 3 | DR_RETAIL,GERMANY_MOBILE,RT_1CENT,*up,4,0, 4 | DR_DATA_1,*any,RT_DATA_2c,*up,4,0, 5 | DR_SMS_1,*any,RT_SMS_5c,*up,4,0, 6 | DR_DATA_r,DATA_DEST,RT_DATA_r,*up,5,0, 7 | DR_FREE,GERMANY,RT_ZERO,*middle,2,0, 8 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/AccountActions.csv: -------------------------------------------------------------------------------- 1 | #Tenant,Account,ActionPlanId,ActionTriggersId,AllowNegative,Disabled 2 | cgrates.org,1001,PACKAGE_1001,STANDARD_TRIGGERS,, 3 | cgrates.org,1002,PACKAGE_10,STANDARD_TRIGGERS,, 4 | cgrates.org,1003,PACKAGE_10,STANDARD_TRIGGERS,, 5 | cgrates.org,1004,PACKAGE_10,STANDARD_TRIGGERS,, 6 | cgrates.org,1007,USE_SHARED_A,STANDARD_TRIGGERS,, 7 | -------------------------------------------------------------------------------- /data/scripts/freeswitch_cdr_csv_rotate.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | 3 | FS_CDR_CSV_DIR=/var/log/freeswitch/cdr-csv 4 | CGR_CDRC_IN_DIR=/var/log/cgrates/cdr/cdrc/in 5 | 6 | /usr/bin/fs_cli -x "cdr_csv rotate" 7 | 8 | find $FS_CDR_CSV_DIR -maxdepth 1 -mindepth 1 -not -name *.csv -exec chown cgrates:cgrates '{}' \; -exec mv '{}' $CGR_CDRC_IN_DIR \; 9 | 10 | exit 0 11 | 12 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/Rates.csv: -------------------------------------------------------------------------------- 1 | #Id,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart 2 | RT_10CNT,0.2,0.1,60s,60s,0s 3 | RT_10CNT,0,0.05,60s,1s,60s 4 | RT_20CNT,0.4,0.2,60s,60s,0s 5 | RT_20CNT,0,0.1,60s,1s,60s 6 | RT_40CNT,0.8,0.4,60s,30s,0s 7 | RT_40CNT,0,0.2,60s,10s,60s 8 | RT_1CNT,0,0.01,60s,60s,0s 9 | RT_1CNT_PER_SEC,0,0.01,1s,1s,0s 10 | RT_GENERIC_1,0,1,1,1,0 11 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/ActionPlans.csv: -------------------------------------------------------------------------------- 1 | #Tag,ActionsTag,TimingTag,Weight 2 | PREPAID_10,PREPAID_10,ASAP,10 3 | PREPAID_10,BONUS_1,ASAP,10 4 | TEST_EXE,TOPUP_EXE,ALWAYS,10 5 | TEST_DATA_r,TOPUP_DATA_r,ASAP,10 6 | TEST_VOICE,TOPUP_VOICE,ASAP,10 7 | TEST_NEG,TOPUP_NEG,ASAP,10 8 | TEST_RPC,RPC,ALWAYS,10 9 | TEST_RPC,RPC_DEST,ALWAYS,10 10 | TEST_RPC,RPC_CDRSTATS,ALWAYS,10 11 | TEST_DID,DID,ALWAYS,10 12 | -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/extensions.conf: -------------------------------------------------------------------------------- 1 | [internal] 2 | exten => _1XXX,1,NoOp() 3 | same => n,Set(CGRMaxSessionTime=0); use it to disconnect automatically the call if bridge is not active 4 | same => n,DumpChan() 5 | same => n,Stasis(cgrates_auth,cgr_reqtype=*prepaid,cgr_supplier=supplier1) 6 | same => n,Dial(PJSIP/${EXTEN},30,L(${CGRMaxSessionTime})) 7 | same => n,Hangup() 8 | 9 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/ActionPlans.csv: -------------------------------------------------------------------------------- 1 | #Id,ActionsId,TimingId,Weight 2 | PACKAGE_10,TOPUP_RST_10,*asap,10 3 | PACKAGE_10_SHARED_A_5,TOPUP_RST_5,*asap,10 4 | PACKAGE_10_SHARED_A_5,TOPUP_RST_SHARED_5,*asap,10 5 | USE_SHARED_A,SHARED_A_0,*asap,10 6 | PACKAGE_1001,TOPUP_RST_5,*asap,10 7 | PACKAGE_1001,TOPUP_RST_SHARED_5,*asap,10 8 | PACKAGE_1001,TOPUP_120_DST1003,*asap,10 9 | PACKAGE_1001,TOPUP_RST_DATA_100,*asap,10 10 | -------------------------------------------------------------------------------- /data/conf/samples/multiral2/cgrates.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used for multiple RAL configuration tests 5 | // Starts RAL 6 | 7 | "listen": { 8 | "rpc_json": ":12012", 9 | "rpc_gob": ":12013", 10 | "http": ":12080", 11 | }, 12 | 13 | "rals": { 14 | "enabled": true, 15 | }, 16 | 17 | "cdrs": { 18 | "enabled": true, 19 | }, 20 | 21 | "sm_generic": { 22 | "enabled": true, 23 | }, 24 | 25 | } -------------------------------------------------------------------------------- /packages/redhat_fedora/cgrates.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Carrier Grade Real-time Charging System 3 | After=network.target mysqld.service postgresql.service redis.service 4 | 5 | [Service] 6 | Type=simple 7 | User=cgrates 8 | Group=cgrates 9 | EnvironmentFile=-/etc/sysconfig/cgrates 10 | ExecStart=/usr/bin/cgr-engine $OPTIONS 11 | Restart=always 12 | TimeoutStopSec=30s 13 | 14 | [Install] 15 | WantedBy=multi-user.target 16 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/Destinations.json: -------------------------------------------------------------------------------- 1 | {"Tenant":"tut", "Code": "1002", "Tag": "DST_1002"} 2 | {"Tenant":"tut", "Code": "1003", "Tag": "DST_1003"} 3 | {"Tenant":"tut", "Code": "1007", "Tag": "DST_1007"} 4 | {"Tenant":"tut", "Code": "10", "Tag": "DST_FS"} 5 | {"Tenant":"tut", "Code": "+49151", "Tag": "DST_DE_MOBILE"} 6 | {"Tenant":"tut", "Code": "+49161", "Tag": "DST_DE_MOBILE"} 7 | {"Tenant":"tut", "Code": "+49171", "Tag": "DST_DE_MOBILE"} 8 | -------------------------------------------------------------------------------- /data/docker/devel/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | mongo: 4 | image: "mongo:latest" 5 | container_name: db 6 | ports: 7 | - "27017:27017" 8 | accurate: 9 | image: accurate 10 | container_name: cc 11 | build: data/docker/devel 12 | ports: 13 | - "2012:2012" 14 | - "2013:2013" 15 | - "2080:2080" 16 | volumes: 17 | - ../../../:/go/src/github.com/accurateproject/accurate 18 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/RatingProfiles.csv: -------------------------------------------------------------------------------- 1 | #Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject,CdrStatQueueIds 2 | *out,cgrates.org,call,*any,2012-01-01T00:00:00Z,RP_RETAIL,, 3 | *out,cgrates.org,data,*any,2012-01-01T00:00:00Z,RP_DATA1,, 4 | *out,cgrates.org,sms,*any,2012-01-01T00:00:00Z,RP_SMS1,, 5 | *out,cgrates.org,data,datar,2016-01-01T00:00:00Z,RP_DATAr,, 6 | *out,cgrates.org,call,free,2016-01-01T00:00:00Z,RP_FREE,, 7 | -------------------------------------------------------------------------------- /data/conf/samples/multiral1/cgrates.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used for multiple RAL configuration tests 5 | // Starts rater, scheduler 6 | 7 | "listen": { 8 | "rpc_json": ":2012", // RPC JSON listening address 9 | "rpc_gob": ":2013", // RPC GOB listening address 10 | "http": ":2080", // HTTP listening address 11 | }, 12 | 13 | "rals": { 14 | "enabled": true, // enable Rater service: 15 | }, 16 | 17 | } -------------------------------------------------------------------------------- /data/docker/prod/start.sh: -------------------------------------------------------------------------------- 1 | /etc/init.d/mysql start 2 | /etc/init.d/postgresql start 3 | /etc/init.d/redis-server start 4 | 5 | cd /usr/share/accurate/storage/mysql && ./setup_cgr_db.sh root accuRate 6 | cd /usr/share/accurate/storage/postgres && ./setup_cgr_db.sh 7 | 8 | /usr/share/accurate/tutorials/fs_evsock/freeswitch/etc/init.d/freeswitch start 9 | /usr/share/accurate/tutorials/fs_evsock/cgrates/etc/init.d/cgrates start 10 | 11 | bash --rcfile /root/.bashrc 12 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/ResourceLimits.csv: -------------------------------------------------------------------------------- 1 | #Id,FilterType,FilterFieldName,FilterValues,ActivationTime,Weight,Limit,ActionTriggers 2 | ResGroup1,*string,Account,1001;1002,2014-07-29T15:00:00Z,10,2, 3 | ResGroup1,*string_prefix,Destination,10;20,2014-07-29T15:00:00Z,10,, 4 | ResGroup1,*rsr_fields,,Subject(~^1.*1$);Destination(1002),,,, 5 | ResGroup2,*destinations,Destination,DST_FS,2014-07-29T15:00:00Z,10,2, 6 | ResGroup2,*cdr_stats,,CDRST1:*min_ASR:34;CDRST_1001:*min_ASR:20,,,, 7 | -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/asterisk.conf: -------------------------------------------------------------------------------- 1 | [directories] 2 | astetcdir => /usr/share/cgrates/tutorials/asterisk_events/asterisk/etc/asterisk 3 | astspooldir => /tmp/cgr_astevents/asterisk/spool 4 | astlogdir => /tmp/cgr_astevents/asterisk/log 5 | astrundir => /tmp/cgr_astevents/asterisk/run 6 | 7 | [options] 8 | runuser = asterisk ; The user to run as. The default is root. 9 | rungroup = asterisk ; The group to run as. The default is root 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/squeeze/cgrates.default: -------------------------------------------------------------------------------- 1 | # defaults file for CGRateS real-time charging system 2 | 3 | # start CGRateS init.d script? 4 | # starts with "true" 5 | ENABLE=false 6 | 7 | # Start with specific user/group 8 | #USER=cgrates 9 | #GROUP=cgrates 10 | 11 | # what extra options to give cgrates binary? 12 | # See cgr-engine -h for options 13 | #DAEMON_OPTS='' 14 | 15 | # Don't forget to create an appropriate config file, 16 | # else the CGRateS system will not start. 17 | 18 | -------------------------------------------------------------------------------- /docs/cgrates_json.rst: -------------------------------------------------------------------------------- 1 | 4.1. cgr-engine configuration file 2 | ============================= 3 | 4 | Organized into configuration sections. All configuration options come with defaults and we have tried our best to choose the best ones for a minimum of efforts necessary when running. 5 | 6 | Below is the default configuration file which comes hardcoded into **cgr-engine**. 7 | 8 | .. literalinclude:: ../data/conf/cgrates/cgrates.json 9 | :language: javascript 10 | :linenos: 11 | -------------------------------------------------------------------------------- /utils/loader_json.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "encoding/json" 5 | "io" 6 | ) 7 | 8 | func LoadJSON(r io.Reader, newElement func() interface{}, callback func(interface{}) error) error { 9 | dec := json.NewDecoder(r) 10 | for { 11 | el := newElement() 12 | if err := dec.Decode(&el); err == io.EOF { 13 | break 14 | } else if err != nil { 15 | return err 16 | } 17 | if err := callback(el); err != nil { 18 | return err 19 | } 20 | } 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /packages/jessie/control: -------------------------------------------------------------------------------- 1 | Source: cgrates 2 | Section: base 3 | Priority: optional 4 | Maintainer: DanB 5 | Build-Depends: debhelper, git 6 | Standards-Version: 3.9.1 7 | Homepage: http://cgrates.org 8 | 9 | Package: cgrates 10 | Architecture: amd64 11 | Suggests: git, redis-server, mysql-server 12 | Version: 0.9.1-rc8 13 | Description: Carrier Grade Real-time Charging System 14 | CGRateS is a very fast and easy scalable real-time charging system for Telecom environments. 15 | -------------------------------------------------------------------------------- /packages/squeeze/control: -------------------------------------------------------------------------------- 1 | Source: cgrates 2 | Section: base 3 | Priority: optional 4 | Maintainer: DanB 5 | Build-Depends: debhelper, git 6 | Standards-Version: 3.9.1 7 | Homepage: http://cgrates.org 8 | 9 | Package: cgrates 10 | Architecture: amd64 11 | Suggests: git, redis-server, mysql-server 12 | Version: 0.9.1-rc8 13 | Description: Carrier Grade Real-time Charging System 14 | CGRateS is a very fast and easy scalable real-time charging system for Telecom environments. 15 | -------------------------------------------------------------------------------- /data/scripts/header.sh: -------------------------------------------------------------------------------- 1 | # check for arguments 2 | if [ $# -ne 1 ] 3 | then 4 | echo "Error in $0 - Invalid Argument Count" 5 | echo "Syntax: $0 input_file - copyright header file" 6 | exit 7 | fi 8 | 9 | # check for header file 10 | infile=$1 11 | if [ ! -f $infile ] 12 | then 13 | echo "Input file [$infile] not found - Aborting" 14 | exit 15 | fi 16 | 17 | # inject header 18 | for i in *.go 19 | do 20 | if ! grep -q Copyright $i 21 | then 22 | cat $infile $i >$i.new && mv $i.new $i 23 | fi 24 | done 25 | -------------------------------------------------------------------------------- /data/tariffplans/osips_training/Actions.csv: -------------------------------------------------------------------------------- 1 | #ActionsId[0],Action[1],ExtraParameters[2],Filter[3],BalanceId[4],BalanceType[5],Directions[6],Categories[7],DestinationIds[8],RatingSubject[9],SharedGroup[10],ExpiryTime[11],TimingIds[12],Units[13],BalanceWeight[14],BalanceBlocker[15],BalanceDisabled[16],Weight[17] 2 | TOPUP_MONETARY_5,*topup_reset,,,,*monetary,*out,,*any,,,*unlimited,,10,10,false,false,10 3 | TOPUP_VOICE_200,*topup_reset,,,,*voice,*out,,DST_ON_NET,,,*unlimited,,12000,20,false,false,10 4 | LOG_WARNING,*log,,,,,,,,,,,,,,false,false,10 5 | -------------------------------------------------------------------------------- /docs/tut_freeswitch.rst: -------------------------------------------------------------------------------- 1 | FreeSWITCH Integration Tutorials 2 | ================================ 3 | 4 | In these tutorials we exemplify few cases of integration between FreeSWITCH_ and **AccuRate**. We start with common steps, installation and postinstall processes then we dive into particular configurations. 5 | 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | 10 | tut_freeswitch_installs 11 | tut_cgrates_installs 12 | tut_jitsi_installs 13 | tut_freeswitch_json 14 | tut_cgrates_usage 15 | 16 | .. _FreeSWITCH: http://www.freeswitch.org/ 17 | 18 | -------------------------------------------------------------------------------- /data/monit/cgrates.monit: -------------------------------------------------------------------------------- 1 | # AccuRate Monit check script 2 | 3 | check process AccuRate with pidfile /var/run/cgrates/cgr-engine.pid 4 | start program = "/etc/init.d/cgrates start" 5 | stop program = "/etc/init.d/cgrates stop" 6 | if failed host 127.0.0.1 port 2012 type TCP 4 times within 4 cycles then restart # Rater 7 | if failed host 127.0.0.1 port 2013 type TCP 4 times within 4 cycles then restart # History 8 | if failed host 127.0.0.1 port 2080 type TCP 4 times within 4 cycles then restart # CDRS 9 | if 5 restarts within 20 cycles then timeout 10 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/DerivedChargers.csv: -------------------------------------------------------------------------------- 1 | #Direction[0],Tenant[1],Category[2],Account[3],Subject[4],DestinationIds[5],RunId[6],RunFilter[7],ReqTypeField[8],DirectionField[9],TenantField[10],CategoryField[11],AccountField[12],SubjectField[13],DestinationField[14],SetupTimeField[15],PddField[16],AnswerTimeField[17],UsageField[18],SupplierField[19],DisconnectCause[20],RatedField[21],CostField[22] 2 | *out,cgrates.org,call,1001,1001,,derived_run1,,^*rated,*default,*default,*default,*default,^1002,*default,*default,*default,*default,*default,*default,*default,*default,*default 3 | -------------------------------------------------------------------------------- /docs/administration.rst: -------------------------------------------------------------------------------- 1 | 5. Administration 2 | ================= 3 | 4 | The general steps to get AccuRate operational are: 5 | 6 | #. Create CSV files containing the initial data for AccuRate. 7 | #. Load the data in the databases using the Loader application. 8 | #. Start the a Balancer or a Rater. If Balancer is used, start one or more Raters serving that Balancer. 9 | #. Start the SessionManager talking to your VoIP Switch or directly make API calls to the Balancer/Rater. 10 | #. Make API calls to the Balancer/Rater or just let the SessionManager do the work. 11 | 12 | -------------------------------------------------------------------------------- /data/conf/samples/cdrsv2mysql/cdrsv2mysql.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used in apier_local_tests 5 | // Starts rater, cdrs and mediator connecting over internal channel 6 | 7 | "rals": { 8 | "enabled": true, // enable Rater service: 9 | }, 10 | 11 | "cdrs": { 12 | "enabled": true, // start the CDR Server service: 13 | "rals_conns": [ 14 | {"address": "*internal"} // address where to reach the Rater for cost calculation, empty to disable functionality: <""|*internal|x.y.z.y:1234> 15 | ], 16 | }, 17 | 18 | } 19 | -------------------------------------------------------------------------------- /data/docker/osips_training/start.sh: -------------------------------------------------------------------------------- 1 | # edit servers config files 2 | sed -i 's/127.0.0.1/0.0.0.0/g' /etc/redis/redis.conf /etc/mysql/my.cnf 3 | 4 | # start services 5 | service rsyslog start 6 | service mysql start 7 | service redis-server start 8 | /root/code/bin/cgr-engine -config_dir /root/cgr/data/conf/samples/osips_training 9 | 10 | # setup mysql 11 | cd /usr/share/accurate/storage/mysql && ./setup_cgr_db.sh root accuRate 12 | 13 | # load tariff plan data 14 | #cd /root/cgr/data/tariffplans/osips_training; cgr-loader 15 | 16 | cd /root/cgr 17 | DISABLE_AUTO_UPDATE="true" zsh 18 | -------------------------------------------------------------------------------- /data/conf/samples/smfs/smfs.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | // This file contains the default configuration hardcoded into AccuRate. 4 | // This is what you get when you load AccuRate with an empty configuration file. 5 | 6 | 7 | "sm_freeswitch": { 8 | "enabled": true, 9 | "rals_conns": [ 10 | {"address": "127.0.0.1:2013"} 11 | ], 12 | "cdrs_conns": [ 13 | {"address": "127.0.0.1:2013"} 14 | ], 15 | "debit_interval": "5s", 16 | "channel_sync_interval": "10s", 17 | "event_socket_conns":[ 18 | {"address": "127.0.0.1:8021", "password": "ClueCon", "reconnects": 5} 19 | ], 20 | }, 21 | 22 | } 23 | -------------------------------------------------------------------------------- /docs/csv_tpdestinations.rst: -------------------------------------------------------------------------------- 1 | Destinations.csv 2 | ++++++++++++++++ 3 | 4 | Group together prefixes into destination groups identified by tag. 5 | 6 | CSV fields example as tabular representation: 7 | 8 | +------------+--------+ 9 | | Tag | Prefix | 10 | +============+========+ 11 | | GERMANY | 49 | 12 | +------------+--------+ 13 | | GERMANY_O2 | 49176 | 14 | +------------+--------+ 15 | 16 | Index 0 - *Tag* 17 | Free-text field used to reference the specific destination from other files. 18 | 19 | Index 1 - *Prefix* 20 | Destination prefix as group element 21 | 22 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. AccuRate documentation master file, created by 2 | sphinx-quickstart on Mon Mar 5 10:59:27 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to AccuRate's documentation! 7 | =================================== 8 | 9 | Full contents: 10 | ============= 11 | 12 | .. toctree:: 13 | :maxdepth: 2 14 | 15 | introduction 16 | architecture 17 | installation 18 | configuration 19 | administration 20 | advanced 21 | tutorials 22 | miscellaneous 23 | 24 | 25 | -------------------------------------------------------------------------------- /data/tariffplans/osips_training/CdrStats.csv: -------------------------------------------------------------------------------- 1 | #Id[0],QueueLength[1],TimeWindow[2],SaveInerval[3],Metric[4],SetupInterval[5],TOR[6],CdrHost[7],CdrSource[8],ReqType[9],Direction[10],Tenant[11],Category[12],Account[13],Subject[14],DestinationIds[15],PddInterval[16],UsageInterval[17],Supplier[18],DisconnectCause[19],RunIds[20],RatedAccount[21],RatedSubject[22],CostInterval[23],Triggers[24] 2 | STATS_TEST,10,0,10s,ASR,,,,,,,cgrates.org,,,,,,,,,*default,,,,STATS_WARN 3 | STATS_TEST,,,,ACD,,,,,,,,,,,,,,,,,,,, 4 | STATS_TEST,,,,ACC,,,,,,,,,,,,,,,,,,,, 5 | STATS_TEST,,,,TCD,,,,,,,,,,,,,,,,,,,, 6 | STATS_TEST,,,,TCC,,,,,,,,,,,,,,,,,,,, 7 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/DestinationRates.csv: -------------------------------------------------------------------------------- 1 | #Id,DestinationId,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy 2 | DR_1002_20CNT,DST_1002,RT_20CNT,*up,4,0, 3 | DR_1002_10CNT,DST_1002,RT_10CNT,*up,4,0, 4 | DR_1003_20CNT,DST_1003,RT_40CNT,*up,4,0, 5 | DR_1003_10CNT,DST_1003,RT_10CNT,*up,4,0, 6 | DR_FS_40CNT,DST_FS,RT_40CNT,*up,4,0, 7 | DR_FS_10CNT,DST_FS,RT_10CNT,*up,4,0, 8 | DR_SPECIAL_1002,DST_1002,RT_1CNT,*up,4,0, 9 | DR_1007_MAXCOST_DISC,DST_1007,RT_1CNT_PER_SEC,*up,4,0.62,*disconnect 10 | DR_1007_MAXCOST_FREE,DST_1007,RT_1CNT_PER_SEC,*up,4,0.62,*free 11 | DR_GENERIC,*any,RT_GENERIC_1,*up,4,0, 12 | -------------------------------------------------------------------------------- /sessionmanager/sessionmanager.go: -------------------------------------------------------------------------------- 1 | package sessionmanager 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/accurateproject/accurate/engine" 7 | "github.com/accurateproject/rpcclient" 8 | ) 9 | 10 | type SessionManager interface { 11 | Rater() rpcclient.RpcClientConnection 12 | CdrSrv() rpcclient.RpcClientConnection 13 | DebitInterval() time.Duration 14 | DisconnectSession(engine.Event, string, string) error 15 | WarnSessionMinDuration(string, string) 16 | Sessions() []*Session 17 | Timezone() string 18 | Connect() error 19 | Shutdown() error 20 | //RemoveSession(string) 21 | //SyncSessions() error 22 | } 23 | -------------------------------------------------------------------------------- /data/conf/samples/storage/mysql/cgrates.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file used for testing mysql implementation 3 | 4 | "stor_db": { // database used to store offline tariff plans and CDRs 5 | "db_type": "mysql", // stor database type to use: 6 | "db_host": "127.0.0.1", // the host to connect to 7 | "db_port": 3306, // the port to reach the stordb 8 | "db_name": "accurate", // stor database name 9 | "db_user": "accurate", // username to use when connecting to stordb 10 | "db_passwd": "accuRate", // password to use when connecting to stordb 11 | }, 12 | 13 | } 14 | -------------------------------------------------------------------------------- /docs/tut_kamailio.rst: -------------------------------------------------------------------------------- 1 | Kamailio_ Integration Tutorials 2 | =============================== 3 | 4 | In these tutorials we exemplify few cases of integration between Kamailio_ and AccuRate_. We start with common steps, installation and postinstall processes then we dive into particular configurations, depending on the case we run. 5 | 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | 10 | tut_kamailio_installs 11 | tut_cgrates_installs 12 | tut_jitsi_installs 13 | tut_kamailio_evapi 14 | tut_cgrates_usage 15 | 16 | .. _Kamailio: http://www.kamailio.org/ 17 | .. _AccuRate: http://accurateproject.github.io/ 18 | 19 | -------------------------------------------------------------------------------- /docs/tut_opensips.rst: -------------------------------------------------------------------------------- 1 | OpenSIPS_ Integration Tutorials 2 | =============================== 3 | 4 | In these tutorials we exemplify few cases of integration between OpenSIPS_ and AccuRate_. We start with common steps, installation and postinstall processes then we dive into particular configurations, depending on the case we run. 5 | 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | 10 | tut_opensips_installs 11 | tut_cgrates_installs 12 | tut_jitsi_installs 13 | tut_opensips_event 14 | tut_cgrates_usage 15 | 16 | .. _OpenSIPS: http://www.opensips.org/ 17 | .. _AccuRate: http://accurateproject.github.io/ 18 | 19 | -------------------------------------------------------------------------------- /data/conf/samples/storage/postgres/cgrates.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file used for testing mysql implementation 3 | 4 | "stor_db": { // database used to store offline tariff plans and CDRs 5 | "db_type": "postgres", // stor database type to use: 6 | "db_host": "127.0.0.1", // the host to connect to 7 | "db_port": 5432, // the port to reach the stordb 8 | "db_name": "accurate", // stor database name 9 | "db_user": "accurate", // username to use when connecting to stordb 10 | "db_passwd": "accuRate", // password to use when connecting to stordb 11 | }, 12 | 13 | } 14 | -------------------------------------------------------------------------------- /data/conf/samples/cdrsreplicationslave/cdrsreplicationslave.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used in apier_local_tests 5 | // Starts rater, cdrs and mediator connecting over internal channel 6 | 7 | "listen": { 8 | "rpc_json": "127.0.0.1:12012", // RPC JSON listening address 9 | "rpc_gob": "127.0.0.1:12013", // RPC GOB listening address 10 | "http": "127.0.0.1:12080", // HTTP listening address 11 | }, 12 | 13 | "rals": { 14 | "enabled": true, // enable Rater service: 15 | }, 16 | 17 | "cdrs": { 18 | "enabled": true, // start the CDR Server service: 19 | }, 20 | 21 | } -------------------------------------------------------------------------------- /data/scripts/pkg/pkg_cgrates_deb.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | 3 | WORK_DIR=/tmp/cgrates 4 | rm -rf $WORK_DIR 5 | mkdir -p $WORK_DIR 6 | cp -r debian $WORK_DIR/debian 7 | cd $WORK_DIR 8 | git clone https://github.com/accurateproject/accurate.git src/github.com/accurateproject/accurate 9 | tar xvzf src/github.com/accurateproject/accurate/data/tutorials/fs_evsock/freeswitch/etc/freeswitch_conf.tar.gz -C src/github.com/accurateproject/accurate/data/tutorials/fs_evsock/freeswitch/etc/ 10 | rm src/github.com/accurateproject/accurate/data/tutorials/fs_evsock/freeswitch/etc/freeswitch_conf.tar.gz 11 | dpkg-buildpackage -us -uc 12 | #rm -rf $WORK_DIR 13 | -------------------------------------------------------------------------------- /data/storage/postgres/setup_cgr_db.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | 3 | 4 | user=$1 5 | if [ -z "$1" ]; then 6 | user="cgrates" 7 | fi 8 | 9 | host=$2 10 | if [ -z "$2" ]; then 11 | host="localhost" 12 | fi 13 | 14 | DIR="$(dirname "$(readlink -f "$0")")" 15 | 16 | "$DIR"/create_db_with_users.sh 17 | 18 | export PGPASSWORD="accuRate" 19 | 20 | psql -U $user -h $host -d cgrates -f "$DIR"/create_cdrs_tables.sql 21 | cdrt=$? 22 | psql -U $user -h $host -d cgrates -f "$DIR"/create_tariffplan_tables.sql 23 | tpt=$? 24 | 25 | if [ $cdrt = 0 ] && [ $tpt = 0 ]; then 26 | echo -e "\n\t+++ CGR-DB successfully set-up! +++\n" 27 | exit 0 28 | fi 29 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/AccountActions.csv: -------------------------------------------------------------------------------- 1 | #Tenant,Account,ActionPlanId,ActionTriggersId,AllowNegative,Disabled 2 | cgrates.org,1001,PREPAID_10,STANDARD_TRIGGERS,, 3 | cgrates.org,1002,PREPAID_10,STANDARD_TRIGGERS,, 4 | cgrates.org,1003,PREPAID_10,STANDARD_TRIGGERS,, 5 | cgrates.org,1004,PREPAID_10,STANDARD_TRIGGERS,, 6 | cgrates.org,1005,PREPAID_10,STANDARD_TRIGGERS,, 7 | cgrates.org,1009,TEST_EXE,,, 8 | cgrates.org,1010,TEST_DATA_r,,true, 9 | cgrates.org,1011,TEST_VOICE,,, 10 | cgrates.org,1012,PREPAID_10,,, 11 | cgrates.org,1013,TEST_NEG,,, 12 | cgrates.org,1014,TEST_RPC,,, 13 | cgrates.org,1015,TEST_DID,,, 14 | cgrates.org,1016,PREPAID_10,,, 15 | -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/voicemail.conf: -------------------------------------------------------------------------------- 1 | [general] 2 | format = wav49|gsm|wav 3 | 4 | [default] 5 | 6 | 7 | [example] 8 | ; Voicemail context for all internal users in the example.com domain. 9 | 1101 = 0717,Maria Berny 10 | 1102 = 7085,Tommie Briar 11 | 1103 = 1809,Penelope Bronte 12 | 1104 = 0039,Richard Casey 13 | 1105 = 6618,Garnet Claude 14 | 1106 = 9805,Aaron Courtney 15 | 1107 = 7484,Lindsey Freddie 16 | 1108 = 7788,Colby Hildred 17 | 1109 = 5750,Terry Jules 18 | 1110 = 3702,Hollis Justy 19 | 1111 = 1878,Temple Morgan 20 | 1112 = 5497,Franny Ocean 21 | 1113 = 1637,Laverne Roberts 22 | 1114 = 3717,Sal Smith 23 | 1115 = 3088,Dusty Williams 24 | -------------------------------------------------------------------------------- /data/tariffplans/osips_training/ActionTriggers.csv: -------------------------------------------------------------------------------- 1 | #Tag[0],UniqueId[1],ThresholdType[2],ThresholdValue[3],Recurrent[4],MinSleep[5],ExpiryTime[6],ActivationTime[7],BalanceTag[8],BalanceType[9],BalanceDirections[10],BalanceCategories[11],BalanceDestinationIds[12],BalanceRatingSubject[13],BalanceSharedGroup[14],BalanceExpiryTime[15],BalanceTimingIds[16],BalanceWeight[17],BalanceBlocker[18],BalanceDisabled[19],StatsMinQueuedItems[20],ActionsId[21],Weight[22] 2 | TEST_THRESHOLDS,,*min_balance,2,false,0,,,,*monetary,*out,,,,,,,,,,,LOG_WARNING,10 3 | TEST_THRESHOLDS,,*max_balance,20,false,0,,,,*monetary,*out,,,,,,,,,,,LOG_WARNING,10 4 | STATS_WARN,,*min_asr,35,true,1m,,,,,,,,,,,,,,,3,LOG_WARNING,10 5 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/README.md: -------------------------------------------------------------------------------- 1 | AccuRate - FSGermanyPrep1 2 | ========================== 3 | 4 | Scenario: 5 | --------- 6 | 7 | * Create the necessary timings (always, asap). 8 | * Configure 1 destination: FS_USERS. 9 | * Calls to FreeSWITCH users will be free and time independent. 10 | * This rating profile will be valid for any rating subject. 11 | 12 | * Create 5 prepaid accounts (equivalent of 5 FreeSWITCH default test users - 1001, 1002, 1003, 1004, 1005). 13 | * Add to each of the accounts a monetary balance of 10 units. 14 | * For each balance created, attach 3 triggers to control the balance: log on balance=2, log on balance=20, log on 15 mins talked towards FS_USERS destination. 15 | -------------------------------------------------------------------------------- /cache2go/response_cache_test.go: -------------------------------------------------------------------------------- 1 | package cache2go 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func TestRCacheSetGet(t *testing.T) { 9 | rc := NewResponseCache(5 * time.Second) 10 | rc.Cache("test", &CacheItem{Value: "best"}) 11 | v, err := rc.Get("test") 12 | if err != nil || v.Value.(string) != "best" { 13 | t.Error("Error retriving response cache: ", v, err) 14 | } 15 | } 16 | 17 | /* 18 | func TestRCacheExpire(t *testing.T) { 19 | rc := NewResponseCache(1 * time.Microsecond) 20 | rc.Cache("test", &CacheItem{Value: "best"}) 21 | time.Sleep(3 * time.Millisecond) 22 | o, err := rc.Get("test") 23 | if err == nil { 24 | t.Error("Error expiring response cache: ", o) 25 | } 26 | } 27 | */ 28 | -------------------------------------------------------------------------------- /docs/tut_opensips_installs.rst: -------------------------------------------------------------------------------- 1 | Software installation 2 | ===================== 3 | 4 | As operating system we have choosen Debian Jessie, since all the software components we use provide packaging for it. 5 | 6 | OpenSIPS_ 7 | --------- 8 | 9 | We got OpenSIPS_ installed via following commands: 10 | :: 11 | 12 | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 049AD65B 13 | echo "deb http://apt.opensips.org jessie 2.2-releases" >>/etc/apt/sources.list 14 | apt-get update 15 | apt-get install opensips opensips-json-module opensips-restclient-module 16 | 17 | Once installed we proceed with loading the configuration out of specific tutorial cases bellow. 18 | 19 | .. _OpenSIPS: http://www.opensips.org/ 20 | -------------------------------------------------------------------------------- /data/conf/samples/cdrstats/cdrstats.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used in apier_local_tests 5 | // Starts rater, cdrs and mediator connecting over internal channel 6 | 7 | "listen": { 8 | "rpc_json": ":2012", 9 | "rpc_gob": ":2013", 10 | "http": ":2080", 11 | }, 12 | 13 | "rals": { 14 | "enabled": true, 15 | "cdrstats_conns": [ 16 | {"address": "*internal"} 17 | ], 18 | }, 19 | 20 | "cdrs": { 21 | "enabled": true, 22 | "store_cdrs": false, 23 | "rals_conns": [ 24 | {"address": "*internal"} 25 | ], 26 | "cdrstats_conns": [ 27 | {"address": "*internal"} 28 | ] 29 | }, 30 | 31 | "cdrstats": { 32 | "enabled": true, 33 | "save_interval": "1s", 34 | }, 35 | 36 | } 37 | -------------------------------------------------------------------------------- /docs/tut_kamailio_installs.rst: -------------------------------------------------------------------------------- 1 | Software installation 2 | ===================== 3 | 4 | As operating system we have choosen Debian Jessie, since all the software components we use provide packaging for it. 5 | 6 | Kamailio_ 7 | --------- 8 | 9 | We got Kamailio_ installed via following commands: 10 | :: 11 | 12 | apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xfb40d3e6508ea4c8 13 | echo "deb http://deb.kamailio.org/kamailio43 jessie main" > /etc/apt/sources.list.d/kamailio.list 14 | apt-get update 15 | apt-get install kamailio kamailio-extra-modules kamailio-json-modules 16 | 17 | Once installed we proceed with loading the configuration out of specific tutorial cases bellow. 18 | 19 | .. _Kamailio: http://www.kamailio.org/ -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/cdr_custom.conf: -------------------------------------------------------------------------------- 1 | [mappings] 2 | ; Our CDR log will be written to /var/log/asterisk/cdr-custom/Master.csv 3 | ; with the following schema. 4 | Master.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration)})},${CSV_QUOTE(${CDR(billsec)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)} 5 | -------------------------------------------------------------------------------- /data/conf/samples/cdrsreplicationmaster/cdrsreplicationmaster.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used in apier_local_tests 5 | // Starts rater, cdrs and mediator connecting over internal channel 6 | 7 | "rals": { 8 | "enabled": true, // enable Rater service: 9 | }, 10 | 11 | "cdrs": { 12 | "enabled": true, // start the CDR Server service: 13 | "store_cdrs": false, // store cdrs in storDb 14 | "cdr_replication":[ // replicate the rated CDR to a number of servers 15 | {"transport": "*http_post", "address": "http://127.0.0.1:12080/cdr_http", "attempts": 1}, 16 | {"transport": "*http_post", "address": "http://127.0.0.1:12080/invalid", "attempts": 1}, 17 | 18 | ], 19 | }, 20 | 21 | } -------------------------------------------------------------------------------- /data/conf/samples/cdrsv2mongo/cdrsv2psql.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used in apier_local_tests 5 | // Starts rater, cdrs and mediator connecting over internal channel 6 | 7 | "stor_db": { 8 | "db_type": "mongo", // stor database type to use: 9 | "db_port": 27017, // the port to reach the stordb 10 | }, 11 | 12 | 13 | "rals": { 14 | "enabled": true, // enable Rater service: 15 | }, 16 | 17 | "cdrs": { 18 | "enabled": true, // start the CDR Server service: 19 | "rals_conns": [ 20 | {"address": "*internal"} // address where to reach the Rater for cost calculation, empty to disable functionality: <""|*internal|x.y.z.y:1234> 21 | ], 22 | }, 23 | 24 | } 25 | -------------------------------------------------------------------------------- /data/conf/samples/cdrsv2psql/cdrsv2psql.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used in apier_local_tests 5 | // Starts rater, cdrs and mediator connecting over internal channel 6 | 7 | "stor_db": { 8 | "db_type": "postgres", // stor database type to use: 9 | "db_port": 5432, // the port to reach the stordb 10 | }, 11 | 12 | 13 | "rals": { 14 | "enabled": true, // enable Rater service: 15 | }, 16 | 17 | "cdrs": { 18 | "enabled": true, // start the CDR Server service: 19 | "rals_conns": [ 20 | {"address": "*internal"} // address where to reach the Rater for cost calculation, empty to disable functionality: <""|*internal|x.y.z.y:1234> 21 | ], 22 | }, 23 | 24 | } 25 | -------------------------------------------------------------------------------- /data/storage/mysql/setup_cgr_db.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env sh 2 | 3 | if test $# -lt 2; then 4 | echo "" 5 | echo "setup_cgr_db.sh []" 6 | echo "" 7 | exit 0 8 | fi 9 | 10 | host=$3 11 | if [ -z "$3" ]; then 12 | host="localhost" 13 | fi 14 | 15 | DIR="$(dirname "$(readlink -f "$0")")" 16 | 17 | mysql -u $1 -p$2 -h $host < "$DIR"/create_db_with_users.sql 18 | cu=$? 19 | mysql -u $1 -p$2 -h $host -D cgrates < "$DIR"/create_cdrs_tables.sql 20 | cdrt=$? 21 | mysql -u $1 -p$2 -h $host -D cgrates < "$DIR"/create_tariffplan_tables.sql 22 | tpt=$? 23 | 24 | if [ $cu = 0 ] && [ $cdrt = 0 ] && [ $tpt = 0 ]; then 25 | echo -e "\n\t+++ CGR-DB successfully set-up! +++\n" 26 | exit 0 27 | fi 28 | 29 | 30 | -------------------------------------------------------------------------------- /data/conf/samples/hapool/cgrrater1/cgr.json: -------------------------------------------------------------------------------- 1 | { 2 | "listen": { 3 | "rpc_json": ":2014", 4 | "rpc_gob": ":2015", 5 | "http": ":2081", 6 | }, 7 | 8 | "rals": { 9 | "enabled": true, 10 | "cdrstats_conns": [ 11 | {"address": "*internal"} 12 | ], 13 | "pubsubs_conns": [ 14 | {"address": "*internal"} 15 | ], 16 | "users_conns": [ 17 | {"address": "*internal"} 18 | ], 19 | "aliases_conns": [ 20 | {"address": "*internal"} 21 | ], 22 | }, 23 | 24 | "scheduler": { 25 | "enabled": true, 26 | }, 27 | 28 | "cdrstats": { 29 | "enabled": true, 30 | }, 31 | 32 | "pubsubs": { 33 | "enabled": true, 34 | }, 35 | 36 | "aliases": { 37 | "enabled": true, 38 | }, 39 | 40 | "users": { 41 | "enabled": true, 42 | "indexes": ["SubscriberId"], 43 | }, 44 | 45 | } 46 | -------------------------------------------------------------------------------- /data/conf/samples/hapool/cgrrater2/cgr.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "listen": { 4 | "rpc_json": ":2016", 5 | "rpc_gob": ":2017", 6 | "http": ":2082", 7 | }, 8 | 9 | "rals": { 10 | "enabled": true, 11 | "cdrstats_conns": [ 12 | {"address": "*internal"} 13 | ], 14 | "pubsubs_conns": [ 15 | {"address": "*internal"} 16 | ], 17 | "users_conns": [ 18 | {"address": "*internal"} 19 | ], 20 | "aliases_conns": [ 21 | {"address": "*internal"} 22 | ], 23 | }, 24 | 25 | "scheduler": { 26 | "enabled": true, 27 | }, 28 | 29 | "cdrstats": { 30 | "enabled": true, 31 | }, 32 | 33 | "pubsubs": { 34 | "enabled": true, 35 | }, 36 | 37 | "aliases": { 38 | "enabled": true, 39 | }, 40 | 41 | "users": { 42 | "enabled": true, 43 | "indexes": ["SubscriberId"], 44 | }, 45 | 46 | } 47 | -------------------------------------------------------------------------------- /data/docker/devel/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:alpine 2 | MAINTAINER Radu Fericean, radu@fericean.ro 3 | 4 | # install dependencies 5 | RUN apk add --update git wget bash zsh ngrep curl nano 6 | 7 | # add accurate user 8 | RUN adduser -h /var/run/accurate -s /bin/false -S accurate 9 | 10 | #install glide 11 | RUN go get github.com/Masterminds/glide 12 | 13 | #install oh-my-zsh 14 | RUN TERM=xterm sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"; exit 0 15 | 16 | # cleanup 17 | RUN rm -f /tmp/* /etc/apk/cache/* 18 | 19 | # expose ports 20 | EXPOSE 2012 2013 2080 21 | 22 | WORKDIR /go/src/github.com/accurateproject/accurate 23 | 24 | # set start command 25 | CMD ./build.sh; cc-engine -cfgdir data/conf/samples/phoenix; sleep 365d 26 | -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/queues.conf: -------------------------------------------------------------------------------- 1 | [general] 2 | monitor-type = MixMonitor 3 | 4 | ;========================Sales Queue == 5 | ; Calls all sales persons in a ring-all fashion 6 | [sales] 7 | strategy=ringall 8 | member => PJSIP/1109 ; Terry Jules - Director of Sales 9 | member => PJSIP/1105 ; Garnet Claude - Sales Associate 10 | member => PJSIP/1112 ; Franny Ocean - Sales Associate 11 | 12 | ;===================== Customer Advocate Queue == 13 | ; Calls all customer advocates in a ring-all fashion 14 | [customer_advocate] 15 | strategy=ringall 16 | member => PJSIP/1101 ; Maria Berny - Director of Customer Experience 17 | member => PJSIP/1115 ; Dusty Williams - Customer Advocate 18 | member => PJSIP/1102 ; Tommy Briar - Customer Advocate 19 | 20 | -------------------------------------------------------------------------------- /docs/api_tp.rst: -------------------------------------------------------------------------------- 1 | ApierV1.GetTPIds 2 | ++++++++++++++++ 3 | 4 | Queries tarrif plan identities gathered from all tables. 5 | 6 | **Request**: 7 | 8 | Data: 9 | :: 10 | 11 | type AttrGetTPIds struct { 12 | } 13 | 14 | *JSON sample*: 15 | :: 16 | 17 | { 18 | "id": 9, 19 | "method": "ApierV1.GetTPIds", 20 | "params": [] 21 | } 22 | 23 | 24 | **Reply**: 25 | 26 | Data: 27 | :: 28 | 29 | []string 30 | 31 | *JSON sample*: 32 | :: 33 | 34 | { 35 | "error": null, 36 | "id": 9, 37 | "result": [ 38 | "SAMPLE_TP", 39 | "SAMPLE_TP_2" 40 | ] 41 | } 42 | 43 | 44 | 45 | **Errors**: 46 | 47 | ``SERVER_ERROR`` - Server error occurred. 48 | 49 | ``NOT_FOUND`` - No tariff plans defined. 50 | -------------------------------------------------------------------------------- /cmd/cc-engine/engine_test.go: -------------------------------------------------------------------------------- 1 | 2 | package main 3 | 4 | import ( 5 | "net/rpc" 6 | "testing" 7 | ) 8 | 9 | /*func TestRPCGet(t *testing.T) { 10 | client, err := rpc.DialHTTPPath("tcp", "localhost:2000", "/rpc") 11 | if err != nil { 12 | t.Error("Balancer server not started!") 13 | t.FailNow() 14 | } 15 | var reply string 16 | client.Call("Responder.Get", "test", &reply) 17 | const expect = "12223" 18 | if reply != expect { 19 | t.Errorf("replay == %v, want %v", reply, expect) 20 | } 21 | }*/ 22 | 23 | func BenchmarkRPCGet(b *testing.B) { 24 | b.StopTimer() 25 | client, _ := rpc.DialHTTPPath("tcp", "localhost:2000", "/rpc") 26 | b.StartTimer() 27 | var reply string 28 | for i := 0; i < b.N; i++ { 29 | client.Call("Responder.Get", "test", &reply) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /data/tariffplans/cdrstats/ActionTriggers.csv: -------------------------------------------------------------------------------- 1 | #Tag[0],UniqueId[1],ThresholdType[2],ThresholdValue[3],Recurrent[4],MinSleep[5],ExpiryTime[6],ActivationTime[7],BalanceTag[8],BalanceType[9],BalanceDirections[10],BalanceCategories[11],BalanceDestinationIds[12],BalanceRatingSubject[13],BalanceSharedGroup[14],BalanceExpiryTime[15],BalanceTimingIds[16],BalanceWeight[17],BalanceBlocker[18],BalanceDisabled[19],StatsMinQueuedItems[20],ActionsId[21],Weight[22] 2 | CDRST3_WARN_ASR,,*min_asr,45,true,1h,,,,,,,,,,,,,,,3,CDRST_LOG,10 3 | CDRST3_WARN_ACD,,*min_acd,10,true,1h,,,,,,,,,,,,,,,5,CDRST_LOG,10 4 | CDRST3_WARN_ACC,,*max_acc,10,true,10m,,,,,,,,,,,,,,,5,CDRST_LOG,10 5 | CDRST4_WARN_ASR,,*min_asr,30,true,0,,,,,,,,,,,,,,,5,CDRST_LOG,10 6 | CDRST4_WARN_ACD,,*min_acd,3,true,0,,,,,,,,,,,,,,,2,CDRST_LOG,10 7 | -------------------------------------------------------------------------------- /api/v1/cdrc.go: -------------------------------------------------------------------------------- 1 | package v1 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/config" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | type AttrReloadConfig struct { 9 | ConfigDir string 10 | } 11 | 12 | func (api *ApiV1) ReloadCdrcConfig(attrs AttrReloadConfig, reply *string) error { 13 | if attrs.ConfigDir == "" { 14 | attrs.ConfigDir = utils.CONFIG_DIR 15 | } 16 | // FIXME: this should be Reload config in general! 17 | if err := config.LoadPath(attrs.ConfigDir); err != nil { 18 | return utils.NewErrServerError(err) 19 | } 20 | //api.Config.CdrcProfiles = newCfg.CdrcProfiles // ToDo: Check if there can be any concurency involved here so we need to lock maybe 21 | //api.Config.ConfigReloads[utils.CDRC] <- struct{}{} 22 | *reply = OK 23 | return nil 24 | } 25 | -------------------------------------------------------------------------------- /data/conf/samples/smg/cgrates.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used for cgradmin 5 | // Starts rater, scheduler 6 | 7 | "general": { 8 | "response_cache_ttl": "1s", 9 | }, 10 | 11 | "listen": { 12 | "rpc_json": ":2012", // RPC JSON listening address 13 | "rpc_gob": ":2013", // RPC GOB listening address 14 | "http": ":2080", // HTTP listening address 15 | }, 16 | 17 | "rals": { 18 | "enabled": true, // enable Rater service: 19 | }, 20 | 21 | "scheduler": { 22 | "enabled": true, // start Scheduler service: 23 | }, 24 | 25 | "cdrs": { 26 | "enabled": true, // start the CDR Server service: 27 | }, 28 | 29 | "sm_generic": { 30 | "enabled": true, 31 | "session_ttl": "50ms", 32 | }, 33 | 34 | } 35 | -------------------------------------------------------------------------------- /data/tariffplans/cdrstats/CdrStats.csv: -------------------------------------------------------------------------------- 1 | #Id[0],QueueLength[1],TimeWindow[2],SaveInerval[3],Metric[4],SetupInterval[5],TOR[6],CdrHost[7],CdrSource[8],ReqType[9],Direction[10],Tenant[11],Category[12],Account[13],Subject[14],DestinationPrefix[15],PddInterval[16],UsageInterval[17],Supplier[18],DisconnectCause[19],MediationRunIds[20],RatedAccount[21],RatedSubject[22],CostInterval[23],Triggers[24] 2 | CDRST3,5,60m,,ASR,2014-07-29T15:00:00Z;2014-07-29T16:00:00Z,*voice,87.139.12.167,FS_JSON,rated,*out,cgrates.org,call,dan,dan,+49,,5m;10m,,,*default,rif,rif,0;2,CDRST3_WARN_ASR 3 | CDRST3,,,,ACD,,,,,,,,,,,,,,,,,,,,CDRST3_WARN_ACD 4 | CDRST3,,,,ACC,,,,,,,,,,,,,,,,,,,,CDRST3_WARN_ACC 5 | CDRST4,10,0,,ASR,,,,,,,cgrates.org,call,,,,,,,,*default,,,,CDRST4_WARN_ASR 6 | CDRST4,,,,ACD,,,,,,,,,,,,,,,,,,,,CDRST4_WARN_ACD 7 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/CdrStats.csv: -------------------------------------------------------------------------------- 1 | #Id[0],QueueLength[1],TimeWindow[2],SaveInerval[3],Metric[4],SetupInterval[5],TOR[6],CdrHost[7],CdrSource[8],ReqType[9],Direction[10],Tenant[11],Category[12],Account[13],Subject[14],DestinationPrefix[15],PddInterval[16],UsageInterval[17],Supplier[18],DisconnectCause[19],MediationRunIds[20],RatedAccount[21],RatedSubject[22],CostInterval[23],Triggers[24] 2 | CDRST1,5,60m,10s,ASR,2014-07-29T15:00:00Z;2014-07-29T16:00:00Z,*voice,87.139.12.167,FS_JSON,rated,*out,cgrates.org,call,dan,dan,+49,,5m;10m,,,default,rif,rif,0;2,CDRST1_WARN_ASR 3 | CDRST1,,,,ACD,,,,,,,,,,,,,,,,,,,,CDRST1_WARN_ACD 4 | CDRST1,,,,ACC,,,,,,,,,,,,,,,,,,,,CDRST1_WARN_ACC 5 | CDRST2,10,10m,10s,ASR,,,,,,,cgrates.org,call,,,,,,,,,,,,CDRST2_WARN_ASR 6 | CDRST2,,,,ACD,,,,,,,,,,,,,,,,,,,,CDRST2_WARN_ACD 7 | -------------------------------------------------------------------------------- /utils/researchreplace.go: -------------------------------------------------------------------------------- 1 | 2 | package utils 3 | 4 | import ( 5 | "regexp" 6 | ) 7 | 8 | // Regexp Search/Replace, used for example for field formatting 9 | type ReSearchReplace struct { 10 | SearchRegexp *regexp.Regexp 11 | ReplaceTemplate string 12 | Matched bool 13 | } 14 | 15 | func (rsr *ReSearchReplace) Process(source string) string { 16 | if rsr.SearchRegexp == nil { 17 | return "" 18 | } 19 | res := []byte{} 20 | match := rsr.SearchRegexp.FindStringSubmatchIndex(source) 21 | if match == nil { 22 | return source // No match returns unaltered source, so we can play with national vs international dialing 23 | } else { 24 | rsr.Matched = true 25 | } 26 | res = rsr.SearchRegexp.ExpandString(res, rsr.ReplaceTemplate, source, match) 27 | return string(res) 28 | } 29 | -------------------------------------------------------------------------------- /data/conf/samples/fscsv/cgrates.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "listen": { 4 | "rpc_json": ":2012", // RPC JSON listening address 5 | "rpc_gob": ":2013", // RPC GOB listening address 6 | "http": ":2080", // HTTP listening address 7 | }, 8 | 9 | "rals": { 10 | "enabled": true, // enable Rater service: 11 | "cdrstats_conns": [ 12 | {"address": "*internal"} 13 | ], 14 | }, 15 | 16 | "scheduler": { 17 | "enabled": true, // start Scheduler service: 18 | }, 19 | 20 | "cdrs": { 21 | "enabled": true, // start the CDR Server service: 22 | "cdrstats_conns": [ 23 | {"address": "*internal"} 24 | ], 25 | }, 26 | 27 | "cdrstats": { 28 | "enabled": true, // starts the cdrstats service: 29 | "save_interval": "5s" 30 | }, 31 | 32 | } 33 | -------------------------------------------------------------------------------- /data/scripts/copyright_header.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Rating system designed to be used in VoIP Carriers World 3 | Copyright (C) 2016 Radu Ioan Fericean 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see 17 | */ 18 | -------------------------------------------------------------------------------- /docs/configuration.rst: -------------------------------------------------------------------------------- 1 | 4. Configuration 2 | ============= 3 | 4 | The behaviour of **AccuRate** can be externally influenced by following means: 5 | 6 | - **Engine configuration files**: usually located at */etc/cgrates/*. 7 | There can be one or multiple file(s)/folder(s) hierarchies behind configuration folder with support for automatic includes. 8 | The file(s)/folder(s) will be imported **in alphabetical order** into final configuration object. 9 | - **Tariff Plans**: set of files used to import various data used in AccuRate subsystems (eg: Rating, Accounting, LCR, DerivedCharging, etc). 10 | - **RPC APIs**: set of JSON/GOB encoded APIs remotely available for various operational/administrative tasks. 11 | 12 | .. toctree:: 13 | :maxdepth: 2 14 | 15 | cgrates_json 16 | tariff_plans 17 | 18 | 19 | -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/indications.conf: -------------------------------------------------------------------------------- 1 | [general] 2 | country = us ; We are in Waldo, Al, USA so the US is our default. 3 | 4 | [us] 5 | description = United States / North America 6 | ringcadence = 2000,4000 7 | dial = 350+440 8 | busy = 480+620/500,0/500 9 | ring = 440+480/2000,0/4000 10 | congestion = 480+620/250,0/250 11 | callwaiting = 440/300,0/10000 12 | dialrecall = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 13 | record = 1400/500,0/15000 14 | info = !950/330,!1400/330,!1800/330,0 15 | stutter = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 16 | 17 | ; Additional country configurations can be found in the Asterisk source 18 | ; at /configs/samples/indications.conf.sample 19 | 20 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/RatingProfiles.csv: -------------------------------------------------------------------------------- 1 | #Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject,CdrStatQueueIds 2 | *out,cgrates.org,call,*any,2014-01-14T00:00:00Z,RP_RETAIL1,, 3 | *out,cgrates.org,call,1001,2014-01-14T00:00:00Z,RP_RETAIL2,, 4 | *out,cgrates.org,call,SPECIAL_1002,2014-01-14T00:00:00Z,RP_SPECIAL_1002,, 5 | *out,cgrates.org,lcr_profile1,suppl1,2014-01-14T00:00:00Z,RP_RETAIL1,,STATS_SUPPL1 6 | *out,cgrates.org,lcr_profile1,suppl2,2014-01-14T00:00:00Z,RP_RETAIL2,,STATS_SUPPL2 7 | *out,cgrates.org,lcr_profile2,suppl1,2014-01-14T00:00:00Z,RP_RETAIL2,,STATS_SUPPL1 8 | *out,cgrates.org,lcr_profile2,suppl2,2014-01-14T00:00:00Z,RP_RETAIL1,,STATS_SUPPL2 9 | *out,cgrates.org,lcr_profile2,suppl3,2014-01-14T00:00:00Z,RP_SPECIAL_1002,, 10 | *out,cgrates.org,generic,*any,2014-01-14T00:00:00Z,RP_GENERIC,, 11 | -------------------------------------------------------------------------------- /utils/cgrrecordwriter.go: -------------------------------------------------------------------------------- 1 | 2 | package utils 3 | 4 | import ( 5 | "io" 6 | ) 7 | 8 | // Writer for one line, compatible with csv.Writer interface on Write 9 | type CgrRecordWriter interface { 10 | Write([]string) error 11 | Flush() 12 | } 13 | 14 | func NewCgrIORecordWriter(w io.Writer) *CgrIORecordWriter { 15 | return &CgrIORecordWriter{w: w} 16 | } 17 | 18 | type CgrIORecordWriter struct { 19 | w io.Writer 20 | } 21 | 22 | func (self *CgrIORecordWriter) Write(record []string) error { 23 | for _, fld := range append(record, "\n") { // Postpend the new line char and write record in the writer 24 | if _, err := io.WriteString(self.w, fld); err != nil { 25 | return err 26 | } 27 | } 28 | return nil 29 | } 30 | 31 | // ToDo: make sure we properly handle this method 32 | func (self *CgrIORecordWriter) Flush() { 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /data/tutorials/asterisk_events/asterisk/etc/asterisk/README: -------------------------------------------------------------------------------- 1 | The included Asterisk configuration files are intended to be an example 2 | implementation for a fictitious company, Super Awesome Company. 3 | 4 | It can serve as a handy reference for understanding a simple Asterisk 5 | configuration in an approximate real-world environment. 6 | 7 | If you intend to use this configuration as a template for your own, then 8 | you will need to change many values in the various configuration files to 9 | match your own devices, network, SIP ITSP accounts and more. 10 | 11 | For further documentation on this configuration see the Asterisk wiki: 12 | https://wiki.asterisk.org/wiki/display/AST/Reference+Use+Cases+for+Asterisk. 13 | 14 | Please report bugs or errors in configuration on the Asterisk issue tracker: 15 | https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines 16 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/Users.csv: -------------------------------------------------------------------------------- 1 | #Tenant[0],UserName[1],Maksed[2],AttributeName[3],AttributeValue[4],Weight[5] 2 | cgrates.org,1001,,SysUserName,danb,10 3 | cgrates.org,1001,,SysPassword,hisPass321,10 4 | cgrates.org,1001,,Cli,+4986517174963,10 5 | cgrates.org,1001,,Account,1001,10 6 | cgrates.org,1001,,Subject,1001,10 7 | cgrates.org,1001,,Uuid,388539dfd4f5cefee8f488b78c6c244b9e19138e,10 8 | cgrates.org,1001,,ReqType,*prepaid,10 9 | cgrates.org,1002,,SysUserName,rif,10 10 | cgrates.org,1002,,RifAttr,RifVal,10 11 | cgrates.org,1002,,Account,1002,10 12 | cgrates.org,1002,,Subject,1002,10 13 | cgrates.org,1002,,Uuid,27f37edec0670fa34cf79076b80ef5021e39c5b5,10 14 | cgrates.org,1004,,SysUserName,danb4,10 15 | cgrates.org,1004,,SysPassword,hisPass321,10 16 | cgrates.org,1004,,Cli,+4986517174964,10 17 | cgrates.org,1004,,Account,1004,10 18 | cgrates.org,1004,,Subject,1004,10 19 | cgrates.org,1004,,ReqType,*rated,10 20 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/DerivedChargers.csv: -------------------------------------------------------------------------------- 1 | #Direction[0],Tenant[1],Category[2],Account[3],Subject[4],DestinationIds[5],RunId[6],RunFilter[7],ReqTypeField[8],DirectionField[9],TenantField[10],CategoryField[11],AccountField[12],SubjectField[13],DestinationField[14],SetupTimeField[15],PddField[16],AnswerTimeField[17],UsageField[18],SupplierField[19],DisconnectCause[20],RatedField[21],CostField[22] 2 | *out,cgrates.org,call,dan,dan,,extra1,,^prepaid,,,,^rif,^rif,,,,,^1s,*default,*default,*default,*default 3 | *out,cgrates.org,call,dan,dan,,extra2,,,,,,^ivo,^ivo,,,,,,*default,*default,*default,*default 4 | *out,cgrates.org,call,dan,dan,,extra3,~filterhdr1:s/(.+)/special_run3/,,,,,^runusr3,^runusr3,,,,,,*default,*default,*default,*default 5 | *out,cgrates.org,call,dan,*any,,extra1,,,,,,^rif2,^rif2,,,,,,*default,*default,*default,*default 6 | *out,cgrates.org,call,1011,1011,GERMANY,extra1,,,,,,,,^+4915,,,,,*default,*default,*default,*default -------------------------------------------------------------------------------- /packages/jessie/cgrates.service: -------------------------------------------------------------------------------- 1 | # Stop dance for nginx 2 | # ======================= 3 | # 4 | # ExecStop sends SIGSTOP (graceful stop) to the nginx process. 5 | # If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control 6 | # and sends SIGTERM (fast shutdown) to the main process. 7 | # After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends 8 | # SIGKILL to all the remaining processes in the process group (KillMode=mixed). 9 | # 10 | # nginx signals reference doc: 11 | # http://nginx.org/en/docs/control.html 12 | # 13 | [Unit] 14 | Description=Control CGRateS - carrier grade real-time charging system 15 | After=network.target 16 | 17 | [Service] 18 | Type=simple 19 | ExecStart=/usr/bin/cgr-engine 20 | KillMode=mixed 21 | User=cgrates 22 | Group=cgrates 23 | StandardOutput=journal 24 | StandardError=journal 25 | Restart=on-failure 26 | 27 | [Install] 28 | WantedBy=multi-user.target 29 | -------------------------------------------------------------------------------- /packages/jessie/changelog: -------------------------------------------------------------------------------- 1 | cgrates (0.9.1~rc8) UNRELEASED; urgency=low 2 | 3 | * RC8. 4 | 5 | -- DanB Monday, 22 September 2015 12:05:00 +0200 6 | 7 | cgrates (0.9.1~rc7) UNRELEASED; urgency=low 8 | 9 | * RC7. 10 | 11 | -- DanB Wednesday, 3 August 2015 14:04:00 -0600 12 | 13 | cgrates (0.9.1~rc6) UNRELEASED; urgency=low 14 | 15 | * RC6. 16 | 17 | -- DanB Wednesday, 10 September 2014 13:30:00 +0100 18 | 19 | cgrates (0.9.1~rc5) UNRELEASED; urgency=low 20 | 21 | * RC5. 22 | 23 | -- DanB Monday, 18 August 2014 13:30:00 +0100 24 | 25 | 26 | cgrates (0.9.1~rc4) UNRELEASED; urgency=low 27 | 28 | * RC4. 29 | 30 | -- DanB Thursday, 25 March 2014 17:30:00 +0100 31 | 32 | cgrates (0.9.1~rc3) UNRELEASED; urgency=low 33 | 34 | * RC3. 35 | 36 | -- DanB Fri, 03 Jan 2014 17:37:31 +0100 37 | -------------------------------------------------------------------------------- /packages/squeeze/changelog: -------------------------------------------------------------------------------- 1 | cgrates (0.9.1~rc8) UNRELEASED; urgency=low 2 | 3 | * RC8. 4 | 5 | -- DanB Monday, 22 September 2015 12:05:00 +0200 6 | 7 | cgrates (0.9.1~rc7) UNRELEASED; urgency=low 8 | 9 | * RC7. 10 | 11 | -- DanB Wednesday, 3 August 2015 14:04:00 -0600 12 | 13 | cgrates (0.9.1~rc6) UNRELEASED; urgency=low 14 | 15 | * RC6. 16 | 17 | -- DanB Wednesday, 10 September 2014 13:30:00 +0100 18 | 19 | cgrates (0.9.1~rc5) UNRELEASED; urgency=low 20 | 21 | * RC5. 22 | 23 | -- DanB Monday, 18 August 2014 13:30:00 +0100 24 | 25 | 26 | cgrates (0.9.1~rc4) UNRELEASED; urgency=low 27 | 28 | * RC4. 29 | 30 | -- DanB Thursday, 25 March 2014 17:30:00 +0100 31 | 32 | cgrates (0.9.1~rc3) UNRELEASED; urgency=low 33 | 34 | * RC3. 35 | 36 | -- DanB Fri, 03 Jan 2014 17:37:31 +0100 37 | -------------------------------------------------------------------------------- /data/conf/samples/multifiles/b/b.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // Used in multifile configuration tests 4 | // Should be the second file loaded 5 | 6 | "general": { 7 | "default_request_type": "*pseudoprepaid", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated> 8 | }, 9 | 10 | "cdre": { 11 | "*default": { 12 | "data_usage_multiply_factor": 1024, // multiply data usage before export (eg: convert from KBytes to Bytes) 13 | "export_dir": "/tmp/cgrates/cdre", // path where the exported CDRs will be placed 14 | }, 15 | "export1": { 16 | "header_fields": [ 17 | {"tag": "UniqueID", "cdr_field_id": "uniqueid", "type": "cdrfield", "value": "uniqueid"}, 18 | {"tag":"RunId", "cdr_field_id": "mediation_runid", "type": "cdrfield", "value": "mediation_runid"}, 19 | ], // template of the exported header fields 20 | } 21 | }, 22 | 23 | } 24 | -------------------------------------------------------------------------------- /console/publish.go: -------------------------------------------------------------------------------- 1 | 2 | package console 3 | 4 | func init() { 5 | c := &CmdPublish{ 6 | name: "publish", 7 | rpcMethod: "PubSubV1.Publish", 8 | } 9 | commands[c.Name()] = c 10 | c.CommandExecuter = &CommandExecuter{c} 11 | } 12 | 13 | type CmdPublish struct { 14 | name string 15 | rpcMethod string 16 | rpcParams *StringMapWrapper 17 | *CommandExecuter 18 | } 19 | 20 | func (self *CmdPublish) Name() string { 21 | return self.name 22 | } 23 | 24 | func (self *CmdPublish) RpcMethod() string { 25 | return self.rpcMethod 26 | } 27 | 28 | func (self *CmdPublish) RpcParams(reset bool) interface{} { 29 | if reset || self.rpcParams == nil { 30 | self.rpcParams = &StringMapWrapper{} 31 | } 32 | return self.rpcParams 33 | } 34 | 35 | func (self *CmdPublish) PostprocessRpcParams() error { 36 | return nil 37 | } 38 | 39 | func (self *CmdPublish) RpcResult() interface{} { 40 | var s string 41 | return &s 42 | } 43 | -------------------------------------------------------------------------------- /data/conf/samples/hapool/cgrsmg1/cgr.json: -------------------------------------------------------------------------------- 1 | { 2 | "listen": { 3 | "rpc_json": "127.0.0.1:2018", // RPC JSON listening address 4 | "rpc_gob": "127.0.0.1:2019", // RPC GOB listening address 5 | "http": "127.0.0.1:2083", // HTTP listening address 6 | }, 7 | 8 | "cdrs": { 9 | "enabled": true, // start the CDR Server service: 10 | "rals_conns": [ 11 | {"address": "127.0.0.1:2014"}, 12 | {"address": "127.0.0.1:2016"} 13 | ], 14 | "cdrstats": "", // address where to reach the cdrstats service, empty to disable stats functionality<""|internal|x.y.z.y:1234> 15 | }, 16 | 17 | "sm_generic": { 18 | "enabled": true, 19 | "rals_conns": [ 20 | {"address": "127.0.0.1:2014"}, 21 | {"address": "127.0.0.1:2016"} 22 | ], 23 | "cdrs_conns": [ 24 | {"address": "*internal"} // address where to reach CDR Server, empty to disable CDR capturing 25 | ], 26 | }, 27 | } 28 | -------------------------------------------------------------------------------- /cmd/cc-tester/cdr_repl/post_server.py: -------------------------------------------------------------------------------- 1 | from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer 2 | import SocketServer 3 | 4 | class S(BaseHTTPRequestHandler): 5 | def _set_headers(self): 6 | self.send_response(200) 7 | self.send_header('Content-type', 'text/html') 8 | self.end_headers() 9 | 10 | def do_POST(self): 11 | # Doesn't do anything with posted data 12 | self._set_headers() 13 | print(self) 14 | #self.wfile.write("

POST!

") 15 | 16 | def run(server_class=HTTPServer, handler_class=S, port=80): 17 | server_address = ('', port) 18 | httpd = server_class(server_address, handler_class) 19 | print('Starting httpd...') 20 | httpd.serve_forever() 21 | 22 | if __name__ == "__main__": 23 | from sys import argv 24 | 25 | if len(argv) == 2: 26 | run(port=int(argv[1])) 27 | else: 28 | run(port=12080) 29 | -------------------------------------------------------------------------------- /data/conf/samples/hapool/cgrsmg2/cgr.json: -------------------------------------------------------------------------------- 1 | { 2 | "listen": { 3 | "rpc_json": "127.0.0.1:2020", // RPC JSON listening address 4 | "rpc_gob": "127.0.0.1:2021", // RPC GOB listening address 5 | "http": "127.0.0.1:2084", // HTTP listening address 6 | }, 7 | 8 | "cdrs": { 9 | "enabled": true, // start the CDR Server service: 10 | "rals_conns": [ 11 | {"address": "127.0.0.1:2014"}, 12 | {"address": "127.0.0.1:2016"} 13 | ], 14 | "cdrstats": "", // address where to reach the cdrstats service, empty to disable stats functionality<""|internal|x.y.z.y:1234> 15 | }, 16 | 17 | "sm_generic": { 18 | "enabled": true, 19 | "rals_conns": [ 20 | {"address": "127.0.0.1:2014"}, 21 | {"address": "127.0.0.1:2016"} 22 | ], 23 | "cdrs_conns": [ 24 | {"address": "*internal"} // address where to reach CDR Server, empty to disable CDR capturing 25 | ], 26 | }, 27 | 28 | } 29 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/RatingPlans.csv: -------------------------------------------------------------------------------- 1 | #Id,DestinationRatesId,TimingTag,Weight 2 | RP_RETAIL1,DR_FS_40CNT,PEAK,10 3 | RP_RETAIL1,DR_FS_10CNT,OFFPEAK_MORNING,10 4 | RP_RETAIL1,DR_FS_10CNT,OFFPEAK_EVENING,10 5 | RP_RETAIL1,DR_FS_10CNT,OFFPEAK_WEEKEND,10 6 | RP_RETAIL1,DR_1007_MAXCOST_DISC,*any,10 7 | RP_RETAIL2,DR_1002_20CNT,PEAK,10 8 | RP_RETAIL2,DR_1003_20CNT,PEAK,10 9 | RP_RETAIL2,DR_FS_40CNT,PEAK,10 10 | RP_RETAIL2,DR_1002_10CNT,OFFPEAK_MORNING,10 11 | RP_RETAIL2,DR_1002_10CNT,OFFPEAK_EVENING,10 12 | RP_RETAIL2,DR_1002_10CNT,OFFPEAK_WEEKEND,10 13 | RP_RETAIL2,DR_1003_10CNT,OFFPEAK_MORNING,10 14 | RP_RETAIL2,DR_1003_10CNT,OFFPEAK_EVENING,10 15 | RP_RETAIL2,DR_1003_10CNT,OFFPEAK_WEEKEND,10 16 | RP_RETAIL2,DR_FS_10CNT,OFFPEAK_MORNING,10 17 | RP_RETAIL2,DR_FS_10CNT,OFFPEAK_EVENING,10 18 | RP_RETAIL2,DR_FS_10CNT,OFFPEAK_WEEKEND,10 19 | RP_RETAIL2,DR_1007_MAXCOST_FREE,*any,10 20 | RP_SPECIAL_1002,DR_SPECIAL_1002,*any,10 21 | RP_GENERIC,DR_GENERIC,*any,10 -------------------------------------------------------------------------------- /data/tutorials/fs_evsock/README.md: -------------------------------------------------------------------------------- 1 | Tutorial FS_JSON 2 | ================ 3 | 4 | Scenario: 5 | --------- 6 | 7 | - FreeSWITCH with minimal custom configuration. 8 | 9 | - Added following users (with configs in *etc/freeswitch/directory/default*): 1001-prepaid, 1002-postpaid, 1003-pseudoprepaid, 1004-rated, 1006-prepaid, 1007-prepaid. 10 | - Have added inside default dialplan CGR own extensions just before routing towards users (*etc/freeswitch/dialplan/default.xml*). 11 | 12 | - **accuRate** with following components: 13 | 14 | - SM started as prepaid controller, with debits taking place at 5s intervals. 15 | - Mediator component attaching costs to the raw CDRs from FreeSWITCH_ inside CGR StorDB. 16 | - CDRE exporting mediated CDRs from CGR StorDB (export path: */tmp*). 17 | - CDRStats component building up stats in 5 different queues. 18 | - History component keeping the archive of the rates modifications (path browsable with git client at */tmp/cc_history*). 19 | -------------------------------------------------------------------------------- /packages/redhat_fedora/readme.txt: -------------------------------------------------------------------------------- 1 | Building package for RHEL/Centos/Oracle Linux/Scientific Linux/Fedora 2 | 3 | PREREQUISITES 4 | 1. Go 1.5 or newer: 5 | # wget https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz 6 | # tar -C /usr/local -xzf go1.5.1.linux-amd64.tar.gz 7 | # export GOROOT=/usr/local/go 8 | # export PATH=$GOROOT/bin:$GOPATH/bin:$PATH 9 | 10 | 2. Git 1.8 or newer for older systems. 11 | 12 | 3. rpm-build and make packages. 13 | # yum install rpm-build make 14 | 15 | BUILD 16 | 1. Create build environment: 17 | - Make directories 18 | # mkdir -p $HOME/cgr_build/{BUILD,RPMS,SOURCES,SPECS,SRPMS} 19 | - Download source file 20 | # wget -P $HOME/cgr_build/SOURCES https://github.com/accurateproject/accurate/archive/[GIT_COMMIT].tar.gz 21 | - Place cgrates.spec file into $HOME/cgr_build/SPECS 22 | 2. Build: 23 | # cd $HOME/cgr_build 24 | # rpmbuild -bb --define "_topdir $HOME/cgr_build" SPECS/cgrates.spec 25 | -------------------------------------------------------------------------------- /data/tutorials/osips_async/opensips/etc/default/opensips: -------------------------------------------------------------------------------- 1 | # 2 | # OpenSIPS startup options 3 | # 4 | 5 | # Set to yes to enable opensips, once configured properly. 6 | RUN_OPENSIPS=yes 7 | 8 | # User to run as 9 | USER=opensips 10 | 11 | # Group to run as 12 | GROUP=opensips 13 | 14 | # Amount of shared memory to allocate for the running OpenSIPS server (in Mb) 15 | S_MEMORY=64 16 | 17 | # Amount of pkg memory to allocate for the running OpenSIPS server (in Mb) 18 | P_MEMORY=4 19 | 20 | # Enable the server to leave a core file when it crashes. 21 | # Set this to 'yes' to enable OpenSIPS to leave a core file when it crashes 22 | # or 'no' to disable this feature. This option is case sensitive and only 23 | # accepts 'yes' and 'no' and only in lowercase letters. 24 | # On some systems (e.g. Ubuntu 6.10, Debian 4.0) it is necessary to specify 25 | # a directory for the core files to get a dump. Look into the opensips 26 | # init file for an example configuration. 27 | DUMP_CORE=no 28 | -------------------------------------------------------------------------------- /docs/api_scheduler.rst: -------------------------------------------------------------------------------- 1 | Scheduler APIs 2 | ============== 3 | 4 | Set of scheduler related APIs. 5 | 6 | 7 | ApierV1.ReloadScheduler 8 | ----------------------- 9 | 10 | When called AccuRate will reorder/reschedule tasks based on data available in dataDb. This command is necessary after each data load, in some cases being automated in the administration tools (eg: inside *cc-loader*) 11 | 12 | **Request**: 13 | 14 | Data: 15 | 16 | :: 17 | 18 | string 19 | 20 | Mandatory parameters: none 21 | 22 | *JSON sample*: 23 | :: 24 | 25 | { 26 | "id": 0, 27 | "method": "ApierV1.ReloadScheduler", 28 | "params": [ 29 | "" 30 | ] 31 | } 32 | 33 | 34 | **Reply**: 35 | 36 | Data: 37 | :: 38 | 39 | string 40 | 41 | Possible answers: **OK** 42 | 43 | *JSON sample*: 44 | :: 45 | 46 | { 47 | "error": null, 48 | "id": 0, 49 | "result": "OK" 50 | } 51 | 52 | **Errors**: 53 | 54 | ``SERVER_ERROR`` - Server error occurred. 55 | -------------------------------------------------------------------------------- /data/conf/samples/actions/cgradmin.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used for cgradmin 5 | // Starts rater, scheduler 6 | 7 | "listen": { 8 | "rpc_json": ":2012", // RPC JSON listening address 9 | "rpc_gob": ":2013", // RPC GOB listening address 10 | "http": ":2080", // HTTP listening address 11 | }, 12 | 13 | "rals": { 14 | "enabled": true, // enable Rater service: 15 | "pubsubs_conns": [ 16 | {"address": "*internal"} 17 | ], 18 | "users_conns": [ 19 | {"address": "*internal"} 20 | ], 21 | "aliases_conns": [ 22 | {"address": "*internal"} 23 | ], 24 | }, 25 | 26 | 27 | "scheduler": { 28 | "enabled": true, // start Scheduler service: 29 | }, 30 | 31 | "pubsubs": { 32 | "enabled": true, // starts pubsub service: . 33 | }, 34 | 35 | "users": { 36 | "enabled": true, // starts users service: . 37 | }, 38 | 39 | "aliases": { 40 | "enabled": true, 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /console/subscribe.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdSubscribe{ 7 | name: "subscribe", 8 | rpcMethod: "PubSubV1.Subscribe", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | type CmdSubscribe struct { 15 | name string 16 | rpcMethod string 17 | rpcParams *engine.SubscribeInfo 18 | *CommandExecuter 19 | } 20 | 21 | func (self *CmdSubscribe) Name() string { 22 | return self.name 23 | } 24 | 25 | func (self *CmdSubscribe) RpcMethod() string { 26 | return self.rpcMethod 27 | } 28 | 29 | func (self *CmdSubscribe) RpcParams(reset bool) interface{} { 30 | if reset || self.rpcParams == nil { 31 | self.rpcParams = &engine.SubscribeInfo{} 32 | } 33 | return self.rpcParams 34 | } 35 | 36 | func (self *CmdSubscribe) PostprocessRpcParams() error { 37 | return nil 38 | } 39 | 40 | func (self *CmdSubscribe) RpcResult() interface{} { 41 | var s string 42 | return &s 43 | } 44 | -------------------------------------------------------------------------------- /console/user_addindex.go: -------------------------------------------------------------------------------- 1 | 2 | package console 3 | 4 | func init() { 5 | c := &CmdUserAddIndex{ 6 | name: "user_addindex", 7 | rpcMethod: "UsersV1.AddIndex", 8 | } 9 | commands[c.Name()] = c 10 | c.CommandExecuter = &CommandExecuter{c} 11 | } 12 | 13 | // Commander implementation 14 | type CmdUserAddIndex struct { 15 | name string 16 | rpcMethod string 17 | rpcParams *StringSliceWrapper 18 | *CommandExecuter 19 | } 20 | 21 | func (self *CmdUserAddIndex) Name() string { 22 | return self.name 23 | } 24 | 25 | func (self *CmdUserAddIndex) RpcMethod() string { 26 | return self.rpcMethod 27 | } 28 | 29 | func (self *CmdUserAddIndex) RpcParams(reset bool) interface{} { 30 | if reset || self.rpcParams == nil { 31 | self.rpcParams = &StringSliceWrapper{} 32 | } 33 | return self.rpcParams 34 | } 35 | 36 | func (self *CmdUserAddIndex) PostprocessRpcParams() error { 37 | return nil 38 | } 39 | 40 | func (self *CmdUserAddIndex) RpcResult() interface{} { 41 | var s string 42 | return &s 43 | } 44 | -------------------------------------------------------------------------------- /api/v1/smv1.go: -------------------------------------------------------------------------------- 1 | package v1 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/sessionmanager" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | // Interact with SessionManager 9 | type SessionManagerV1 struct { 10 | SMs []sessionmanager.SessionManager // List of session managers since we support having more than one active session manager running on one host 11 | } 12 | 13 | func (self *SessionManagerV1) ActiveSessionMangers(ignored string, reply *[]sessionmanager.SessionManager) error { 14 | if len(self.SMs) == 0 { 15 | return utils.ErrNotFound 16 | } 17 | *reply = self.SMs 18 | return nil 19 | } 20 | 21 | func (self *SessionManagerV1) ActiveSessions(attrs utils.AttrGetSMASessions, reply *[]*sessionmanager.ActiveSession) error { 22 | if attrs.SessionManagerIndex > len(self.SMs)-1 { 23 | return utils.ErrNotFound 24 | } 25 | for _, session := range self.SMs[attrs.SessionManagerIndex].Sessions() { 26 | *reply = append(*reply, session.AsActiveSessions()...) 27 | } 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /console/cdrs_rem.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &CmdRemCdrs{ 7 | name: "cdrs_rem", 8 | rpcMethod: "ApiV1.RemCdrs", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdRemCdrs struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *utils.AttrRemCdrs 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdRemCdrs) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdRemCdrs) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdRemCdrs) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &utils.AttrRemCdrs{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdRemCdrs) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdRemCdrs) RpcResult() interface{} { 42 | var s string 43 | return &s 44 | } 45 | -------------------------------------------------------------------------------- /console/user_set.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdSetUser{ 7 | name: "user_set", 8 | rpcMethod: "UsersV1.SetUser", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdSetUser struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *engine.UserProfile 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdSetUser) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdSetUser) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdSetUser) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &engine.UserProfile{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdSetUser) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdSetUser) RpcResult() interface{} { 42 | var s string 43 | return &s 44 | } 45 | -------------------------------------------------------------------------------- /console/scheduler_reload.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | func init() { 4 | c := &CmdReloadScheduler{ 5 | name: "scheduler_reload", 6 | rpcMethod: "ApiV1.ReloadScheduler", 7 | } 8 | commands[c.Name()] = c 9 | c.CommandExecuter = &CommandExecuter{c} 10 | } 11 | 12 | // Commander implementation 13 | type CmdReloadScheduler struct { 14 | name string 15 | rpcMethod string 16 | rpcParams *StringWrapper 17 | *CommandExecuter 18 | } 19 | 20 | func (self *CmdReloadScheduler) Name() string { 21 | return self.name 22 | } 23 | 24 | func (self *CmdReloadScheduler) RpcMethod() string { 25 | return self.rpcMethod 26 | } 27 | 28 | func (self *CmdReloadScheduler) RpcParams(reset bool) interface{} { 29 | if reset || self.rpcParams == nil { 30 | self.rpcParams = &StringWrapper{} 31 | } 32 | return self.rpcParams 33 | } 34 | 35 | func (self *CmdReloadScheduler) PostprocessRpcParams() error { 36 | return nil 37 | } 38 | 39 | func (self *CmdReloadScheduler) RpcResult() interface{} { 40 | var s string 41 | return &s 42 | } 43 | -------------------------------------------------------------------------------- /console/cdrs_rate.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &CmdRateCdrs{ 7 | name: "cdrs_rate", 8 | rpcMethod: "CdrsV1.RateCDRs", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdRateCdrs struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *utils.AttrRateCdrs 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdRateCdrs) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdRateCdrs) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdRateCdrs) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &utils.AttrRateCdrs{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdRateCdrs) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdRateCdrs) RpcResult() interface{} { 42 | var s string 43 | return &s 44 | } 45 | -------------------------------------------------------------------------------- /console/unsubscribe.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdUnsubscribe{ 7 | name: "unsubscribe", 8 | rpcMethod: "PubSubV1.Unsubscribe", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | type CmdUnsubscribe struct { 15 | name string 16 | rpcMethod string 17 | rpcParams *engine.SubscribeInfo 18 | *CommandExecuter 19 | } 20 | 21 | func (self *CmdUnsubscribe) Name() string { 22 | return self.name 23 | } 24 | 25 | func (self *CmdUnsubscribe) RpcMethod() string { 26 | return self.rpcMethod 27 | } 28 | 29 | func (self *CmdUnsubscribe) RpcParams(reset bool) interface{} { 30 | if reset || self.rpcParams == nil { 31 | self.rpcParams = &engine.SubscribeInfo{} 32 | } 33 | return self.rpcParams 34 | } 35 | 36 | func (self *CmdUnsubscribe) PostprocessRpcParams() error { 37 | return nil 38 | } 39 | 40 | func (self *CmdUnsubscribe) RpcResult() interface{} { 41 | var s string 42 | return &s 43 | } 44 | -------------------------------------------------------------------------------- /docs/csv_tpdestinationrates.rst: -------------------------------------------------------------------------------- 1 | DestinationRates.csv 2 | ++++++++++++++++++++ 3 | 4 | Attach rates to destinations. 5 | 6 | CSV fields as tabular representation: 7 | 8 | +--------------------+------------------+---------------------+ 9 | | Tag | DestinationsTag | RatesTag | 10 | +====================+==================+=====================+ 11 | | DR_RETAIL_PEAK | GERMANY | LANDLINE_PEAK | 12 | +--------------------+------------------+---------------------+ 13 | | DR_RETAIL_OFFPEAK | GERMANY | LANDLINE_OFFPEAK | 14 | +--------------------+------------------+---------------------+ 15 | 16 | **Fields** 17 | 18 | Index 0 - *Tag* 19 | Free-text field used to reference the entry from other files. 20 | 21 | Index 1 - *DestinationsTag* 22 | References profile in Destinations.csv_. 23 | 24 | Index 2 - *RatesTag* 25 | References profile defined in Rates.csv_. 26 | 27 | 28 | .. _Destinations.csv: csv_tpdestinations.rst 29 | .. _Rates.csv: csv_tprates.rst 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /engine/history_test.go: -------------------------------------------------------------------------------- 1 | package engine 2 | 3 | import ( 4 | "encoding/json" 5 | "testing" 6 | 7 | "github.com/accurateproject/accurate/history" 8 | "github.com/accurateproject/accurate/utils" 9 | ) 10 | 11 | func TestHistoryRatinPlans(t *testing.T) { 12 | scribe := historyScribe.(*history.MockScribe) 13 | buf := scribe.GetBuffer(history.RATING_PROFILES_FN) 14 | 15 | x := make([]*RatingProfile, 0) 16 | if err := json.Unmarshal(buf.Bytes(), &x); err != nil { 17 | t.Fatal(err) 18 | } 19 | if len(x) != 24 { 20 | t.Errorf("Error in rating profile history content: %d\n%s", len(x), utils.ToIJSON(x)) 21 | } 22 | } 23 | 24 | func TestHistoryDestinations(t *testing.T) { 25 | scribe := historyScribe.(*history.MockScribe) 26 | buf := scribe.GetBuffer(history.DESTINATIONS_FN) 27 | 28 | x := make([]*Destination, 0) 29 | if err := json.Unmarshal(buf.Bytes(), &x); err != nil { 30 | t.Fatal(err) 31 | } 32 | if len(x) != 18 { 33 | t.Errorf("Error in destination history content: %d\n%s", len(x), utils.ToIJSON(x)) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /console/cdrstats_queue.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdCdrStatsQueue{ 7 | name: "cdrstats_queue", 8 | rpcMethod: "CDRStatsV1.GetQueue", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | type CmdCdrStatsQueue struct { 15 | name string 16 | rpcMethod string 17 | rpcParams *StringWrapper 18 | *CommandExecuter 19 | } 20 | 21 | func (self *CmdCdrStatsQueue) Name() string { 22 | return self.name 23 | } 24 | 25 | func (self *CmdCdrStatsQueue) RpcMethod() string { 26 | return self.rpcMethod 27 | } 28 | 29 | func (self *CmdCdrStatsQueue) RpcParams(reset bool) interface{} { 30 | if reset || self.rpcParams == nil { 31 | self.rpcParams = &StringWrapper{} 32 | } 33 | return self.rpcParams 34 | } 35 | 36 | func (self *CmdCdrStatsQueue) PostprocessRpcParams() error { 37 | return nil 38 | } 39 | 40 | func (self *CmdCdrStatsQueue) RpcResult() interface{} { 41 | return &engine.StatsQueue{} 42 | } 43 | -------------------------------------------------------------------------------- /console/user_indexes.go: -------------------------------------------------------------------------------- 1 | 2 | package console 3 | 4 | func init() { 5 | c := &CmdUserShowIndexes{ 6 | name: "user_indexes", 7 | rpcMethod: "UsersV1.GetIndexes", 8 | } 9 | commands[c.Name()] = c 10 | c.CommandExecuter = &CommandExecuter{c} 11 | } 12 | 13 | // Commander implementation 14 | type CmdUserShowIndexes struct { 15 | name string 16 | rpcMethod string 17 | rpcParams *EmptyWrapper 18 | *CommandExecuter 19 | } 20 | 21 | func (self *CmdUserShowIndexes) Name() string { 22 | return self.name 23 | } 24 | 25 | func (self *CmdUserShowIndexes) RpcMethod() string { 26 | return self.rpcMethod 27 | } 28 | 29 | func (self *CmdUserShowIndexes) RpcParams(reset bool) interface{} { 30 | if reset || self.rpcParams == nil { 31 | self.rpcParams = &EmptyWrapper{} 32 | } 33 | return self.rpcParams 34 | } 35 | 36 | func (self *CmdUserShowIndexes) PostprocessRpcParams() error { 37 | return nil 38 | } 39 | 40 | func (self *CmdUserShowIndexes) RpcResult() interface{} { 41 | s := map[string][]string{} 42 | return &s 43 | } 44 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/Users.csv: -------------------------------------------------------------------------------- 1 | #Tenant[0],UserName[1],Masked[2],AttributeName[3],AttributeValue[4],Weight[5] 2 | cgrates.org,1001,,SysUserName,danb,10 3 | cgrates.org,1001,,SysPassword,hisPass321,10 4 | cgrates.org,1001,,Cli,+4986517174963,10 5 | cgrates.org,1001,,Account,1001,10 6 | cgrates.org,1001,,Subject,1001,10 7 | cgrates.org,1001,,Uuid,388539dfd4f5cefee8f488b78c6c244b9e19138e,10 8 | cgrates.org,1001,,SubscriberId,1001,10 9 | cgrates.org,1001,,RequestType,*prepaid,10 10 | cgrates.org,1002,,SysUserName,rif,10 11 | cgrates.org,1002,,RifAttr,RifVal,10 12 | cgrates.org,1002,,Account,1002,10 13 | cgrates.org,1002,,Subject,1002,10 14 | cgrates.org,1002,,Uuid,27f37edec0670fa34cf79076b80ef5021e39c5b5,10 15 | cgrates.org,1002,,SubscriberId,1002,10 16 | cgrates.org,1004,,SysUserName,danb4,10 17 | cgrates.org,1004,,SysPassword,hisPass321,10 18 | cgrates.org,1004,,Cli,+4986517174964,10 19 | cgrates.org,1004,,Account,1004,10 20 | cgrates.org,1004,,Subject,1004,10 21 | cgrates.org,1004,,RequestType,*rated,10 22 | cgrates.org,1004,,SubscriberId,1004,10 23 | -------------------------------------------------------------------------------- /console/account_set.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/api/v1" 4 | 5 | func init() { 6 | c := &CmdAddAccount{ 7 | name: "account_set", 8 | rpcMethod: "ApiV1.SetAccount", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdAddAccount struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *v1.AttrSetAccount 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdAddAccount) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdAddAccount) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdAddAccount) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &v1.AttrSetAccount{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdAddAccount) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdAddAccount) RpcResult() interface{} { 42 | var s string 43 | return &s 44 | } 45 | -------------------------------------------------------------------------------- /console/user_remove.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdUserRemove{ 7 | name: "user_remove", 8 | rpcMethod: "UsersV1.RemoveUser", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdUserRemove struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *engine.UserProfile 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdUserRemove) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdUserRemove) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdUserRemove) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &engine.UserProfile{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdUserRemove) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdUserRemove) RpcResult() interface{} { 42 | var s string 43 | return &s 44 | } 45 | -------------------------------------------------------------------------------- /console/user_update.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdUpdateUser{ 7 | name: "user_update", 8 | rpcMethod: "UsersV1.UpdateUser", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdUpdateUser struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *engine.UserProfile 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdUpdateUser) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdUpdateUser) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdUpdateUser) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &engine.UserProfile{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdUpdateUser) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdUpdateUser) RpcResult() interface{} { 42 | var s string 43 | return &s 44 | } 45 | -------------------------------------------------------------------------------- /console/sharedgroup.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdGetSharedGroup{ 7 | name: "sharedgroup", 8 | rpcMethod: "ApiV1.GetSharedGroup", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdGetSharedGroup struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *StringWrapper 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdGetSharedGroup) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdGetSharedGroup) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdGetSharedGroup) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &StringWrapper{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdGetSharedGroup) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdGetSharedGroup) RpcResult() interface{} { 42 | return &engine.SharedGroup{} 43 | } 44 | -------------------------------------------------------------------------------- /console/subscribers.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdShowSubscribers{ 7 | name: "subscribers", 8 | rpcMethod: "PubSubV1.ShowSubscribers", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | type CmdShowSubscribers struct { 15 | name string 16 | rpcMethod string 17 | rpcParams *StringWrapper 18 | *CommandExecuter 19 | } 20 | 21 | func (self *CmdShowSubscribers) Name() string { 22 | return self.name 23 | } 24 | 25 | func (self *CmdShowSubscribers) RpcMethod() string { 26 | return self.rpcMethod 27 | } 28 | 29 | func (self *CmdShowSubscribers) RpcParams(reset bool) interface{} { 30 | if reset || self.rpcParams == nil { 31 | self.rpcParams = &StringWrapper{} 32 | } 33 | return self.rpcParams 34 | } 35 | 36 | func (self *CmdShowSubscribers) PostprocessRpcParams() error { 37 | return nil 38 | } 39 | 40 | func (self *CmdShowSubscribers) RpcResult() interface{} { 41 | var s map[string]*engine.SubscriberData 42 | return &s 43 | } 44 | -------------------------------------------------------------------------------- /console/cdrs_export.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &CmdExportCdrs{ 7 | name: "cdrs_export", 8 | rpcMethod: "ApiV2.ExportCdrsToFile", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdExportCdrs struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *utils.AttrExportCdrsToFile 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdExportCdrs) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdExportCdrs) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdExportCdrs) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &utils.AttrExportCdrsToFile{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdExportCdrs) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdExportCdrs) RpcResult() interface{} { 42 | return &utils.AttrExportCdrsToFile{} 43 | } 44 | -------------------------------------------------------------------------------- /console/users.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdGetUsers{ 7 | name: "users", 8 | rpcMethod: "UsersV1.GetUsers", 9 | rpcParams: &engine.UserProfile{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdGetUsers struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *engine.UserProfile 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdGetUsers) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdGetUsers) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdGetUsers) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &engine.UserProfile{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdGetUsers) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdGetUsers) RpcResult() interface{} { 43 | s := engine.UserProfiles{} 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/console_old/cache_stats.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &CmdGetCacheStats{ 7 | name: "cache_stats", 8 | rpcMethod: "ApiV1.GetCacheStats", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdGetCacheStats struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *utils.AttrCacheStats 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdGetCacheStats) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdGetCacheStats) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdGetCacheStats) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &utils.AttrCacheStats{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdGetCacheStats) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdGetCacheStats) RpcResult() interface{} { 42 | return &utils.CacheStats{} 43 | } 44 | -------------------------------------------------------------------------------- /console/cache_reload.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &CmdReloadCache{ 7 | name: "cache_reload", 8 | rpcMethod: "ApiV1.ReloadCache", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdReloadCache struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *utils.AttrReloadCache 19 | rpcResult string 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdReloadCache) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdReloadCache) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdReloadCache) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &utils.AttrReloadCache{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdReloadCache) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdReloadCache) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /docs/api_ratingprofiles.rst: -------------------------------------------------------------------------------- 1 | ApierV1.SetRatingProfile 2 | ++++++++++++++++++++++ 3 | 4 | Process dependencies and load a specific rating profile from storDb into dataDb. 5 | 6 | **Request**: 7 | 8 | Data: 9 | :: 10 | 11 | type AttrSetRatingProfile struct { 12 | TPid string 13 | RatingProfileId string 14 | } 15 | 16 | Mandatory parameters: ``[]string{"TPid", "RatingProfileId"}`` 17 | 18 | *JSON sample*: 19 | :: 20 | 21 | { 22 | "id": 37, 23 | "method": "ApierV1.SetRatingProfile", 24 | "params": [ 25 | { 26 | "RatingProfileId": "RP_ANY", 27 | "TPid": "CGR_API_TESTS" 28 | } 29 | ] 30 | } 31 | 32 | **Reply**: 33 | 34 | Data: 35 | :: 36 | 37 | string 38 | 39 | Possible answers: 40 | ``OK`` - Success. 41 | 42 | *JSON sample*: 43 | :: 44 | 45 | { 46 | "error": null, 47 | "id": 37, 48 | "result": "OK" 49 | } 50 | 51 | **Errors**: 52 | 53 | ``MANDATORY_IE_MISSING`` - Mandatory parameter missing from request. 54 | 55 | ``SERVER_ERROR`` - Server error occurred. 56 | 57 | 58 | -------------------------------------------------------------------------------- /console/balance_debit.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/api/v1" 4 | 5 | func init() { 6 | c := &CmdBalanceDebit{ 7 | name: "balance_debit", 8 | rpcMethod: "ApiV1.DebitBalance", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdBalanceDebit struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *v1.AttrSetBalance 19 | clientArgs []string 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdBalanceDebit) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdBalanceDebit) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdBalanceDebit) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrSetBalance{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdBalanceDebit) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdBalanceDebit) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/console_old/actions_remove.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/api/v1" 4 | 5 | func init() { 6 | c := &CmdRemoveActions{ 7 | name: "actions_remove", 8 | rpcMethod: "ApiV1.RemoveActions", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdRemoveActions struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *v1.AttrRemoveActions 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdRemoveActions) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdRemoveActions) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdRemoveActions) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &v1.AttrRemoveActions{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdRemoveActions) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdRemoveActions) RpcResult() interface{} { 42 | var s string 43 | return &s 44 | } 45 | -------------------------------------------------------------------------------- /docs/api_accounts.rst: -------------------------------------------------------------------------------- 1 | ApierV1.SetAccountActions 2 | +++++++++++++++++++++++++ 3 | 4 | 5 | Process dependencies and load a specific AccountActions profile from storDb into dataDb. 6 | 7 | **Request**: 8 | 9 | Data: 10 | :: 11 | 12 | type AttrSetAccountActions struct { 13 | TPid string 14 | AccountActionsId string 15 | } 16 | 17 | Mandatory parameters: ``[]string{"TPid", "AccountActionsId"}`` 18 | 19 | *JSON sample*: 20 | :: 21 | 22 | { 23 | "id": 0, 24 | "method": "ApierV1.SetAccountActions", 25 | "params": [ 26 | { 27 | "AccountActionsId": "AA_1005", 28 | "TPid": "CGR_API_TESTS" 29 | } 30 | ] 31 | } 32 | 33 | **Reply**: 34 | 35 | Data: 36 | :: 37 | 38 | string 39 | 40 | Possible answers: 41 | ``OK`` - Success. 42 | 43 | *JSON sample*: 44 | :: 45 | 46 | { 47 | "error": null, 48 | "id": 0, 49 | "result": "OK" 50 | } 51 | 52 | **Errors**: 53 | 54 | ``MANDATORY_IE_MISSING`` - Mandatory parameter missing from request. 55 | 56 | ``SERVER_ERROR`` - Server error occurred. 57 | -------------------------------------------------------------------------------- /console/account_remove.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/api/v1" 5 | ) 6 | 7 | func init() { 8 | c := &CmdRemoveAccount{ 9 | name: "account_remove", 10 | rpcMethod: "ApiV1.RemoveAccount", 11 | } 12 | commands[c.Name()] = c 13 | c.CommandExecuter = &CommandExecuter{c} 14 | } 15 | 16 | // Commander implementation 17 | type CmdRemoveAccount struct { 18 | name string 19 | rpcMethod string 20 | rpcParams *v1.AttrRemoveAccount 21 | *CommandExecuter 22 | } 23 | 24 | func (self *CmdRemoveAccount) Name() string { 25 | return self.name 26 | } 27 | 28 | func (self *CmdRemoveAccount) RpcMethod() string { 29 | return self.rpcMethod 30 | } 31 | 32 | func (self *CmdRemoveAccount) RpcParams(reset bool) interface{} { 33 | if reset || self.rpcParams == nil { 34 | self.rpcParams = &v1.AttrRemoveAccount{} 35 | } 36 | return self.rpcParams 37 | } 38 | 39 | func (self *CmdRemoveAccount) PostprocessRpcParams() error { 40 | return nil 41 | } 42 | 43 | func (self *CmdRemoveAccount) RpcResult() interface{} { 44 | var s string 45 | return &s 46 | } 47 | -------------------------------------------------------------------------------- /console/cdrstats_reset.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &CmdCdrResetQueues{ 7 | name: "cdrstats_reset", 8 | rpcMethod: "CDRStatsV1.ResetQueues", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdCdrResetQueues struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *utils.AttrStatsQueueIDs 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdCdrResetQueues) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdCdrResetQueues) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdCdrResetQueues) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &utils.AttrStatsQueueIDs{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdCdrResetQueues) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdCdrResetQueues) RpcResult() interface{} { 42 | var s string 43 | return &s 44 | } 45 | -------------------------------------------------------------------------------- /console/cdrstats_metrics.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &CmdCdrStatsMetrics{ 7 | name: "cdrstats_metrics", 8 | rpcMethod: "CDRStatsV1.GetMetrics", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdCdrStatsMetrics struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *utils.AttrStatsQueueID 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdCdrStatsMetrics) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdCdrStatsMetrics) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdCdrStatsMetrics) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &utils.AttrStatsQueueID{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdCdrStatsMetrics) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdCdrStatsMetrics) RpcResult() interface{} { 42 | return &map[string]float64{} 43 | } 44 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/Actions.csv: -------------------------------------------------------------------------------- 1 | #ActionsId[0],Action[1],ExtraParameters[2],Filter[3],BalanceId[4],BalanceType[5],Directions[6],Categories[7],DestinationIds[8],RatingSubject[9],SharedGroup[10],ExpiryTime[11],TimingIds[12],Units[13],BalanceWeight[14],BalanceBlocker[15],BalanceDisabled[16],Weight[17] 2 | TOPUP_RST_10,*topup_reset,,,,*monetary,*out,,*any,,,*unlimited,,10,10,false,false,10 3 | TOPUP_RST_5,*topup_reset,,,,*monetary,*out,,*any,,,*unlimited,,5,20,false,false,10 4 | TOPUP_RST_5,*topup_reset,,,,*voice,*out,,DST_1002,SPECIAL_1002,,*unlimited,,90,20,false,false,10 5 | TOPUP_120_DST1003,*topup_reset,,,,*voice,*out,,DST_1003,,,*unlimited,,120,20,false,false,10 6 | TOPUP_RST_SHARED_5,*topup,,,,*monetary,*out,,*any,,SHARED_A,*unlimited,,5,10,false,false,10 7 | SHARED_A_0,*topup_reset,,,,*monetary,*out,,*any,,SHARED_A,*unlimited,,0,10,false,false,10 8 | TOPUP_RST_DATA_100,*topup_reset,,,,*data,*out,,*any,,,*unlimited,,102400,10,false,false,10 9 | LOG_WARNING,*log,,,,,,,,,,,,,,false,false,10 10 | DISABLE_AND_LOG,*log,,,,,,,,,,,,,,false,false,10 11 | DISABLE_AND_LOG,*disable_account,,,,,,,,,,,,,,false,false,10 12 | -------------------------------------------------------------------------------- /console/status.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdStatus{ 7 | name: "status", 8 | rpcMethod: "Responder.Status", 9 | rpcParams: &engine.AttrStatus{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | type CmdStatus struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *engine.AttrStatus 19 | *CommandExecuter 20 | } 21 | 22 | func (self *CmdStatus) Name() string { 23 | return self.name 24 | } 25 | 26 | func (self *CmdStatus) RpcMethod() string { 27 | return self.rpcMethod 28 | } 29 | 30 | func (self *CmdStatus) RpcParams(reset bool) interface{} { 31 | if reset || self.rpcParams == nil { 32 | self.rpcParams = &engine.AttrStatus{} 33 | } 34 | return self.rpcParams 35 | } 36 | 37 | func (self *CmdStatus) PostprocessRpcParams() error { 38 | return nil 39 | } 40 | 41 | func (self *CmdStatus) RpcResult() interface{} { 42 | var s map[string]interface{} 43 | return &s 44 | } 45 | 46 | func (self *CmdStatus) ClientArgs() (args []string) { 47 | return 48 | } 49 | -------------------------------------------------------------------------------- /console/cdrstats_queue_triggers.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdCdrStatsQueueTriggers{ 7 | name: "cdrstats_queue_triggers", 8 | rpcMethod: "CDRStatsV1.GetQueueTriggers", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | type CmdCdrStatsQueueTriggers struct { 15 | name string 16 | rpcMethod string 17 | rpcParams *StringWrapper 18 | *CommandExecuter 19 | } 20 | 21 | func (self *CmdCdrStatsQueueTriggers) Name() string { 22 | return self.name 23 | } 24 | 25 | func (self *CmdCdrStatsQueueTriggers) RpcMethod() string { 26 | return self.rpcMethod 27 | } 28 | 29 | func (self *CmdCdrStatsQueueTriggers) RpcParams(reset bool) interface{} { 30 | if reset || self.rpcParams == nil { 31 | self.rpcParams = &StringWrapper{} 32 | } 33 | return self.rpcParams 34 | } 35 | 36 | func (self *CmdCdrStatsQueueTriggers) PostprocessRpcParams() error { 37 | return nil 38 | } 39 | 40 | func (self *CmdCdrStatsQueueTriggers) RpcResult() interface{} { 41 | return new(engine.ActionTriggers) 42 | } 43 | -------------------------------------------------------------------------------- /console/cdrstats_reload.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/utils" 5 | ) 6 | 7 | func init() { 8 | c := &CmdCdrReloadQueues{ 9 | name: "cdrstats_reload", 10 | rpcMethod: "CDRStatsV1.ReloadQueues", 11 | } 12 | commands[c.Name()] = c 13 | c.CommandExecuter = &CommandExecuter{c} 14 | } 15 | 16 | // Commander implementation 17 | type CmdCdrReloadQueues struct { 18 | name string 19 | rpcMethod string 20 | rpcParams *utils.AttrStatsQueueIDs 21 | *CommandExecuter 22 | } 23 | 24 | func (self *CmdCdrReloadQueues) Name() string { 25 | return self.name 26 | } 27 | 28 | func (self *CmdCdrReloadQueues) RpcMethod() string { 29 | return self.rpcMethod 30 | } 31 | 32 | func (self *CmdCdrReloadQueues) RpcParams(reset bool) interface{} { 33 | if reset || self.rpcParams == nil { 34 | self.rpcParams = &utils.AttrStatsQueueIDs{} 35 | } 36 | return self.rpcParams 37 | } 38 | 39 | func (self *CmdCdrReloadQueues) PostprocessRpcParams() error { 40 | return nil 41 | } 42 | 43 | func (self *CmdCdrReloadQueues) RpcResult() interface{} { 44 | var s string 45 | return &s 46 | } 47 | -------------------------------------------------------------------------------- /history/scribe_test.go: -------------------------------------------------------------------------------- 1 | 2 | package history 3 | 4 | import ( 5 | "strconv" 6 | "testing" 7 | ) 8 | 9 | func TestHistorySet(t *testing.T) { 10 | rs := records{&Record{Id: "first"}} 11 | second := &Record{Id: "first"} 12 | rs.Modify(second) 13 | if len(rs) != 1 || rs[0] != second { 14 | t.Error("error setting new value: ", rs[0]) 15 | } 16 | } 17 | 18 | func TestHistoryAdd(t *testing.T) { 19 | rs := records{&Record{Id: "first"}} 20 | second := &Record{Id: "second"} 21 | rs = rs.Modify(second) 22 | if len(rs) != 2 || rs[1] != second { 23 | t.Error("error setting new value: ", rs) 24 | } 25 | } 26 | 27 | func TestHistoryRemove(t *testing.T) { 28 | rs := records{&Record{Id: "first"}, &Record{Id: "second"}} 29 | rs = rs.Modify(&Record{Id: "first", Deleted: true}) 30 | if len(rs) != 1 || rs[0].Id != "second" { 31 | t.Error("error deleting record: ", rs) 32 | } 33 | } 34 | 35 | func BenchmarkModify(b *testing.B) { 36 | var rs records 37 | for i := 0; i < 1000; i++ { 38 | rs = rs.Modify(&Record{Id: strconv.Itoa(i)}) 39 | } 40 | for i := 0; i < b.N; i++ { 41 | rs.Modify(&Record{Id: "400"}) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /console/balance_set.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/api/v1" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | func init() { 9 | c := &CmdSetBalance{ 10 | name: "balance_set", 11 | rpcMethod: "ApiV1.SetBalance", 12 | } 13 | commands[c.Name()] = c 14 | c.CommandExecuter = &CommandExecuter{c} 15 | } 16 | 17 | // Commander implementation 18 | type CmdSetBalance struct { 19 | name string 20 | rpcMethod string 21 | rpcParams *v1.AttrSetBalance 22 | *CommandExecuter 23 | } 24 | 25 | func (self *CmdSetBalance) Name() string { 26 | return self.name 27 | } 28 | 29 | func (self *CmdSetBalance) RpcMethod() string { 30 | return self.rpcMethod 31 | } 32 | 33 | func (self *CmdSetBalance) RpcParams(reset bool) interface{} { 34 | if reset || self.rpcParams == nil { 35 | self.rpcParams = &v1.AttrSetBalance{TOR: utils.MONETARY} 36 | } 37 | return self.rpcParams 38 | } 39 | 40 | func (self *CmdSetBalance) PostprocessRpcParams() error { 41 | return nil 42 | } 43 | 44 | func (self *CmdSetBalance) RpcResult() interface{} { 45 | var s string 46 | return &s 47 | } 48 | -------------------------------------------------------------------------------- /console/cdrc_config_reload.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/api/v1" 5 | ) 6 | 7 | func init() { 8 | c := &CmdCdrcConfigReload{ 9 | name: "cdrc_config_reload", 10 | rpcMethod: "ApiV1.ReloadCdrcConfig", 11 | } 12 | commands[c.Name()] = c 13 | c.CommandExecuter = &CommandExecuter{c} 14 | } 15 | 16 | // Commander implementation 17 | type CmdCdrcConfigReload struct { 18 | name string 19 | rpcMethod string 20 | rpcParams *v1.AttrReloadConfig 21 | *CommandExecuter 22 | } 23 | 24 | func (self *CmdCdrcConfigReload) Name() string { 25 | return self.name 26 | } 27 | 28 | func (self *CmdCdrcConfigReload) RpcMethod() string { 29 | return self.rpcMethod 30 | } 31 | 32 | func (self *CmdCdrcConfigReload) RpcParams(reset bool) interface{} { 33 | if reset || self.rpcParams == nil { 34 | self.rpcParams = new(v1.AttrReloadConfig) 35 | } 36 | return self.rpcParams 37 | } 38 | 39 | func (self *CmdCdrcConfigReload) PostprocessRpcParams() error { 40 | return nil 41 | } 42 | 43 | func (self *CmdCdrcConfigReload) RpcResult() interface{} { 44 | var s string 45 | return &s 46 | } 47 | -------------------------------------------------------------------------------- /console/cdre_config_reload.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/api/v1" 5 | ) 6 | 7 | func init() { 8 | c := &CmdCdreConfigReload{ 9 | name: "cdre_config_reload", 10 | rpcMethod: "ApiV1.ReloadCdreConfig", 11 | } 12 | commands[c.Name()] = c 13 | c.CommandExecuter = &CommandExecuter{c} 14 | } 15 | 16 | // Commander implementation 17 | type CmdCdreConfigReload struct { 18 | name string 19 | rpcMethod string 20 | rpcParams *v1.AttrReloadConfig 21 | *CommandExecuter 22 | } 23 | 24 | func (self *CmdCdreConfigReload) Name() string { 25 | return self.name 26 | } 27 | 28 | func (self *CmdCdreConfigReload) RpcMethod() string { 29 | return self.rpcMethod 30 | } 31 | 32 | func (self *CmdCdreConfigReload) RpcParams(reset bool) interface{} { 33 | if reset || self.rpcParams == nil { 34 | self.rpcParams = new(v1.AttrReloadConfig) 35 | } 36 | return self.rpcParams 37 | } 38 | 39 | func (self *CmdCdreConfigReload) PostprocessRpcParams() error { 40 | return nil 41 | } 42 | 43 | func (self *CmdCdreConfigReload) RpcResult() interface{} { 44 | var s string 45 | return &s 46 | } 47 | -------------------------------------------------------------------------------- /console/actions.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/api/v1" 5 | "github.com/accurateproject/accurate/engine" 6 | ) 7 | 8 | func init() { 9 | c := &CmdGetActions{ 10 | name: "actions", 11 | rpcMethod: "ApiV1.GetActions", 12 | } 13 | commands[c.Name()] = c 14 | c.CommandExecuter = &CommandExecuter{c} 15 | } 16 | 17 | // Commander implementation 18 | type CmdGetActions struct { 19 | name string 20 | rpcMethod string 21 | rpcParams *v1.AttrGetMultiple 22 | *CommandExecuter 23 | } 24 | 25 | func (self *CmdGetActions) Name() string { 26 | return self.name 27 | } 28 | 29 | func (self *CmdGetActions) RpcMethod() string { 30 | return self.rpcMethod 31 | } 32 | 33 | func (self *CmdGetActions) RpcParams(reset bool) interface{} { 34 | if reset || self.rpcParams == nil { 35 | self.rpcParams = &v1.AttrGetMultiple{} 36 | } 37 | return self.rpcParams 38 | } 39 | 40 | func (self *CmdGetActions) PostprocessRpcParams() error { 41 | return nil 42 | } 43 | 44 | func (self *CmdGetActions) RpcResult() interface{} { 45 | a := make(map[string]engine.Actions, 0) 46 | return &a 47 | } 48 | -------------------------------------------------------------------------------- /console/console_old/destination_set.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &CmdSetDestination{ 7 | name: "destination_set", 8 | rpcMethod: "ApiV1.SetDestination", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdSetDestination struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *utils.AttrSetDestination 19 | rpcResult string 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdSetDestination) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdSetDestination) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdSetDestination) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &utils.AttrSetDestination{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdSetDestination) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdSetDestination) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/console_old/trigger_set.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/apier/v1" 4 | 5 | func init() { 6 | c := &CmdSetTriggers{ 7 | name: "triggers_set", 8 | rpcMethod: "ApiV1.SetActionTrigger", 9 | rpcParams: &v1.AttrSetActionTrigger{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdSetTriggers struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *v1.AttrSetActionTrigger 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdSetTriggers) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdSetTriggers) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdSetTriggers) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrSetActionTrigger{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdSetTriggers) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdSetTriggers) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/console_old/actionplan_set.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/apier/v1" 4 | 5 | func init() { 6 | c := &CmdSetActionPlan{ 7 | name: "actionplan_set", 8 | rpcMethod: "ApiV1.SetActionPlan", 9 | rpcParams: &v1.AttrSetActionPlan{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdSetActionPlan struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *v1.AttrSetActionPlan 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdSetActionPlan) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdSetActionPlan) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdSetActionPlan) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrSetActionPlan{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdSetActionPlan) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdSetActionPlan) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/action_execute.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/utils" 5 | ) 6 | 7 | func init() { 8 | c := &CmdExecuteAction{ 9 | name: "action_execute", 10 | rpcMethod: "ApiV1.ExecuteAction", 11 | rpcParams: &utils.AttrExecuteAction{}, 12 | } 13 | commands[c.Name()] = c 14 | c.CommandExecuter = &CommandExecuter{c} 15 | } 16 | 17 | // Commander implementation 18 | type CmdExecuteAction struct { 19 | name string 20 | rpcMethod string 21 | rpcParams *utils.AttrExecuteAction 22 | *CommandExecuter 23 | } 24 | 25 | func (self *CmdExecuteAction) Name() string { 26 | return self.name 27 | } 28 | 29 | func (self *CmdExecuteAction) RpcMethod() string { 30 | return self.rpcMethod 31 | } 32 | 33 | func (self *CmdExecuteAction) RpcParams(reset bool) interface{} { 34 | if reset || self.rpcParams == nil { 35 | self.rpcParams = &utils.AttrExecuteAction{} 36 | } 37 | return self.rpcParams 38 | } 39 | 40 | func (self *CmdExecuteAction) PostprocessRpcParams() error { 41 | return nil 42 | } 43 | 44 | func (self *CmdExecuteAction) RpcResult() interface{} { 45 | var s string 46 | return &s 47 | } 48 | -------------------------------------------------------------------------------- /console/balance_add.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/api/v1" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | func init() { 9 | c := &CmdAddBalance{ 10 | name: "balance_add", 11 | rpcMethod: "ApiV1.AddBalance", 12 | } 13 | commands[c.Name()] = c 14 | c.CommandExecuter = &CommandExecuter{c} 15 | } 16 | 17 | // Commander implementation 18 | type CmdAddBalance struct { 19 | name string 20 | rpcMethod string 21 | rpcParams *v1.AttrSetBalance 22 | *CommandExecuter 23 | } 24 | 25 | func (self *CmdAddBalance) Name() string { 26 | return self.name 27 | } 28 | 29 | func (self *CmdAddBalance) RpcMethod() string { 30 | return self.rpcMethod 31 | } 32 | 33 | func (self *CmdAddBalance) RpcParams(reset bool) interface{} { 34 | if reset || self.rpcParams == nil { 35 | self.rpcParams = &v1.AttrSetBalance{TOR: utils.MONETARY, Overwrite: false} 36 | } 37 | return self.rpcParams 38 | } 39 | 40 | func (self *CmdAddBalance) PostprocessRpcParams() error { 41 | return nil 42 | } 43 | 44 | func (self *CmdAddBalance) RpcResult() interface{} { 45 | var s string 46 | return &s 47 | } 48 | -------------------------------------------------------------------------------- /console/console_old/load_tp_from_folder.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &LoadTpFromFolder{ 7 | name: "load_tp_from_folder", 8 | rpcMethod: "ApiV1.LoadTariffPlanFromFolder", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type LoadTpFromFolder struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *utils.AttrLoadTpFromFolder 19 | rpcResult string 20 | *CommandExecuter 21 | } 22 | 23 | func (self *LoadTpFromFolder) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *LoadTpFromFolder) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *LoadTpFromFolder) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &utils.AttrLoadTpFromFolder{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *LoadTpFromFolder) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *LoadTpFromFolder) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/console_old/ratingprofile_set.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &CmdSetRatingProfile{ 7 | name: "ratingprofile_set", 8 | rpcMethod: "ApiV1.SetRatingProfile", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdSetRatingProfile struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *utils.TPRatingProfile 19 | rpcResult string 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdSetRatingProfile) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdSetRatingProfile) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdSetRatingProfile) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &utils.TPRatingProfile{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdSetRatingProfile) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdSetRatingProfile) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /glide.yaml: -------------------------------------------------------------------------------- 1 | package: "" 2 | import: 3 | - package: github.com/DisposaBoy/JsonConfigReader 4 | - package: github.com/cenk/hub 5 | - package: github.com/cenk/rpc2 6 | - package: github.com/accurateproject/fsock 7 | - package: github.com/accurateproject/kamevapi 8 | - package: github.com/accurateproject/osipsdagram 9 | - package: github.com/accurateproject/rpcclient 10 | - package: github.com/accurateproject/aringo 11 | - package: github.com/fiorix/go-diameter 12 | subpackages: 13 | - diam 14 | - diam/avp 15 | - diam/datatype 16 | - diam/dict 17 | - diam/sm 18 | - package: github.com/gorhill/cronexpr 19 | - package: github.com/kr/pty 20 | - package: github.com/peterh/liner 21 | - package: golang.org/x/net 22 | subpackages: 23 | - websocket 24 | - package: gopkg.in/fsnotify.v1 25 | - package: gopkg.in/mgo.v2 26 | subpackages: 27 | - bson 28 | - package: github.com/ChrisTrenkamp/goxpath 29 | - package: github.com/mitchellh/mapstructure 30 | - package: github.com/hashicorp/golang-lru 31 | - package: github.com/bit4bit/gami 32 | - package: go.uber.org/zap 33 | - package: github.com/ericlagergren/decimal 34 | - package: github.com/jeffail/tunny 35 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/LcrRules.csv: -------------------------------------------------------------------------------- 1 | #Direction,Tenant,Category,Account,Subject,DestinationId,RPCategory,Strategy,StrategyParams,ActivationTime,Weight 2 | *out,cgrates.org,call,1001,*any,DST_1002,lcr_profile1,*static,suppl2;suppl1,2014-01-14T00:00:00Z,10 3 | *out,cgrates.org,call,1001,*any,*any,lcr_profile1,*static,suppl1;suppl2,2014-01-14T00:00:00Z,10 4 | *out,cgrates.org,call,1002,*any,DST_1002,lcr_profile1,*highest_cost,,2014-01-14T00:00:00Z,10 5 | *out,cgrates.org,call,1002,*any,*any,lcr_profile1,*qos,,2014-01-14T00:00:00Z,10 6 | *out,cgrates.org,call,1003,*any,DST_1002,lcr_profile1,*qos_threshold,20;;;;2m;;;;;;;,2014-01-14T00:00:00Z,10 7 | *out,cgrates.org,call,1003,*any,*any,lcr_profile1,*qos_threshold,40;;;;90s;;;;;;;,2014-01-14T00:00:00Z,10 8 | *out,cgrates.org,call,1004,*any,DST_1002,lcr_profile1,*load_distribution,supplier1:5;supplier2:3;*default:1,2014-01-14T00:00:00Z,10 9 | *out,cgrates.org,call,1004,*any,*any,lcr_profile1,*load_distribution,,2014-01-14T00:00:00Z,10 10 | *out,cgrates.org,call,*any,*any,DST_1002,lcr_profile2,*lowest_cost,,2014-01-14T00:00:00Z,10 11 | *out,cgrates.org,call,*any,*any,*any,lcr_profile1,*lowest_cost,,2014-01-14T00:00:00Z,10 -------------------------------------------------------------------------------- /console/lcr.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/engine" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | func init() { 9 | c := &CmdGetLcr{ 10 | name: "lcr", 11 | rpcMethod: "ApiV1.GetLcr", 12 | rpcParams: &engine.LcrRequest{Paginator: &utils.Paginator{}}, 13 | } 14 | commands[c.Name()] = c 15 | c.CommandExecuter = &CommandExecuter{c} 16 | } 17 | 18 | // Commander implementation 19 | type CmdGetLcr struct { 20 | name string 21 | rpcMethod string 22 | rpcParams *engine.LcrRequest 23 | *CommandExecuter 24 | } 25 | 26 | func (self *CmdGetLcr) Name() string { 27 | return self.name 28 | } 29 | 30 | func (self *CmdGetLcr) RpcMethod() string { 31 | return self.rpcMethod 32 | } 33 | 34 | func (self *CmdGetLcr) RpcParams(reset bool) interface{} { 35 | if reset || self.rpcParams == nil { 36 | self.rpcParams = &engine.LcrRequest{Paginator: &utils.Paginator{}} 37 | } 38 | return self.rpcParams 39 | } 40 | 41 | func (self *CmdGetLcr) PostprocessRpcParams() error { 42 | return nil 43 | } 44 | 45 | func (self *CmdGetLcr) RpcResult() interface{} { 46 | return &engine.LcrReply{} 47 | } 48 | -------------------------------------------------------------------------------- /console/cdrstats_queueids.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/api/v1" 4 | 5 | func init() { 6 | c := &CmdCdrStatsQueueIds{ 7 | name: "cdrstats_queueids", 8 | rpcMethod: "CDRStatsV1.GetQueueIDs", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | type CmdCdrStatsQueueIds struct { 15 | name string 16 | rpcMethod string 17 | rpcParams *v1.AttrTenant 18 | *CommandExecuter 19 | } 20 | 21 | func (self *CmdCdrStatsQueueIds) Name() string { 22 | return self.name 23 | } 24 | 25 | func (self *CmdCdrStatsQueueIds) RpcMethod() string { 26 | return self.rpcMethod 27 | } 28 | 29 | func (self *CmdCdrStatsQueueIds) RpcParams(reset bool) interface{} { 30 | if reset || self.rpcParams == nil { 31 | self.rpcParams = &v1.AttrTenant{} 32 | } 33 | return self.rpcParams 34 | } 35 | 36 | func (self *CmdCdrStatsQueueIds) PostprocessRpcParams() error { 37 | return nil 38 | } 39 | 40 | func (self *CmdCdrStatsQueueIds) RpcResult() interface{} { 41 | var s []string 42 | return &s 43 | } 44 | 45 | func (self *CmdCdrStatsQueueIds) ClientArgs() (args []string) { 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /console/console_old/trigger_remove.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/apier/v1" 4 | 5 | func init() { 6 | c := &CmdRemoveTriggers{ 7 | name: "triggers_remove", 8 | rpcMethod: "ApiV1.RemoveActionTrigger", 9 | rpcParams: &v1.AttrRemoveActionTrigger{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdRemoveTriggers struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *v1.AttrRemoveActionTrigger 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdRemoveTriggers) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdRemoveTriggers) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdRemoveTriggers) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrRemoveActionTrigger{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdRemoveTriggers) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdRemoveTriggers) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/destinations.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/api/v1" 5 | "github.com/accurateproject/accurate/engine" 6 | ) 7 | 8 | func init() { 9 | c := &CmdGetDestination{ 10 | name: "destinations", 11 | rpcMethod: "ApiV1.GetDestinations", 12 | } 13 | commands[c.Name()] = c 14 | c.CommandExecuter = &CommandExecuter{c} 15 | } 16 | 17 | // Commander implementation 18 | type CmdGetDestination struct { 19 | name string 20 | rpcMethod string 21 | rpcParams *v1.AttrGetMultiple 22 | *CommandExecuter 23 | } 24 | 25 | func (self *CmdGetDestination) Name() string { 26 | return self.name 27 | } 28 | 29 | func (self *CmdGetDestination) RpcMethod() string { 30 | return self.rpcMethod 31 | } 32 | 33 | func (self *CmdGetDestination) RpcParams(reset bool) interface{} { 34 | if reset || self.rpcParams == nil { 35 | self.rpcParams = &v1.AttrGetMultiple{} 36 | } 37 | return self.rpcParams 38 | } 39 | 40 | func (self *CmdGetDestination) PostprocessRpcParams() error { 41 | return nil 42 | } 43 | 44 | func (self *CmdGetDestination) RpcResult() interface{} { 45 | a := make([]*engine.Destination, 0) 46 | return &a 47 | } 48 | -------------------------------------------------------------------------------- /console/indexes_ensure.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/api/v1" 5 | ) 6 | 7 | func init() { 8 | c := &CmdEnsureIndexes{ 9 | name: "indexes_ensure", 10 | rpcMethod: "ApiV1.EnsureIndexes", 11 | rpcParams: &v1.AttrEmpty{}, 12 | } 13 | commands[c.Name()] = c 14 | c.CommandExecuter = &CommandExecuter{c} 15 | } 16 | 17 | type CmdEnsureIndexes struct { 18 | name string 19 | rpcMethod string 20 | rpcParams *v1.AttrEmpty 21 | *CommandExecuter 22 | } 23 | 24 | func (self *CmdEnsureIndexes) Name() string { 25 | return self.name 26 | } 27 | 28 | func (self *CmdEnsureIndexes) RpcMethod() string { 29 | return self.rpcMethod 30 | } 31 | 32 | func (self *CmdEnsureIndexes) RpcParams(reset bool) interface{} { 33 | if reset || self.rpcParams == nil { 34 | self.rpcParams = &v1.AttrEmpty{} 35 | } 36 | return self.rpcParams 37 | } 38 | 39 | func (self *CmdEnsureIndexes) PostprocessRpcParams() error { 40 | return nil 41 | } 42 | 43 | func (self *CmdEnsureIndexes) RpcResult() interface{} { 44 | var s string 45 | return &s 46 | } 47 | 48 | func (self *CmdEnsureIndexes) ClientArgs() (args []string) { 49 | return 50 | } 51 | -------------------------------------------------------------------------------- /console/accounts.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/api/v1" 5 | "github.com/accurateproject/accurate/engine" 6 | ) 7 | 8 | func init() { 9 | c := &CmdGetAccounts{ 10 | name: "accounts", 11 | rpcMethod: "ApiV1.GetAccounts", 12 | rpcParams: &v1.AttrGetMultiple{}, 13 | } 14 | commands[c.Name()] = c 15 | c.CommandExecuter = &CommandExecuter{c} 16 | } 17 | 18 | // Commander implementation 19 | type CmdGetAccounts struct { 20 | name string 21 | rpcMethod string 22 | rpcParams *v1.AttrGetMultiple 23 | *CommandExecuter 24 | } 25 | 26 | func (self *CmdGetAccounts) Name() string { 27 | return self.name 28 | } 29 | 30 | func (self *CmdGetAccounts) RpcMethod() string { 31 | return self.rpcMethod 32 | } 33 | 34 | func (self *CmdGetAccounts) RpcParams(reset bool) interface{} { 35 | if reset || self.rpcParams == nil { 36 | self.rpcParams = &v1.AttrGetMultiple{} 37 | } 38 | return self.rpcParams 39 | } 40 | 41 | func (self *CmdGetAccounts) PostprocessRpcParams() error { 42 | return nil 43 | } 44 | 45 | func (self *CmdGetAccounts) RpcResult() interface{} { 46 | a := make([]*engine.Account, 0) 47 | return &a 48 | } 49 | -------------------------------------------------------------------------------- /console/aliases.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/engine" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | func init() { 9 | c := &CmdGetAliases{ 10 | name: "aliases", 11 | rpcMethod: "AliasesV1.GetAlias", 12 | rpcParams: &engine.Alias{Direction: utils.OUT}, 13 | } 14 | commands[c.Name()] = c 15 | c.CommandExecuter = &CommandExecuter{c} 16 | } 17 | 18 | // Commander implementation 19 | type CmdGetAliases struct { 20 | name string 21 | rpcMethod string 22 | rpcParams *engine.Alias 23 | *CommandExecuter 24 | } 25 | 26 | func (self *CmdGetAliases) Name() string { 27 | return self.name 28 | } 29 | 30 | func (self *CmdGetAliases) RpcMethod() string { 31 | return self.rpcMethod 32 | } 33 | 34 | func (self *CmdGetAliases) RpcParams(reset bool) interface{} { 35 | if reset || self.rpcParams == nil { 36 | self.rpcParams = &engine.Alias{Direction: utils.OUT} 37 | } 38 | return self.rpcParams 39 | } 40 | 41 | func (self *CmdGetAliases) PostprocessRpcParams() error { 42 | return nil 43 | } 44 | 45 | func (self *CmdGetAliases) RpcResult() interface{} { 46 | a := engine.Alias{} 47 | return &a 48 | } 49 | -------------------------------------------------------------------------------- /console/balance_remove.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/api/v1" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | func init() { 9 | c := &CmdRemoveBalance{ 10 | name: "balance_remove", 11 | rpcMethod: "ApiV1.RemoveBalances", 12 | } 13 | commands[c.Name()] = c 14 | c.CommandExecuter = &CommandExecuter{c} 15 | } 16 | 17 | // Commander implementation 18 | type CmdRemoveBalance struct { 19 | name string 20 | rpcMethod string 21 | rpcParams *v1.AttrSetBalance 22 | *CommandExecuter 23 | } 24 | 25 | func (self *CmdRemoveBalance) Name() string { 26 | return self.name 27 | } 28 | 29 | func (self *CmdRemoveBalance) RpcMethod() string { 30 | return self.rpcMethod 31 | } 32 | 33 | func (self *CmdRemoveBalance) RpcParams(reset bool) interface{} { 34 | if reset || self.rpcParams == nil { 35 | self.rpcParams = &v1.AttrSetBalance{TOR: utils.MONETARY, Overwrite: false} 36 | } 37 | return self.rpcParams 38 | } 39 | 40 | func (self *CmdRemoveBalance) PostprocessRpcParams() error { 41 | return nil 42 | } 43 | 44 | func (self *CmdRemoveBalance) RpcResult() interface{} { 45 | var s string 46 | return &s 47 | } 48 | -------------------------------------------------------------------------------- /data/tariffplans/testtp/ActionTriggers.csv: -------------------------------------------------------------------------------- 1 | #Tag[0],UniqueId[1],ThresholdType[2],ThresholdValue[3],Recurrent[4],MinSleep[5],ExpiryTime[6],ActivationTime[7],BalanceTag[8],BalanceType[9],BalanceDirections[10],BalanceCategories[11],BalanceDestinationIds[12],BalanceRatingSubject[13],BalanceSharedGroup[14],BalanceExpiryTime[15],BalanceTimingIds[16],BalanceWeight[17],BalanceBlocker[18],BalanceDisabled[19],StatsMinQueuedItems[20],ActionsId[21],Weight[22] 2 | STANDARD_TRIGGERS,,*min_balance,2,false,0,,,,*monetary,*out,,,,,,,,,,,LOG_BALANCE,10 3 | STANDARD_TRIGGERS,,*max_balance,20,false,0,,,,*monetary,*out,,,,,,,,,,,LOG_BALANCE,10 4 | STANDARD_TRIGGERS,,*max_event_counter,15,false,0,,,,*monetary,*out,,FS_USERS,,,,,,,,,LOG_BALANCE,10 5 | STANDARD_TRIGGERS,,*max_balance_counter,1,false,0,,,,*monetary,*out,,,,,,,,,,,LOG_BALANCE,10 6 | CDRST1_WARN_ASR,,*min_asr,45,true,1h,,,,,,,,,,,,,,,3,CDRST_WARN_HTTP,10 7 | CDRST1_WARN_ACD,,*min_acd,10,true,1h,,,,,,,,,,,,,,,5,CDRST_WARN_HTTP,10 8 | CDRST1_WARN_ACC,,*max_acc,10,true,10m,,,,,,,,,,,,,,,5,CDRST_WARN_HTTP,10 9 | CDRST2_WARN_ASR,,*min_asr,30,true,0,,,,,,,,,,,,,,,5,CDRST_WARN_HTTP,10 10 | CDRST2_WARN_ACD,,*min_acd,3,true,0,,,,,,,,,,,,,,,2,CDRST_LOG,10 11 | -------------------------------------------------------------------------------- /utils/errors_test.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestCGRErrorActivate(t *testing.T) { 8 | ctx := "TEST_CONTEXT" 9 | apiErr := "TEST_API_ERR" 10 | shortErr := "short error" 11 | longErr := "long error which is good for debug" 12 | err := NewCGRError(ctx, apiErr, shortErr, longErr) 13 | if ctxRcv := err.Context(); ctxRcv != ctx { 14 | t.Errorf("Context: <%s>", ctxRcv) 15 | } 16 | if err.Error() != shortErr { 17 | t.Error(err) 18 | } 19 | err.ActivateAPIError() 20 | if err.Error() != apiErr { 21 | t.Error(err) 22 | } 23 | err.ActivateLongError() 24 | if err.Error() != longErr { 25 | t.Error(err) 26 | } 27 | } 28 | 29 | func TestAPIErrorHandler(t *testing.T) { 30 | if err := APIErrorHandler(ErrNotImplemented); err.Error() != NewErrServerError(ErrNotImplemented).Error() { 31 | t.Error(err) 32 | } 33 | if err := APIErrorHandler(ErrNotFound); err.Error() != ErrNotFound.Error() { 34 | t.Error(err) 35 | } 36 | cgrErr := NewCGRError("TEST_CONTEXT", "TEST_API_ERR", "short error", "long error which is good for debug") 37 | if err := APIErrorHandler(cgrErr); err.Error() != cgrErr.apiError { 38 | t.Error(err) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /data/freeswitch/conf/directory/default/1000.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/tut_freeswitch_installs.rst: -------------------------------------------------------------------------------- 1 | Software installation 2 | ===================== 3 | 4 | As operating system we have chosen Debian Jessie, since all the software components we use provide packaging for it. 5 | 6 | 7 | FreeSWITCH_ 8 | ----------- 9 | 10 | More information regarding installing FreeSWITCH_ on Debian can be found on it's official `installation wiki `_. 11 | 12 | To get FreeSWITCH_ installed and configured, we have choosen the simplest method, out of *vanilla* packages plus one individual module we need: *mod-json-cdr*. 13 | 14 | We got FreeSWITCH_ installed via following commands: 15 | 16 | :: 17 | 18 | wget -O - http://files.freeswitch.org/repo/deb/freeswitch-1.6/key.gpg |apt-key add - 19 | echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list 20 | apt-get update 21 | apt-get install freeswitch-meta-vanilla freeswitch-mod-json-cdr libyuv-dev 22 | 23 | Once installed we proceed with loading the configuration out of specific tutorial cases bellow. 24 | 25 | .. _FreeSWITCH: http://www.freeswitch.org/ 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /console/aliases_reverse.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdGetReverseAliases{ 7 | name: "aliases_reverse", 8 | rpcMethod: "AliasesV1.GetReverseAlias", 9 | rpcParams: &engine.AttrReverseAlias{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdGetReverseAliases struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *engine.AttrReverseAlias 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdGetReverseAliases) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdGetReverseAliases) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdGetReverseAliases) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &engine.AttrReverseAlias{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdGetReverseAliases) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdGetReverseAliases) RpcResult() interface{} { 43 | a := make(map[string][]*engine.Alias) 44 | return &a 45 | } 46 | -------------------------------------------------------------------------------- /console/callcost.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/engine" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | func init() { 9 | c := &CmdGetCostDetails{ 10 | name: "cost_details", 11 | rpcMethod: "ApiV1.GetCallCostLog", 12 | } 13 | commands[c.Name()] = c 14 | c.CommandExecuter = &CommandExecuter{c} 15 | } 16 | 17 | // Commander implementation 18 | type CmdGetCostDetails struct { 19 | name string 20 | rpcMethod string 21 | rpcParams *utils.AttrGetCallCost 22 | rpcResult string 23 | *CommandExecuter 24 | } 25 | 26 | func (self *CmdGetCostDetails) Name() string { 27 | return self.name 28 | } 29 | 30 | func (self *CmdGetCostDetails) RpcMethod() string { 31 | return self.rpcMethod 32 | } 33 | 34 | func (self *CmdGetCostDetails) RpcParams(reset bool) interface{} { 35 | if reset || self.rpcParams == nil { 36 | self.rpcParams = &utils.AttrGetCallCost{RunID: utils.DEFAULT_RUNID} 37 | } 38 | return self.rpcParams 39 | } 40 | 41 | func (self *CmdGetCostDetails) PostprocessRpcParams() error { 42 | return nil 43 | } 44 | 45 | func (self *CmdGetCostDetails) RpcResult() interface{} { 46 | return &engine.CallCost{} 47 | } 48 | -------------------------------------------------------------------------------- /console/console_old/load_history.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | func init() { 6 | c := &CmdGetLoadHistory{ 7 | name: "load_history", 8 | rpcMethod: "ApiV1.GetLoadHistory", 9 | rpcParams: new(utils.Paginator), 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Returns the list of load items from the history, in reverse order 16 | type CmdGetLoadHistory struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *utils.Paginator 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdGetLoadHistory) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdGetLoadHistory) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdGetLoadHistory) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = new(utils.Paginator) 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdGetLoadHistory) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdGetLoadHistory) RpcResult() interface{} { 43 | a := make([]*utils.LoadInstance, 0) 44 | return &a 45 | } 46 | -------------------------------------------------------------------------------- /console/maxusage.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdGetMaxUsage{ 7 | name: "maxusage", 8 | rpcMethod: "ApiV1.GetMaxUsage", 9 | } 10 | commands[c.Name()] = c 11 | c.CommandExecuter = &CommandExecuter{c} 12 | } 13 | 14 | // Commander implementation 15 | type CmdGetMaxUsage struct { 16 | name string 17 | rpcMethod string 18 | rpcParams *engine.UsageRecord 19 | clientArgs []string 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdGetMaxUsage) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdGetMaxUsage) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdGetMaxUsage) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &engine.UsageRecord{Direction: "*out"} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdGetMaxUsage) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdGetMaxUsage) RpcResult() interface{} { 43 | var f float64 44 | return &f 45 | } 46 | 47 | func (self *CmdGetMaxUsage) ClientArgs() []string { 48 | return self.clientArgs 49 | } 50 | -------------------------------------------------------------------------------- /console/aliases_remove.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/engine" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | func init() { 9 | c := &CmdRemoveAliases{ 10 | name: "aliases_remove", 11 | rpcMethod: "AliasesV1.RemoveAlias", 12 | rpcParams: &engine.Alias{Direction: utils.OUT}, 13 | } 14 | commands[c.Name()] = c 15 | c.CommandExecuter = &CommandExecuter{c} 16 | } 17 | 18 | // Commander implementation 19 | type CmdRemoveAliases struct { 20 | name string 21 | rpcMethod string 22 | rpcParams *engine.Alias 23 | *CommandExecuter 24 | } 25 | 26 | func (self *CmdRemoveAliases) Name() string { 27 | return self.name 28 | } 29 | 30 | func (self *CmdRemoveAliases) RpcMethod() string { 31 | return self.rpcMethod 32 | } 33 | 34 | func (self *CmdRemoveAliases) RpcParams(reset bool) interface{} { 35 | if reset || self.rpcParams == nil { 36 | self.rpcParams = &engine.Alias{Direction: utils.OUT} 37 | } 38 | return self.rpcParams 39 | } 40 | 41 | func (self *CmdRemoveAliases) PostprocessRpcParams() error { 42 | return nil 43 | } 44 | 45 | func (self *CmdRemoveAliases) RpcResult() interface{} { 46 | var s string 47 | return &s 48 | } 49 | -------------------------------------------------------------------------------- /console/console_old/triggers.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/apier/v1" 5 | "github.com/accurateproject/accurate/engine" 6 | ) 7 | 8 | func init() { 9 | c := &CmdGetTriggers{ 10 | name: "triggers", 11 | rpcMethod: "ApiV1.GetActionTriggers", 12 | rpcParams: &v1.AttrGetActionTriggers{}, 13 | } 14 | commands[c.Name()] = c 15 | c.CommandExecuter = &CommandExecuter{c} 16 | } 17 | 18 | // Commander implementation 19 | type CmdGetTriggers struct { 20 | name string 21 | rpcMethod string 22 | rpcParams *v1.AttrGetActionTriggers 23 | *CommandExecuter 24 | } 25 | 26 | func (self *CmdGetTriggers) Name() string { 27 | return self.name 28 | } 29 | 30 | func (self *CmdGetTriggers) RpcMethod() string { 31 | return self.rpcMethod 32 | } 33 | 34 | func (self *CmdGetTriggers) RpcParams(reset bool) interface{} { 35 | if reset || self.rpcParams == nil { 36 | self.rpcParams = &v1.AttrGetActionTriggers{} 37 | } 38 | return self.rpcParams 39 | } 40 | 41 | func (self *CmdGetTriggers) PostprocessRpcParams() error { 42 | return nil 43 | } 44 | 45 | func (self *CmdGetTriggers) RpcResult() interface{} { 46 | atr := engine.ActionTriggers{} 47 | return &atr 48 | } 49 | -------------------------------------------------------------------------------- /console/scheduler_queue.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/api/v1" 4 | 5 | func init() { 6 | c := &CmdGetScheduledActions{ 7 | name: "scheduler_queue", 8 | rpcMethod: "ApiV1.GetScheduledActions", 9 | rpcParams: &v1.AttrsGetScheduledActions{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdGetScheduledActions struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *v1.AttrsGetScheduledActions 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdGetScheduledActions) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdGetScheduledActions) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdGetScheduledActions) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrsGetScheduledActions{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdGetScheduledActions) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdGetScheduledActions) RpcResult() interface{} { 43 | s := make([]*v1.ScheduledActions, 0) 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/active_sessions.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/sessionmanager" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | func init() { 9 | c := &CmdActiveSessions{ 10 | name: "active_sessions", 11 | rpcMethod: "SessionManagerV1.ActiveSessions", 12 | } 13 | commands[c.Name()] = c 14 | c.CommandExecuter = &CommandExecuter{c} 15 | } 16 | 17 | // Commander implementation 18 | type CmdActiveSessions struct { 19 | name string 20 | rpcMethod string 21 | rpcParams *utils.AttrGetSMASessions 22 | *CommandExecuter 23 | } 24 | 25 | func (self *CmdActiveSessions) Name() string { 26 | return self.name 27 | } 28 | 29 | func (self *CmdActiveSessions) RpcMethod() string { 30 | return self.rpcMethod 31 | } 32 | 33 | func (self *CmdActiveSessions) RpcParams(reset bool) interface{} { 34 | if reset || self.rpcParams == nil { 35 | self.rpcParams = &utils.AttrGetSMASessions{} 36 | } 37 | return self.rpcParams 38 | } 39 | 40 | func (self *CmdActiveSessions) PostprocessRpcParams() error { 41 | return nil 42 | } 43 | 44 | func (self *CmdActiveSessions) RpcResult() interface{} { 45 | var sessions *[]*sessionmanager.ActiveSession 46 | return &sessions 47 | } 48 | -------------------------------------------------------------------------------- /console/console_old/account_actionplan_get.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/apier/v1" 4 | 5 | func init() { 6 | c := &CmdGetAccountActionPlan{ 7 | name: "account_actionplan_get", 8 | rpcMethod: "ApiV1.GetAccountActionPlan", 9 | rpcParams: &v1.AttrAcntAction{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdGetAccountActionPlan struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *v1.AttrAcntAction 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdGetAccountActionPlan) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdGetAccountActionPlan) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdGetAccountActionPlan) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrAcntAction{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdGetAccountActionPlan) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdGetAccountActionPlan) RpcResult() interface{} { 43 | s := make([]*v1.AccountActionTiming, 0) 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/console_old/account_trigger_add.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/apier/v1" 4 | 5 | func init() { 6 | c := &CmdAccountAddTriggers{ 7 | name: "account_triggers_add", 8 | rpcMethod: "ApiV1.AddAccountActionTriggers", 9 | rpcParams: &v1.AttrAddAccountActionTriggers{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdAccountAddTriggers struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *v1.AttrAddAccountActionTriggers 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdAccountAddTriggers) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdAccountAddTriggers) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdAccountAddTriggers) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrAddAccountActionTriggers{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdAccountAddTriggers) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdAccountAddTriggers) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/console_old/account_trigger_set.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/apier/v1" 4 | 5 | func init() { 6 | c := &CmdAccountSetTriggers{ 7 | name: "account_triggers_set", 8 | rpcMethod: "ApiV1.SetAccountActionTriggers", 9 | rpcParams: &v1.AttrSetAccountActionTriggers{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdAccountSetTriggers struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *v1.AttrSetAccountActionTriggers 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdAccountSetTriggers) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdAccountSetTriggers) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdAccountSetTriggers) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrSetAccountActionTriggers{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdAccountSetTriggers) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdAccountSetTriggers) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/console_old/actionplan_get.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/apier/v1" 5 | "github.com/accurateproject/accurate/engine" 6 | ) 7 | 8 | func init() { 9 | c := &CmdGetActionPlan{ 10 | name: "actionplan_get", 11 | rpcMethod: "ApiV1.GetActionPlan", 12 | rpcParams: &v1.AttrGetActionPlan{}, 13 | } 14 | commands[c.Name()] = c 15 | c.CommandExecuter = &CommandExecuter{c} 16 | } 17 | 18 | // Commander implementation 19 | type CmdGetActionPlan struct { 20 | name string 21 | rpcMethod string 22 | rpcParams *v1.AttrGetActionPlan 23 | *CommandExecuter 24 | } 25 | 26 | func (self *CmdGetActionPlan) Name() string { 27 | return self.name 28 | } 29 | 30 | func (self *CmdGetActionPlan) RpcMethod() string { 31 | return self.rpcMethod 32 | } 33 | 34 | func (self *CmdGetActionPlan) RpcParams(reset bool) interface{} { 35 | if reset || self.rpcParams == nil { 36 | self.rpcParams = &v1.AttrGetActionPlan{} 37 | } 38 | return self.rpcParams 39 | } 40 | 41 | func (self *CmdGetActionPlan) PostprocessRpcParams() error { 42 | return nil 43 | } 44 | 45 | func (self *CmdGetActionPlan) RpcResult() interface{} { 46 | s := make([]*engine.ActionPlan, 0) 47 | return &s 48 | } 49 | -------------------------------------------------------------------------------- /console/aliases_set.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/engine" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | func init() { 9 | c := &CmdSetAliases{ 10 | name: "aliases_set", 11 | rpcMethod: "AliasesV1.SetAlias", 12 | rpcParams: &engine.AttrAddAlias{Alias: &engine.Alias{Direction: utils.OUT}}, 13 | } 14 | commands[c.Name()] = c 15 | c.CommandExecuter = &CommandExecuter{c} 16 | } 17 | 18 | // Commander implementation 19 | type CmdSetAliases struct { 20 | name string 21 | rpcMethod string 22 | rpcParams *engine.AttrAddAlias 23 | *CommandExecuter 24 | } 25 | 26 | func (self *CmdSetAliases) Name() string { 27 | return self.name 28 | } 29 | 30 | func (self *CmdSetAliases) RpcMethod() string { 31 | return self.rpcMethod 32 | } 33 | 34 | func (self *CmdSetAliases) RpcParams(reset bool) interface{} { 35 | if reset || self.rpcParams == nil { 36 | self.rpcParams = &engine.AttrAddAlias{Alias: &engine.Alias{Direction: utils.OUT}} 37 | } 38 | return self.rpcParams 39 | } 40 | 41 | func (self *CmdSetAliases) PostprocessRpcParams() error { 42 | return nil 43 | } 44 | 45 | func (self *CmdSetAliases) RpcResult() interface{} { 46 | var s string 47 | return &s 48 | } 49 | -------------------------------------------------------------------------------- /console/scheduler_execute.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/api/v1" 4 | 5 | func init() { 6 | c := &CmdExecuteScheduledActions{ 7 | name: "scheduler_execute", 8 | rpcMethod: "ApiV1.ExecuteScheduledActions", 9 | rpcParams: &v1.AttrsExecuteScheduledActions{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdExecuteScheduledActions struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *v1.AttrsExecuteScheduledActions 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdExecuteScheduledActions) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdExecuteScheduledActions) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdExecuteScheduledActions) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrsExecuteScheduledActions{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdExecuteScheduledActions) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdExecuteScheduledActions) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /console/console_old/ratingprofile_rem.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "github.com/accurateproject/accurate/apier/v1" 5 | "github.com/accurateproject/accurate/utils" 6 | ) 7 | 8 | func init() { 9 | c := &CmdRemRatingProfile{ 10 | name: "ratingprofile_rem", 11 | rpcMethod: "ApiV1.RemoveRatingProfile", 12 | } 13 | commands[c.Name()] = c 14 | c.CommandExecuter = &CommandExecuter{c} 15 | } 16 | 17 | // Commander implementation 18 | type CmdRemRatingProfile struct { 19 | name string 20 | rpcMethod string 21 | rpcParams *v1.AttrRemoveRatingProfile 22 | rpcResult string 23 | *CommandExecuter 24 | } 25 | 26 | func (self *CmdRemRatingProfile) Name() string { 27 | return self.name 28 | } 29 | 30 | func (self *CmdRemRatingProfile) RpcMethod() string { 31 | return self.rpcMethod 32 | } 33 | 34 | func (self *CmdRemRatingProfile) RpcParams(reset bool) interface{} { 35 | if reset || self.rpcParams == nil { 36 | self.rpcParams = &v1.AttrRemoveRatingProfile{Direction: utils.OUT} 37 | } 38 | return self.rpcParams 39 | } 40 | 41 | func (self *CmdRemRatingProfile) PostprocessRpcParams() error { 42 | return nil 43 | } 44 | 45 | func (self *CmdRemRatingProfile) RpcResult() interface{} { 46 | var s string 47 | return &s 48 | } 49 | -------------------------------------------------------------------------------- /engine/event.go: -------------------------------------------------------------------------------- 1 | package engine 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/accurateproject/accurate/utils" 7 | ) 8 | 9 | type Event interface { 10 | GetName() string 11 | GetUniqueID(timezone string) string 12 | GetUUID() string 13 | GetSessionIds() []string // Returns identifiers needed to control a session (eg disconnect) 14 | GetDirection(string) string 15 | GetSubject(string) string 16 | GetAccount(string) string 17 | GetDestination(string) string 18 | GetCallDestNr(string) string 19 | GetOriginatorIP(string) string 20 | GetCategory(string) string 21 | GetTenant(string) string 22 | GetReqType(string) string 23 | GetSetupTime(string, string) (time.Time, error) 24 | GetAnswerTime(string, string) (time.Time, error) 25 | GetEndTime(string, string) (time.Time, error) 26 | GetDuration(string) (time.Duration, error) 27 | GetPdd(string) (time.Duration, error) 28 | GetSupplier(string) string 29 | GetDisconnectCause(string) string 30 | GetExtraFields() map[string]string 31 | MissingParameter(string) bool 32 | ParseEventValue(*utils.RSRField, string) string 33 | AsStoredCdr(timezone string) *CDR 34 | String() string 35 | AsEvent(string) Event 36 | ComputeLcr() bool 37 | AsMapStringIface() (map[string]interface{}, error) 38 | } 39 | -------------------------------------------------------------------------------- /utils/README.md: -------------------------------------------------------------------------------- 1 | # structmatcher 2 | Query language for matching structures 3 | 4 | [![Build Status](https://secure.travis-ci.org/cgrates/structmatcher.png)](http://travis-ci.org/cgrates/structmatcher) 5 | 6 | The StructMatcher type will parse a condition string and match it against a given structure. 7 | 8 | The condition syntax is a json encoded string similar to mongodb query language. 9 | 10 | Examples: 11 | - {"Weight":{"*gt":50}} checks for a balance with weight greater than 50 12 | - {"*or":[{"Value":{"*eq":0}},{"Value":{"*gte":100}}] checks for a balance with value equal to 0 or equal or highr than 100 13 | 14 | Available operators: 15 | - *eq: equal 16 | - *gt: greater than 17 | - *gte: greater or equal than 18 | - *lt: less then 19 | - *lte: less or equal than 20 | - *exp: expired 21 | - *or: logical or 22 | - *and: logical and 23 | - *not: logical not 24 | - *has: receives a list of elements and checks that the elements are present in the specified field (StringMap type) 25 | - *rsr: will apply a rsr check to the field (see utils/rsrfield.go) 26 | 27 | Equal (*eq) and local and (*and) operators are implicit for shortcuts. In this way: 28 | 29 | {"*and":[{"Value":{"*eq":3}},{"Weight":{"*eq":10}}]} is equivalent to: {"Value":3, "Weight":10}. 30 | -------------------------------------------------------------------------------- /console/console_old/account_trigger_reset.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/apier/v1" 4 | 5 | func init() { 6 | c := &CmdAccountResetTriggers{ 7 | name: "account_triggers_reset", 8 | rpcMethod: "ApiV1.ResetAccountActionTriggers", 9 | rpcParams: &v1.AttrRemoveAccountActionTriggers{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdAccountResetTriggers struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *v1.AttrRemoveAccountActionTriggers 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdAccountResetTriggers) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdAccountResetTriggers) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdAccountResetTriggers) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrRemoveAccountActionTriggers{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdAccountResetTriggers) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdAccountResetTriggers) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /docs/csv_tpdestratetimings.rst: -------------------------------------------------------------------------------- 1 | DestinationRateTimings.csv 2 | ++++++++++++++++++++++++++ 3 | 4 | Enable DestinationRates at specific times. 5 | 6 | CSV fields examples as tabular representations: 7 | 8 | +-----------------+----------------------+-----------+--------+ 9 | | Tag | DestinationRatesTag | TimingTag | Weight | 10 | +=================+======================+===========+========+ 11 | | RETAIL1 | DR_RETAIL_PEAK | PEAK | 10 | 12 | +-----------------+----------------------+-----------+--------+ 13 | | RETAIL1 | DR_FREESWITCH_USERS | ALWAYS | 10 | 14 | +-----------------+----------------------+-----------+--------+ 15 | 16 | 17 | **Fields** 18 | 19 | Index 0 - *Tag* 20 | Free-text field used to reference the entry from other files. 21 | 22 | Index 1 - *DestinationRatesTag* 23 | References profile in DestinationRates.csv_. 24 | 25 | Index 2 - *TimingTag* 26 | References profile defined in Timings.csv_. 27 | 28 | Index 3 - *Weight* 29 | Solves possible conflicts between different DestinationRateTimings profiles matching on same interval. 30 | Higher *Weight* has higher priority. 31 | 32 | 33 | .. _DestinationRates.csv: csv_tpdestinationrates.html 34 | .. _Timings.csv: csv_tptimings.html 35 | 36 | -------------------------------------------------------------------------------- /console/console_old/account_trigger_remove.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/apier/v1" 4 | 5 | func init() { 6 | c := &CmdAccountRemoveTriggers{ 7 | name: "account_triggers_remove", 8 | rpcMethod: "ApiV1.RemoveAccountActionTriggers", 9 | rpcParams: &v1.AttrRemoveAccountActionTriggers{}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdAccountRemoveTriggers struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *v1.AttrRemoveAccountActionTriggers 20 | *CommandExecuter 21 | } 22 | 23 | func (self *CmdAccountRemoveTriggers) Name() string { 24 | return self.name 25 | } 26 | 27 | func (self *CmdAccountRemoveTriggers) RpcMethod() string { 28 | return self.rpcMethod 29 | } 30 | 31 | func (self *CmdAccountRemoveTriggers) RpcParams(reset bool) interface{} { 32 | if reset || self.rpcParams == nil { 33 | self.rpcParams = &v1.AttrRemoveAccountActionTriggers{} 34 | } 35 | return self.rpcParams 36 | } 37 | 38 | func (self *CmdAccountRemoveTriggers) PostprocessRpcParams() error { 39 | return nil 40 | } 41 | 42 | func (self *CmdAccountRemoveTriggers) RpcResult() interface{} { 43 | var s string 44 | return &s 45 | } 46 | -------------------------------------------------------------------------------- /data/conf/samples/osips_training/cgrates.json: -------------------------------------------------------------------------------- 1 | { 2 | // This file contains the default configuration hardcoded into AccuRate. 3 | // This is what you get when you load AccuRate with an empty configuration file. 4 | 5 | "listen": { 6 | "rpc_json": ":2012", // RPC JSON listening address 7 | "rpc_gob": ":2013", // RPC GOB listening address 8 | "http": ":2080", // HTTP listening address 9 | }, 10 | 11 | 12 | "rals": { 13 | "enabled": true, 14 | }, 15 | 16 | 17 | "scheduler": { 18 | "enabled": true, 19 | }, 20 | 21 | 22 | "cdrs": { 23 | "enabled": true, // start the CDR Server service: 24 | "cdrstats_conns": [ 25 | {"address": "*internal"} 26 | ], 27 | }, 28 | 29 | 30 | "cdrstats": { 31 | "enabled": true, // starts the cdrstats service: 32 | }, 33 | 34 | "sm_opensips": { 35 | "enabled": true, // starts SessionManager service: 36 | "listen_udp": ":2020", // address where to listen for datagram events coming from OpenSIPS 37 | "create_cdr": true, // create CDR out of events and sends them to CDRS component 38 | "debit_interval": "5s", // interval to perform debits on. 39 | "mi_addr": "192.168.56.128:8020", // address where to reach OpenSIPS MI to send session disconnects 40 | }, 41 | 42 | } 43 | -------------------------------------------------------------------------------- /data/tariffplans/tutorial/ActionTriggers.csv: -------------------------------------------------------------------------------- 1 | #Tag[0],UniqueId[1],ThresholdType[2],ThresholdValue[3],Recurrent[4],MinSleep[5],ExpiryTime[6],ActivationTime[7],BalanceTag[8],BalanceType[9],BalanceDirections[10],BalanceCategories[11],BalanceDestinationIds[12],BalanceRatingSubject[13],BalanceSharedGroup[14],BalanceExpiryTime[15],BalanceTimingIds[16],BalanceWeight[17],BalanceBlocker[18],BalanceDisabled[19],StatsMinQueuedItems[20],ActionsId[21],Weight[22] 2 | STANDARD_TRIGGERS,,*min_balance,2,false,0,,,,*monetary,*out,,,,,,,,,,,LOG_WARNING,10 3 | STANDARD_TRIGGERS,,*max_event_counter,5,false,0,,,,*monetary,*out,,FS_USERS,,,,,,,,,LOG_WARNING,10 4 | STANDARD_TRIGGERS,,*max_balance,20,false,0,,,,*monetary,*out,,,,,,,,,,,LOG_WARNING,10 5 | STANDARD_TRIGGERS,,*max_balance,100,false,0,,,,*monetary,*out,,,,,,,,,,,DISABLE_AND_LOG,10 6 | CDRST1_WARN,,*min_asr,45,true,1m,,,,,,,,,,,,,,,3,LOG_WARNING,10 7 | CDRST1_WARN,,*min_acd,10,true,1m,,,,,,,,,,,,,,,5,LOG_WARNING,10 8 | CDRST1_WARN,,*max_acc,10,true,1m,,,,,,,,,,,,,,,5,LOG_WARNING,10 9 | CDRST1001_WARN,,*min_asr,65,true,1m,,,,,,,,,,,,,,,3,LOG_WARNING,10 10 | CDRST1001_WARN,,*min_acd,10,true,1m,,,,,,,,,,,,,,,5,LOG_WARNING,10 11 | CDRST1001_WARN,,*max_acc,5,true,1m,,,,,,,,,,,,,,,5,LOG_WARNING,10 12 | CDRST3_WARN,,*min_acd,60,false,1m,,,,,,,,,,,,,,,5,LOG_WARNING,10 13 | -------------------------------------------------------------------------------- /utils/slice_test.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "sort" 5 | "testing" 6 | 7 | "github.com/accurateproject/accurate/dec" 8 | ) 9 | 10 | func TestAvg(t *testing.T) { 11 | values := dec.DecSlice{dec.NewVal(1, 0), dec.NewVal(2, 0), dec.NewVal(3, 0)} 12 | result := Avg(values) 13 | expected := dec.NewVal(2, 0) 14 | if expected.Cmp(result) != 0 { 15 | t.Errorf("Wrong Avg: expected %v got %v", expected, result) 16 | } 17 | } 18 | 19 | func TestAvgEmpty(t *testing.T) { 20 | values := dec.DecSlice{} 21 | result := Avg(values) 22 | expected := dec.New() 23 | if expected.Cmp(result) != 0 { 24 | t.Errorf("Wrong Avg: expected %v got %v", expected, result) 25 | } 26 | } 27 | 28 | // ********************* bench ******************** 29 | 30 | func BenchmarkSearchMap(b *testing.B) { 31 | for i := 0; i < b.N; i++ { 32 | a := StringMap{"some": true, "values": true, "to": true, "search": true, "not": true, "too": true, "many": true} 33 | if a["test"] { 34 | 35 | } 36 | } 37 | } 38 | 39 | func BenchmarkSearchSlice(b *testing.B) { 40 | for i := 0; i < b.N; i++ { 41 | ss := []string{"some", "values", "to", "search", "not", "too", "many"} 42 | s := "test" 43 | sort.Strings(ss) 44 | if i := sort.SearchStrings(ss, s); i < len(ss) && ss[i] == s { 45 | 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "github.com/ChrisTrenkamp/goxpath": { 4 | "revision": "4aad8d0161aae7d17df4755d2c1e86cd1fcaaab6" 5 | }, 6 | "github.com/accurateproject/fsock": { 7 | "branch": "master" 8 | }, 9 | "github.com/accurateproject/kamevapi": { 10 | "branch": "master" 11 | }, 12 | "github.com/accurateproject/rpcclient": { 13 | "branch": "master" 14 | }, 15 | "github.com/cenk/hub": { 16 | "revision": "11382a9960d39b0ecda16fd01c424c11ff765a34" 17 | }, 18 | "github.com/cenk/rpc2": { 19 | "revision": "7ab76d2e88c77ca1a715756036d8264b2886acd2" 20 | }, 21 | "github.com/ericlagergren/decimal": { 22 | "branch": "master" 23 | }, 24 | "github.com/fiorix/go-diameter": { 25 | "branch": "master" 26 | }, 27 | "github.com/mitchellh/mapstructure": { 28 | "branch": "master" 29 | }, 30 | "go.uber.org/zap": { 31 | "branch": "master" 32 | }, 33 | "golang.org/x/net": { 34 | "branch": "master" 35 | }, 36 | "gopkg.in/mgo.v2": { 37 | "branch": "v2" 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /utils/rpc_params.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import "reflect" 4 | 5 | var rpcParamsMap map[string]*RpcParams 6 | 7 | type RpcParams struct { 8 | Object interface{} 9 | InParam interface{} 10 | OutParam interface{} 11 | } 12 | 13 | func init() { 14 | rpcParamsMap = make(map[string]*RpcParams) 15 | } 16 | 17 | func RegisterRpcParams(name string, obj interface{}) { 18 | objType := reflect.TypeOf(obj) 19 | if name == "" { 20 | val := reflect.ValueOf(obj) 21 | name = objType.Name() 22 | if val.Kind() == reflect.Ptr { 23 | name = objType.Elem().Name() 24 | } 25 | } 26 | for i := 0; i < objType.NumMethod(); i++ { 27 | method := objType.Method(i) 28 | methodType := method.Type 29 | if methodType.NumIn() == 3 { // if it has three parameters (one is self and two are rpc params) 30 | out := methodType.In(2) 31 | if out.Kind() == reflect.Ptr { 32 | out = out.Elem() 33 | } 34 | rpcParamsMap[name+"."+method.Name] = &RpcParams{ 35 | Object: obj, 36 | InParam: reflect.New(methodType.In(1)).Interface(), 37 | OutParam: reflect.New(out).Interface(), 38 | } 39 | } 40 | } 41 | } 42 | 43 | func GetRpcParams(method string) (*RpcParams, error) { 44 | x, found := rpcParamsMap[method] 45 | if !found { 46 | return nil, ErrNotFound 47 | } 48 | return x, nil 49 | } 50 | -------------------------------------------------------------------------------- /console/debit.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdDebit{ 7 | name: "debit", 8 | rpcMethod: "Responder.Debit", 9 | clientArgs: []string{"Direction", "Category", "TOR", "Tenant", "Subject", "Account", "Destination", "TimeStart", "TimeEnd", "CallDuration", "FallbackSubject", "DryRun"}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdDebit struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *engine.CallDescriptor 20 | clientArgs []string 21 | *CommandExecuter 22 | } 23 | 24 | func (self *CmdDebit) Name() string { 25 | return self.name 26 | } 27 | 28 | func (self *CmdDebit) RpcMethod() string { 29 | return self.rpcMethod 30 | } 31 | 32 | func (self *CmdDebit) RpcParams(reset bool) interface{} { 33 | if reset || self.rpcParams == nil { 34 | self.rpcParams = &engine.CallDescriptor{Direction: "*out"} 35 | } 36 | return self.rpcParams 37 | } 38 | 39 | func (self *CmdDebit) PostprocessRpcParams() error { 40 | return nil 41 | } 42 | 43 | func (self *CmdDebit) RpcResult() interface{} { 44 | return &engine.CallCost{} 45 | } 46 | 47 | func (self *CmdDebit) ClientArgs() []string { 48 | return self.clientArgs 49 | } 50 | -------------------------------------------------------------------------------- /console/cost.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdGetCost{ 7 | name: "cost", 8 | rpcMethod: "Responder.GetCost", 9 | clientArgs: []string{"Direction", "Category", "TOR", "Tenant", "Subject", "Account", "Destination", "TimeStart", "TimeEnd", "CallDuration", "FallbackSubject"}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdGetCost struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *engine.CallDescriptor 20 | clientArgs []string 21 | *CommandExecuter 22 | } 23 | 24 | func (self *CmdGetCost) Name() string { 25 | return self.name 26 | } 27 | 28 | func (self *CmdGetCost) RpcMethod() string { 29 | return self.rpcMethod 30 | } 31 | 32 | func (self *CmdGetCost) RpcParams(reset bool) interface{} { 33 | if reset || self.rpcParams == nil { 34 | self.rpcParams = &engine.CallDescriptor{Direction: "*out"} 35 | } 36 | return self.rpcParams 37 | } 38 | 39 | func (self *CmdGetCost) PostprocessRpcParams() error { 40 | return nil 41 | } 42 | 43 | func (self *CmdGetCost) RpcResult() interface{} { 44 | return &engine.CallCost{} 45 | } 46 | 47 | func (self *CmdGetCost) ClientArgs() []string { 48 | return self.clientArgs 49 | } 50 | -------------------------------------------------------------------------------- /data/conf/samples/apier/apier.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // 4 | // Used in apier_local_tests 5 | // Starts rater, cdrs and mediator connecting over internal channel 6 | 7 | "listen": { 8 | "rpc_json": ":2012", // RPC JSON listening address 9 | "rpc_gob": ":2013", // RPC GOB listening address 10 | "http": ":2080", // HTTP listening address 11 | }, 12 | 13 | "rals": { 14 | "enabled": true, // enable Rater service: 15 | "aliases_conns": [ 16 | {"address": "*internal"} 17 | ], 18 | }, 19 | 20 | "scheduler": { 21 | "enabled": true, // start Scheduler service: 22 | }, 23 | 24 | "cdrs": { 25 | "enabled": true, // start the CDR Server service: 26 | "rals_conns": [ 27 | {"address": "*internal"} // address where to reach the Rater <""|*internal|127.0.0.1:2013> 28 | ], 29 | }, 30 | 31 | "aliases": { 32 | "enabled": true, // start the CDR Server service: 33 | }, 34 | 35 | "cdre": { 36 | "*default": { 37 | "export_dir": "/tmp/cgrates/cdr/cdrexport/csv", // path where the exported CDRs will be placed 38 | } 39 | }, 40 | 41 | "cdrstats": { 42 | "enabled": true, // starts the cdrstats service: 43 | "save_interval": "0s", // interval to save changed stats into dataDb storage 44 | }, 45 | 46 | } 47 | -------------------------------------------------------------------------------- /utils/slice.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "sort" 5 | "strings" 6 | 7 | "github.com/accurateproject/accurate/dec" 8 | ) 9 | 10 | // Binary string search in slice 11 | func IsSliceMember(ss []string, s string) bool { 12 | sort.Strings(ss) 13 | if i := sort.SearchStrings(ss, s); i < len(ss) && ss[i] == s { 14 | return true 15 | } 16 | return false 17 | } 18 | 19 | func SliceWithoutMember(ss []string, s string) []string { 20 | sort.Strings(ss) 21 | if i := sort.SearchStrings(ss, s); i < len(ss) && ss[i] == s { 22 | ss[i], ss = ss[len(ss)-1], ss[:len(ss)-1] 23 | } 24 | return ss 25 | } 26 | 27 | //Iterates over slice members and returns true if one starts with prefix 28 | func SliceMemberHasPrefix(ss []string, prfx string) bool { 29 | for _, mbr := range ss { 30 | if strings.HasPrefix(mbr, prfx) { 31 | return true 32 | } 33 | } 34 | return false 35 | } 36 | 37 | func Avg(values dec.DecSlice) *dec.Dec { 38 | if len(values) == 0 { 39 | return dec.New() 40 | } 41 | sum := dec.New() 42 | for _, val := range values { 43 | sum.AddS(val) 44 | } 45 | return dec.New().Quo(sum, dec.NewVal(int64(len(values)), 0)) 46 | } 47 | 48 | func AvgNegative(values dec.DecSlice) *dec.Dec { 49 | if len(values) == 0 { 50 | return dec.NewVal(-1, 0) // return -1 if no data 51 | } 52 | return Avg(values) 53 | } 54 | -------------------------------------------------------------------------------- /data/docker/prod/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:latest 2 | MAINTAINER Radu Fericean, radu@fericean.ro 3 | RUN apt-get -y update 4 | 5 | # set mysql password 6 | RUN echo 'mysql-server mysql-server/root_password password accuRate' | debconf-set-selections && echo 'mysql-server mysql-server/root_password_again password accuRate' | debconf-set-selections 7 | 8 | # add freeswitch gpg key 9 | RUN gpg --keyserver pool.sks-keyservers.net --recv-key D76EDC7725E010CF && gpg -a --export D76EDC7725E010CF | apt-key add - 10 | 11 | # add freeswitch apt repo 12 | RUN echo 'deb http://files.freeswitch.org/repo/deb/debian/ jessie main' > /etc/apt/sources.list.d/freeswitch.list 13 | 14 | # install dependencies 15 | RUN apt-get update && apt-get -y install redis-server mysql-server python-pycurl python-mysqldb postgresql postgresql-client sudo wget git freeswitch-meta-vanilla 16 | 17 | # add accurate apt-key 18 | RUN wget -qO- http://apt.itsyscom.com/conf/accurate.gpg.key | apt-key add - 19 | 20 | # add accurate repo 21 | RUN cd /etc/apt/sources.list.d/; wget -q http://apt.itsyscom.com/conf/accurate.apt.list 22 | 23 | # install accurate 24 | RUN apt-get update && apt-get -y install accurate 25 | 26 | # cleanup 27 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 28 | 29 | # set start command 30 | CMD /root/code/data/docker/prod/start.sh 31 | -------------------------------------------------------------------------------- /engine/handler_derivedcharging.go: -------------------------------------------------------------------------------- 1 | package engine 2 | 3 | import "github.com/accurateproject/accurate/utils" 4 | 5 | // Handles retrieving of DerivedChargers profile based on longest match from AccountingDb 6 | func HandleGetDerivedChargers(ratingStorage RatingStorage, attrs *utils.AttrDerivedChargers) (*utils.DerivedChargerGroup, error) { 7 | result := &utils.DerivedChargerGroup{} 8 | if dcsDb, err := ratingStorage.GetDerivedChargers(attrs.Direction, attrs.Tenant, attrs.Category, attrs.Account, attrs.Subject, utils.CACHED); err != nil && err != utils.ErrNotFound { 9 | return nil, err 10 | } else if dcsDb != nil { 11 | for _, dcs := range dcsDb { 12 | if DerivedChargersMatchesDest(dcs, attrs.Destination) { 13 | result = dcs 14 | break 15 | } 16 | } 17 | } 18 | return result, nil 19 | } 20 | 21 | func DerivedChargersMatchesDest(dcs *utils.DerivedChargerGroup, dest string) bool { 22 | if len(dcs.DestinationIDs) == 0 || dcs.DestinationIDs[utils.ANY] { 23 | return true 24 | } 25 | // check destination ids 26 | if dests, err := ratingStorage.GetDestinations(dcs.Tenant, dest, "", utils.DestMatching, utils.CACHED); err == nil { 27 | for _, dest := range dests { 28 | includeDest, found := dcs.DestinationIDs[dest.Name] 29 | if found { 30 | return includeDest 31 | } 32 | } 33 | } 34 | return false 35 | } 36 | -------------------------------------------------------------------------------- /console/debit_max.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import "github.com/accurateproject/accurate/engine" 4 | 5 | func init() { 6 | c := &CmdMaxDebit{ 7 | name: "debit_max", 8 | rpcMethod: "Responder.MaxDebit", 9 | clientArgs: []string{"Direction", "Category", "TOR", "Tenant", "Subject", "Account", "Destination", "TimeStart", "TimeEnd", "CallDuration", "FallbackSubject"}, 10 | } 11 | commands[c.Name()] = c 12 | c.CommandExecuter = &CommandExecuter{c} 13 | } 14 | 15 | // Commander implementation 16 | type CmdMaxDebit struct { 17 | name string 18 | rpcMethod string 19 | rpcParams *engine.CallDescriptor 20 | clientArgs []string 21 | *CommandExecuter 22 | } 23 | 24 | func (self *CmdMaxDebit) Name() string { 25 | return self.name 26 | } 27 | 28 | func (self *CmdMaxDebit) RpcMethod() string { 29 | return self.rpcMethod 30 | } 31 | 32 | func (self *CmdMaxDebit) RpcParams(reset bool) interface{} { 33 | if reset || self.rpcParams == nil { 34 | self.rpcParams = &engine.CallDescriptor{Direction: "*out"} 35 | } 36 | return self.rpcParams 37 | } 38 | 39 | func (self *CmdMaxDebit) PostprocessRpcParams() error { 40 | return nil 41 | } 42 | 43 | func (self *CmdMaxDebit) RpcResult() interface{} { 44 | return &engine.CallCost{} 45 | } 46 | 47 | func (self *CmdMaxDebit) ClientArgs() []string { 48 | return self.clientArgs 49 | } 50 | -------------------------------------------------------------------------------- /api/v1/costs.go: -------------------------------------------------------------------------------- 1 | package v1 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/accurateproject/accurate/engine" 7 | "github.com/accurateproject/accurate/utils" 8 | ) 9 | 10 | type AttrGetDataCost struct { 11 | Direction string 12 | Category string 13 | Tenant, Account, Subject string 14 | StartTime time.Time 15 | Usage int64 // the call duration so far (till TimeEnd) 16 | } 17 | 18 | func (api *ApiV1) GetDataCost(attrs AttrGetDataCost, reply *engine.DataCost) error { 19 | usageAsDuration := time.Duration(attrs.Usage) * time.Second // Convert to seconds to match the loaded rates 20 | cd := &engine.CallDescriptor{ 21 | Direction: attrs.Direction, 22 | Category: attrs.Category, 23 | Tenant: attrs.Tenant, 24 | Account: attrs.Account, 25 | Subject: attrs.Subject, 26 | TimeStart: attrs.StartTime, 27 | TimeEnd: attrs.StartTime.Add(usageAsDuration), 28 | DurationIndex: usageAsDuration, 29 | TOR: utils.DATA, 30 | } 31 | var cc engine.CallCost 32 | if err := api.responder.GetCost(cd, &cc); err != nil { 33 | return utils.NewErrServerError(err) 34 | } 35 | if dc, err := cc.ToDataCost(); err != nil { 36 | return utils.NewErrServerError(err) 37 | } else if dc != nil { 38 | *reply = *dc 39 | } 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /data/conf/samples/multifiles/c.json: -------------------------------------------------------------------------------- 1 | { 2 | // AccuRate Configuration file 3 | // Used in multifile configuration tests 4 | // Should be the third file loaded 5 | 6 | "cdre": { 7 | "export1": { 8 | "cost_rounding_decimals": 3, // rounding decimals for Cost values. -1 to disable rounding 9 | "content_fields": [ // template of the exported content fields 10 | {"tag":"Tenant", "cdr_field_id": "tenant", "type": "cdrfield", "value": "tenant"}, 11 | {"tag":"Category", "cdr_field_id": "category", "type": "cdrfield", "value": "category"}, 12 | {"tag":"Account", "cdr_field_id": "account", "type": "cdrfield", "value": "account"}, 13 | {"tag":"Subject", "cdr_field_id": "subject", "type": "cdrfield", "value": "subject"}, 14 | {"tag":"Destination", "cdr_field_id": "destination", "type": "cdrfield", "value": "destination"}, 15 | {"tag":"SetupTime", "cdr_field_id": "setup_time", "type": "cdrfield", "value": "setup_time", "layout": "2006-01-02T15:04:05Z07:00"}, 16 | {"tag":"AnswerTime", "cdr_field_id": "answer_time", "type": "cdrfield", "value": "answer_time", "layout": "2006-01-02T15:04:05Z07:00"}, 17 | {"tag":"Usage", "cdr_field_id": "usage", "type": "cdrfield", "value": "usage"}, 18 | {"tag":"Cost", "cdr_field_id": "cost", "type": "cdrfield", "value": "cost"}, 19 | ], // template of the exported header fields 20 | } 21 | }, 22 | 23 | } --------------------------------------------------------------------------------