mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-01 18:33:19 +02:00
envoyconfig: address strconv.Atoi warnings (#5076)
Replace Atoi() calls with ParseUint(), and update the buildAddress() defaultPort parameter to be a uint32. (A uint16 would arguably make more sense for a port number, but uint32 matches the Envoy proto field.) Delete a ParseAddress() method that appears to be unused.
This commit is contained in:
parent
df67fb7086
commit
a3149363a6
4 changed files with 9 additions and 36 deletions
|
@ -1,13 +1,5 @@
|
|||
package envoy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
|
||||
)
|
||||
|
||||
func firstNonEmpty[T interface{ ~string }](args ...T) T {
|
||||
for _, a := range args {
|
||||
if a != "" {
|
||||
|
@ -16,22 +8,3 @@ func firstNonEmpty[T interface{ ~string }](args ...T) T {
|
|||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ParseAddress parses a string address into an envoy address.
|
||||
func ParseAddress(raw string) (*envoy_config_core_v3.Address, error) {
|
||||
if host, portstr, err := net.SplitHostPort(raw); err == nil {
|
||||
if port, err := strconv.Atoi(portstr); err == nil {
|
||||
return &envoy_config_core_v3.Address{
|
||||
Address: &envoy_config_core_v3.Address_SocketAddress{
|
||||
SocketAddress: &envoy_config_core_v3.SocketAddress{
|
||||
Address: host,
|
||||
PortSpecifier: &envoy_config_core_v3.SocketAddress_PortValue{
|
||||
PortValue: uint32(port),
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("unknown address format: %s", raw)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue