Skip to content

Commit

Permalink
Allow custom ctrl address
Browse files Browse the repository at this point in the history
  • Loading branch information
negbie committed Jul 15, 2021
1 parent 8cd3f03 commit 6427a0d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import (
//go:embed zip/sounds.tar.gz
var baresipSounds []byte

func createConfig(maxCalls uint, rtpNet, rtpPorts string, rtpTimeout uint, sipAddr string) {
func createConfig(maxCalls uint, rtpNet, rtpPorts string, rtpTimeout uint, ctrlAddr, sipAddr string) {
ctrlAddrNorm := strings.Replace(ctrlAddr, "localhost", "127.0.0.1", 1)
config = strings.Replace(config, "127.0.0.1:4444", ctrlAddrNorm, 1)

if sipAddr != "" {
config = strings.Replace(
config,
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ go 1.16

require (
github.com/coocood/freecache v1.1.1
github.com/negbie/go-baresip v0.1.0
github.com/goccy/go-json v0.7.4 // indirect
github.com/negbie/go-baresip v0.1.1
)
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/coocood/freecache v1.1.1 h1:uukNF7QKCZEdZ9gAV7WQzvh0SbjwdMF6m3x3rxEkaPc=
github.com/coocood/freecache v1.1.1/go.mod h1:OKrEjkGVoxZhyWAJoeFi5BMLUJm2Tit0kpGkIr7NGYY=
github.com/goccy/go-json v0.6.1 h1:O7xC9WR7B09imThbRIEMIWK4MVcxOsLzWtGe16cv5SU=
github.com/goccy/go-json v0.6.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.7.4 h1:B44qRUFwz/vxPKPISQ1KhvzRi9kZ28RAf6YtjriBZ5k=
github.com/goccy/go-json v0.7.4/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/negbie/go-baresip v0.1.0 h1:e0xuvvRmgZGqimZMIqGp5hZyp6LQeWfud9d2JW/wbs4=
github.com/negbie/go-baresip v0.1.0/go.mod h1:rZ1+ZBEwbYxNOsm4KHZSnutgWMcA1qtpj9TBcSyOzPo=
github.com/negbie/go-baresip v0.1.1 h1:OS3oGmkdKLc6G0fMf5U6Ck2yYRk1gw0vQTFxVb1GnKU=
github.com/negbie/go-baresip v0.1.1/go.mod h1:rZ1+ZBEwbYxNOsm4KHZSnutgWMcA1qtpj9TBcSyOzPo=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
gobaresip "github.com/negbie/go-baresip"
)

const v = "v0.1.0"
const v = "v0.1.1"

func main() {
debug := flag.Bool("debug", false, "Set debug mode")
ctrlAddr := flag.String("ctrl_address", "127.0.0.1:4444", "Local control listen address")
guiAddr := flag.String("gui_address", "0.0.0.0:8080", "Local GUI listen address")
logStd := flag.Bool("log_stderr", true, "Log to stderr")
lokiURL := flag.String("loki_url", "", "URL to remote Loki server like http://localhost:3100")
Expand All @@ -32,7 +33,7 @@ func main() {
os.Exit(0)
}

createConfig(*maxCalls, *rtpNet, *rtpPorts, *rtpTimeout, *sipAddr)
createConfig(*maxCalls, *rtpNet, *rtpPorts, *rtpTimeout, *ctrlAddr, *sipAddr)

if *webhookDelay == 0 {
*webhookDelay = 1
Expand Down Expand Up @@ -64,6 +65,7 @@ func main() {
gobaresip.SetConfigPath("."),
gobaresip.SetDebug(*debug),
gobaresip.SetUserAgent("telefonist"),
gobaresip.SetCtrlTCPAddr(*ctrlAddr),
gobaresip.SetWsAddr(*guiAddr),
)
if err != nil {
Expand Down

0 comments on commit 6427a0d

Please sign in to comment.