mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 08:19:23 +02:00
support host:port in metrics_address (#2042)
This commit is contained in:
parent
4218f49741
commit
c27cd9030d
6 changed files with 91 additions and 25 deletions
|
@ -3,6 +3,7 @@ package config
|
|||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
|
||||
|
@ -39,15 +40,19 @@ func GetEnvoyDNSLookupFamily(value string) envoy_config_cluster_v3.Cluster_DnsLo
|
|||
return envoy_config_cluster_v3.Cluster_AUTO
|
||||
}
|
||||
|
||||
// ValidateListenerAddress validates that a listener address is ip:port, not host:port.
|
||||
func ValidateListenerAddress(addr string) error {
|
||||
host, _, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid address, expected host:port")
|
||||
// ValidateMetricsAddress validates address for the metrics
|
||||
func ValidateMetricsAddress(addr string) error {
|
||||
_, port, err := net.SplitHostPort(addr)
|
||||
if err != nil || port == "" {
|
||||
return fmt.Errorf("expected host:port")
|
||||
}
|
||||
|
||||
if host != "" && net.ParseIP(host) == nil {
|
||||
return fmt.Errorf("invalid address, expected ip for host")
|
||||
p, err := strconv.Atoi(port)
|
||||
if err != nil {
|
||||
return fmt.Errorf("port must be a number")
|
||||
}
|
||||
if p <= 0 {
|
||||
return fmt.Errorf("expected positive port number")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue