mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Merge pull request #333 from wallyqs/custom-monitoring-server-listen
Enables using the same listen from server for monitoring endpoint via `-a`
This commit is contained in:
@@ -758,6 +758,10 @@ func processOptions(opts *Options) {
|
||||
if opts.Host == "" {
|
||||
opts.Host = DEFAULT_HOST
|
||||
}
|
||||
if opts.HTTPHost == "" {
|
||||
// Default to same bind from server if left undefined
|
||||
opts.HTTPHost = opts.Host
|
||||
}
|
||||
if opts.Port == 0 {
|
||||
opts.Port = DEFAULT_PORT
|
||||
} else if opts.Port == RANDOM_PORT {
|
||||
|
||||
@@ -15,6 +15,7 @@ func TestDefaultOptions(t *testing.T) {
|
||||
Host: DEFAULT_HOST,
|
||||
Port: DEFAULT_PORT,
|
||||
MaxConn: DEFAULT_MAX_CONNECTIONS,
|
||||
HTTPHost: DEFAULT_HOST,
|
||||
PingInterval: DEFAULT_PING_INTERVAL,
|
||||
MaxPingsOut: DEFAULT_PING_MAX_OUT,
|
||||
TLSTimeout: float64(TLS_TIMEOUT) / float64(time.Second),
|
||||
@@ -360,10 +361,13 @@ func TestListenConfig(t *testing.T) {
|
||||
// Normal clients
|
||||
host := "10.0.1.22"
|
||||
port := 4422
|
||||
|
||||
monHost := "127.0.0.1"
|
||||
if opts.Host != host {
|
||||
t.Fatalf("Received incorrect host %q, expected %q\n", opts.Host, host)
|
||||
}
|
||||
if opts.HTTPHost != monHost {
|
||||
t.Fatalf("Received incorrect host %q, expected %q\n", opts.HTTPHost, monHost)
|
||||
}
|
||||
if opts.Port != port {
|
||||
t.Fatalf("Received incorrect port %v, expected %v\n", opts.Port, port)
|
||||
}
|
||||
@@ -409,6 +413,9 @@ func TestListenPortOnlyConfig(t *testing.T) {
|
||||
if opts.Host != DEFAULT_HOST {
|
||||
t.Fatalf("Received incorrect host %q, expected %q\n", opts.Host, DEFAULT_HOST)
|
||||
}
|
||||
if opts.HTTPHost != DEFAULT_HOST {
|
||||
t.Fatalf("Received incorrect host %q, expected %q\n", opts.Host, DEFAULT_HOST)
|
||||
}
|
||||
if opts.Port != port {
|
||||
t.Fatalf("Received incorrect port %v, expected %v\n", opts.Port, port)
|
||||
}
|
||||
@@ -426,11 +433,32 @@ func TestListenPortWithColonConfig(t *testing.T) {
|
||||
if opts.Host != DEFAULT_HOST {
|
||||
t.Fatalf("Received incorrect host %q, expected %q\n", opts.Host, DEFAULT_HOST)
|
||||
}
|
||||
if opts.HTTPHost != DEFAULT_HOST {
|
||||
t.Fatalf("Received incorrect host %q, expected %q\n", opts.Host, DEFAULT_HOST)
|
||||
}
|
||||
if opts.Port != port {
|
||||
t.Fatalf("Received incorrect port %v, expected %v\n", opts.Port, port)
|
||||
}
|
||||
}
|
||||
|
||||
func TestListenMonitoringDefault(t *testing.T) {
|
||||
opts := &Options{
|
||||
Host: "10.0.1.22",
|
||||
}
|
||||
processOptions(opts)
|
||||
|
||||
host := "10.0.1.22"
|
||||
if opts.Host != host {
|
||||
t.Fatalf("Received incorrect host %q, expected %q\n", opts.Host, host)
|
||||
}
|
||||
if opts.HTTPHost != host {
|
||||
t.Fatalf("Received incorrect host %q, expected %q\n", opts.Host, host)
|
||||
}
|
||||
if opts.Port != DEFAULT_PORT {
|
||||
t.Fatalf("Received incorrect port %v, expected %v\n", opts.Port, DEFAULT_PORT)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMultipleUsersConfig(t *testing.T) {
|
||||
opts, err := ProcessConfigFile("./configs/multiple_users.conf")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user