mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-05-04 06:52:54 +03:00
Pull request: 3172 fix mobileconfig
Merge in DNS/adguard-home from 3172-mobileconfig to master
Updates #3172.
Updates #2497.
Squashed commit of the following:
commit 30549ef4eda9d88f0738089e901492d7369caa25
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Tue Jun 1 21:00:17 2021 +0300
all: log changes
commit 9b9429447430a8e5656b992c04c4a74606dc5f9f
Author: Ildar Kamalov <ik@adguard.com>
Date: Tue Jun 1 17:56:59 2021 +0300
client: always show port input
commit 6d6a0bdfaa849220a5ddb4a17502ab05379d7a1c
Merge: 13a3bffd 77946a7f
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Tue Jun 1 17:50:41 2021 +0300
Merge branch 'master' into 3172-mobileconfig
commit 13a3bffd4dd6ccabf3d261f17b2c758a5c61eb9c
Author: Ildar Kamalov <ik@adguard.com>
Date: Tue Jun 1 17:20:17 2021 +0300
client: add port to mobile config form
commit f6abe0b6044572f3801c31b683e76f90c4a28487
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Mon May 31 19:43:37 2021 +0300
home: imp cyclo
commit c304a0bacdca6f8b5ffd21f3d00c8244ea9e4e36
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Mon May 31 18:19:46 2021 +0300
home: reduce allocs
commit 10a7678861079b710bb0ef14569c60a09612ec70
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Mon May 24 20:05:08 2021 +0300
all: make the host parameter required
This commit is contained in:
parent
77946a7f72
commit
3f1fd56b17
17 changed files with 223 additions and 186 deletions
internal/home
|
@ -15,7 +15,6 @@ import (
|
|||
"os/signal"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
@ -630,7 +629,28 @@ func loadOptions() options {
|
|||
return o
|
||||
}
|
||||
|
||||
// printHTTPAddresses prints the IP addresses which user can use to open the
|
||||
// printWebAddrs prints addresses built from proto, addr, and an appropriate
|
||||
// port. At least one address is printed with the value of port. If the value
|
||||
// of betaPort is 0, the second address is not printed. The output example:
|
||||
//
|
||||
// Go to http://127.0.0.1:80
|
||||
// Go to http://127.0.0.1:3000 (BETA)
|
||||
//
|
||||
func printWebAddrs(proto, addr string, port, betaPort int) {
|
||||
const (
|
||||
hostMsg = "Go to %s://%s"
|
||||
hostBetaMsg = hostMsg + " (BETA)"
|
||||
)
|
||||
|
||||
log.Printf(hostMsg, proto, aghnet.JoinHostPort(addr, port))
|
||||
if betaPort == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf(hostBetaMsg, proto, aghnet.JoinHostPort(addr, config.BetaBindPort))
|
||||
}
|
||||
|
||||
// printHTTPAddresses prints the IP addresses which user can use to access the
|
||||
// admin interface. proto is either schemeHTTP or schemeHTTPS.
|
||||
func printHTTPAddresses(proto string) {
|
||||
tlsConf := tlsConfigSettings{}
|
||||
|
@ -638,45 +658,40 @@ func printHTTPAddresses(proto string) {
|
|||
Context.tls.WriteDiskConfig(&tlsConf)
|
||||
}
|
||||
|
||||
port := strconv.Itoa(config.BindPort)
|
||||
port := config.BindPort
|
||||
if proto == schemeHTTPS {
|
||||
port = strconv.Itoa(tlsConf.PortHTTPS)
|
||||
port = tlsConf.PortHTTPS
|
||||
}
|
||||
|
||||
var hostStr string
|
||||
// TODO(e.burkov): Inspect and perhaps merge with the previous
|
||||
// condition.
|
||||
if proto == schemeHTTPS && tlsConf.ServerName != "" {
|
||||
if tlsConf.PortHTTPS == 443 {
|
||||
log.Printf("Go to https://%s", tlsConf.ServerName)
|
||||
} else {
|
||||
log.Printf("Go to https://%s:%s", tlsConf.ServerName, port)
|
||||
}
|
||||
} else if config.BindHost.IsUnspecified() {
|
||||
log.Println("AdGuard Home is available on the following addresses:")
|
||||
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
|
||||
if err != nil {
|
||||
// That's weird, but we'll ignore it
|
||||
hostStr = config.BindHost.String()
|
||||
log.Printf("Go to %s://%s", proto, net.JoinHostPort(hostStr, port))
|
||||
if config.BetaBindPort != 0 {
|
||||
log.Printf("Go to %s://%s (BETA)", proto, net.JoinHostPort(hostStr, strconv.Itoa(config.BetaBindPort)))
|
||||
}
|
||||
return
|
||||
}
|
||||
printWebAddrs(proto, tlsConf.ServerName, tlsConf.PortHTTPS, 0)
|
||||
|
||||
for _, iface := range ifaces {
|
||||
for _, addr := range iface.Addresses {
|
||||
hostStr = addr.String()
|
||||
log.Printf("Go to %s://%s", proto, net.JoinHostPort(hostStr, strconv.Itoa(config.BindPort)))
|
||||
if config.BetaBindPort != 0 {
|
||||
log.Printf("Go to %s://%s (BETA)", proto, net.JoinHostPort(hostStr, strconv.Itoa(config.BetaBindPort)))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hostStr = config.BindHost.String()
|
||||
log.Printf("Go to %s://%s", proto, net.JoinHostPort(hostStr, port))
|
||||
if config.BetaBindPort != 0 {
|
||||
log.Printf("Go to %s://%s (BETA)", proto, net.JoinHostPort(hostStr, strconv.Itoa(config.BetaBindPort)))
|
||||
return
|
||||
}
|
||||
|
||||
bindhost := config.BindHost
|
||||
if !bindhost.IsUnspecified() {
|
||||
printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
ifaces, err := aghnet.GetValidNetInterfacesForWeb()
|
||||
if err != nil {
|
||||
log.Error("web: getting iface ips: %s", err)
|
||||
// That's weird, but we'll ignore it.
|
||||
//
|
||||
// TODO(e.burkov): Find out when it happens.
|
||||
printWebAddrs(proto, bindhost.String(), port, config.BetaBindPort)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
for _, iface := range ifaces {
|
||||
for _, addr := range iface.Addresses {
|
||||
printWebAddrs(proto, addr.String(), config.BindPort, config.BetaBindPort)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue