🩹 Fix: corrects ipv6 loopback ip shown on UI (#1517)

Author:    Rupesh Harode <rupeshharode@gmail.com>

Co-authored-by: Rupesh Harode <rupesh.harode@dailyrounds.org>
This commit is contained in:
Rupesh Harode 2021-09-03 17:53:03 +05:30 committed by GitHub
parent 12c1bf91bc
commit 9dd39c0e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

7
app.go
View File

@ -954,9 +954,14 @@ func (app *App) startupMessage(addr string, tls bool, pids string) {
host, port := parseAddr(addr) host, port := parseAddr(addr)
if host == "" { if host == "" {
host = "0.0.0.0" if app.config.Network == NetworkTCP6 {
host = "[::1]"
} else {
host = "0.0.0.0"
}
} }
scheme := "http" scheme := "http"
if tls { if tls {
scheme = "https" scheme = "https"

View File

@ -194,7 +194,7 @@ func Test_Utils_Parse_Address(t *testing.T) {
testCases := []struct { testCases := []struct {
addr, host, port string addr, host, port string
}{ }{
{"[::]:3000", "[::]", "3000"}, {"[::1]:3000", "[::1]", "3000"},
{"127.0.0.1:3000", "127.0.0.1", "3000"}, {"127.0.0.1:3000", "127.0.0.1", "3000"},
{"/path/to/unix/socket", "/path/to/unix/socket", ""}, {"/path/to/unix/socket", "/path/to/unix/socket", ""},
} }

View File

@ -31,7 +31,7 @@ func Test_App_Prefork_Child_Process(t *testing.T) {
utils.AssertEqual(t, nil, app.Shutdown()) utils.AssertEqual(t, nil, app.Shutdown())
}() }()
utils.AssertEqual(t, nil, app.prefork(NetworkTCP6, "[::]:", nil)) utils.AssertEqual(t, nil, app.prefork(NetworkTCP6, "[::1]:", nil))
// Create tls certificate // Create tls certificate
cer, err := tls.LoadX509KeyPair("./.github/testdata/ssl.pem", "./.github/testdata/ssl.key") cer, err := tls.LoadX509KeyPair("./.github/testdata/ssl.pem", "./.github/testdata/ssl.key")