mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Merge branch 'master' of https://github.com/cgrates/cgrates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
language: go
|
||||
|
||||
before_install: sudo apt-get -q install bzr
|
||||
script: $TRAVIS_BUILD_DIR/test.sh
|
||||
|
||||
branches:
|
||||
only: master
|
||||
@@ -15,5 +15,3 @@ notifications:
|
||||
on_success: change
|
||||
on_failure: always
|
||||
|
||||
after_script:
|
||||
./build.sh && ./test.sh
|
||||
|
||||
@@ -22,4 +22,4 @@ API reference http://gopkgdoc.appspot.com/pkg/github.com/cgrates/cgrates
|
||||
|
||||
Also check irc.freenode.net#cgrates and [Google group](https://groups.google.com/forum/#!forum/cgrates) for a more real-time support.
|
||||
|
||||
Continous integration: [](http://goci.me/project/github.com/cgrates/cgrates) [](http://travis-ci.org/cgrates/cgrates)
|
||||
[](https://drone.io/github.com/cgrates/cgrates/latest) [](http://travis-ci.org/cgrates/cgrates)
|
||||
30
cdrs/cdrs.go
30
cdrs/cdrs.go
@@ -20,40 +20,42 @@ package cdrs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/mediator"
|
||||
"github.com/cgrates/cgrates/rater"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
Logger = rater.Logger
|
||||
cfg *config.CGRConfig // Share the configuration with the rest of the package
|
||||
Logger = rater.Logger
|
||||
cfg *config.CGRConfig // Share the configuration with the rest of the package
|
||||
storage rater.DataStorage
|
||||
medi *mediator.Mediator
|
||||
)
|
||||
|
||||
type CDRS struct {
|
||||
loggerDb rater.DataStorage
|
||||
medi *mediator.Mediator
|
||||
}
|
||||
|
||||
func (cdrs *CDRS) cdrHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func cdrHandler(w http.ResponseWriter, r *http.Request) {
|
||||
body, _ := ioutil.ReadAll(r.Body)
|
||||
if fsCdr, err := new(FSCdr).New(body); err == nil {
|
||||
cdrs.loggerDb.SetCdr(fsCdr)
|
||||
cdrs.medi.MediateCdrFromDB(fsCdr.GetAccount(), cdrs.loggerDb)
|
||||
storage.SetCdr(fsCdr)
|
||||
medi.MediateCdrFromDB(fsCdr.GetAccount(), storage)
|
||||
} else {
|
||||
Logger.Err(fmt.Sprintf("Could not create CDR entry: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
func New(storage rater.DataStorage, mediator *mediator.Mediator) *CDRS {
|
||||
return &CDRS{storage, mediator}
|
||||
type CDRS struct{}
|
||||
|
||||
func New(s rater.DataStorage, m *mediator.Mediator, c *config.CGRConfig) *CDRS {
|
||||
storage = s
|
||||
medi = m
|
||||
cfg = c
|
||||
return &CDRS{}
|
||||
}
|
||||
|
||||
func (cdrs *CDRS) StartCapturingCDRs() {
|
||||
if cfg.CDRSfsJSONEnabled {
|
||||
http.HandleFunc("/freeswitch_json", cdrs.cdrHandler)
|
||||
http.HandleFunc("/freeswitch_json", cdrHandler)
|
||||
}
|
||||
http.ListenAndServe(cfg.CDRSListen, nil)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
const (
|
||||
// Freswitch event property names
|
||||
CDR_MAP = "variables"
|
||||
@@ -43,9 +42,8 @@ const (
|
||||
PARK_TIME = "start_stamp"
|
||||
START_TIME = "answer_stamp"
|
||||
END_TIME = "end_stamp"
|
||||
NAME = "unused"
|
||||
USERNAME = "user_name"
|
||||
FS_IP = "sip_local_network_addr"
|
||||
FS_IP = "sip_local_network_addr"
|
||||
)
|
||||
|
||||
type FSCdr map[string]string
|
||||
@@ -67,9 +65,6 @@ func (fsCdr FSCdr) New(body []byte) (rater.CDR, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (fsCdr FSCdr) GetName() string {
|
||||
return fsCdr[NAME]
|
||||
}
|
||||
func (fsCdr FSCdr) GetDirection() string {
|
||||
//TODO: implement direction
|
||||
return "OUT"
|
||||
|
||||
@@ -320,7 +320,7 @@ func main() {
|
||||
|
||||
if cfg.CDRSListen!="" {
|
||||
rater.Logger.Info("Starting CGRateS CDR Server.")
|
||||
cs := cdrs.New(loggerDb, medi)
|
||||
cs := cdrs.New(loggerDb, medi, cfg)
|
||||
go cs.StartCapturingCDRs()
|
||||
}
|
||||
<-exitChan
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
|
||||
type CDR interface {
|
||||
New([]byte) (CDR, error)
|
||||
GetName() string
|
||||
GetDirection() string
|
||||
GetOrigId() string
|
||||
GetSubject() string
|
||||
|
||||
Reference in New Issue
Block a user