diff --git a/dnscrypt-proxy/common.go b/dnscrypt-proxy/common.go index fa822ff4..1a80a3c0 100644 --- a/dnscrypt-proxy/common.go +++ b/dnscrypt-proxy/common.go @@ -135,7 +135,7 @@ func ExtractPort(str string, defaultPort int) int { return port } -func StripPort(str string) string { +func ExtractHost(str string) string { if idx := strings.LastIndex(str, ":"); idx >= 0 && idx < len(str)-1 { if _, err := strconv.Atoi(str[idx+1:]); err == nil { str = str[:idx] diff --git a/dnscrypt-proxy/config.go b/dnscrypt-proxy/config.go index ed07089e..e41dbb09 100644 --- a/dnscrypt-proxy/config.go +++ b/dnscrypt-proxy/config.go @@ -120,14 +120,15 @@ type BlockIPConfig struct { } type ServerSummary struct { - Name string `json:"name"` - Proto string `json:"proto"` - IPv6 bool `json:"ipv6"` - Ports []int `json:"ports"` - DNSSEC bool `json:"dnssec"` - NoLog bool `json:"nolog"` - NoFilter bool `json:"nofilter"` - Description string `json:"description,omitempty"` + Name string `json:"name"` + Proto string `json:"proto"` + IPv6 bool `json:"ipv6"` + Addrs []string `json:"addrs,omitempty"` + Ports []int `json:"ports"` + DNSSEC bool `json:"dnssec"` + NoLog bool `json:"nolog"` + NoFilter bool `json:"nofilter"` + Description string `json:"description,omitempty"` } func ConfigLoad(proxy *Proxy, svcFlag *string) error { @@ -311,15 +312,22 @@ func (config *Config) printRegisteredServers(proxy *Proxy, jsonOutput bool) { for _, registeredServer := range proxy.registeredServers { addrStr, port := registeredServer.stamp.serverAddrStr, DefaultPort port = ExtractPort(addrStr, port) + addrs := make([]string, 0) if registeredServer.stamp.proto == StampProtoTypeDoH && len(registeredServer.stamp.providerName) > 0 { providerName := registeredServer.stamp.providerName - port = ExtractPort(providerName, port) + var host string + host, port = ExtractHostAndPort(providerName, port) + addrs = append(addrs, host) + } + if len(addrStr) > 0 { + addrs = append(addrs, ExtractHost(addrStr)) } serverSummary := ServerSummary{ Name: registeredServer.name, Proto: registeredServer.stamp.proto.String(), IPv6: strings.HasPrefix(addrStr, "["), Ports: []int{port}, + Addrs: addrs, DNSSEC: registeredServer.stamp.props&ServerInformalPropertyDNSSEC != 0, NoLog: registeredServer.stamp.props&ServerInformalPropertyNoLog != 0, NoFilter: registeredServer.stamp.props&ServerInformalPropertyNoFilter != 0,