Skip to content

Commit fba85b9

Browse files
committed
added wsserver flag to call-api-client tool
1 parent a6b09cc commit fba85b9

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

cmd/call-api-client/main.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,20 @@ import (
2626
"os/signal"
2727
"time"
2828

29+
"github.com/OpenSIPS/call-api/internal/jsonrpc"
30+
"github.com/OpenSIPS/call-api/pkg/config"
2931
"github.com/gorilla/websocket"
3032
"github.com/sirupsen/logrus"
31-
"github.com/OpenSIPS/call-api/pkg/config"
32-
"github.com/OpenSIPS/call-api/internal/jsonrpc"
3333
)
3434

3535
func usage(prog string) {
3636
logrus.Fatalf("Usage: %s jsonrpc_method [jsonrpc_arguments]", prog)
3737
}
3838

39-
func ParseClientArgs() (string, string, interface{}, string) {
40-
var method, params, id string
39+
func ParseClientArgs() (string, string, string, interface{}, string) {
40+
var wsServer, method, params, id string
4141

42+
flag.StringVar(&wsServer, "wsserver", "localhost", "The API host to connect to")
4243
flag.StringVar(&method, "method", "", "JSON-RPC method")
4344
flag.StringVar(&params, "params", "", "JSON-RPC params")
4445
flag.StringVar(&id, "id", "", "JSON-RPC id")
@@ -62,7 +63,7 @@ func ParseClientArgs() (string, string, interface{}, string) {
6263
}
6364
}
6465

65-
return cfgPath, method, v, id
66+
return wsServer, cfgPath, method, v, id
6667
}
6768

6869
func closeWSConnection(c *websocket.Conn) {
@@ -79,7 +80,7 @@ func closeWSConnection(c *websocket.Conn) {
7980

8081
func main() {
8182
// parse cmdline args
82-
cfgPath, method, params, id := ParseClientArgs()
83+
wsServer, cfgPath, method, params, id := ParseClientArgs()
8384

8485
// read configuration
8586
cfg, err := config.NewConfig(cfgPath)
@@ -99,7 +100,7 @@ func main() {
99100
interrupt := make(chan os.Signal, 1)
100101
signal.Notify(interrupt, os.Interrupt)
101102

102-
api_hostport := fmt.Sprintf("%s:%d", cfg.WSServer.Host, cfg.WSServer.Port)
103+
api_hostport := fmt.Sprintf("%s:%d", wsServer, cfg.WSServer.Port)
103104
u := url.URL{Scheme: "ws", Host: api_hostport, Path: cfg.WSServer.Path}
104105
logrus.Printf("connecting to %s", u.String())
105106

0 commit comments

Comments
 (0)