diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-06-21 19:06:17 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-06-21 19:06:17 -0700 |
commit | 42f28ab8e374137fe3f5d25424489d879d4724f8 (patch) | |
tree | 20353f2446b506d32e6d353b72a57bf48f070389 /vendor/github.com/hashicorp/go-sockaddr/template/template.go | |
parent | 6b39c308d882a0aeac533f8ab1d90b48a2ae4b5a (diff) | |
download | chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.gz chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.bz2 chat-42f28ab8e374137fe3f5d25424489d879d4724f8.zip |
Updating server dependancies (#6712)
Diffstat (limited to 'vendor/github.com/hashicorp/go-sockaddr/template/template.go')
-rw-r--r-- | vendor/github.com/hashicorp/go-sockaddr/template/template.go | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/vendor/github.com/hashicorp/go-sockaddr/template/template.go b/vendor/github.com/hashicorp/go-sockaddr/template/template.go index ffe467b7f..bbed51361 100644 --- a/vendor/github.com/hashicorp/go-sockaddr/template/template.go +++ b/vendor/github.com/hashicorp/go-sockaddr/template/template.go @@ -64,23 +64,53 @@ func init() { HelperFuncs = template.FuncMap{ // Misc functions that operate on IfAddrs inputs - "attr": sockaddr.IfAttr, + "attr": Attr, "join": sockaddr.JoinIfAddrs, "limit": sockaddr.LimitIfAddrs, "offset": sockaddr.OffsetIfAddrs, "unique": sockaddr.UniqueIfAddrsBy, + // Misc math functions that operate on a single IfAddr input + "math": sockaddr.IfAddrsMath, + // Return a Private RFC 6890 IP address string that is attached // to the default route and a forwardable address. "GetPrivateIP": sockaddr.GetPrivateIP, + // Return all Private RFC 6890 IP addresses as a space-delimited string of + // IP addresses. Addresses returned do not have to be on the interface with + // a default route. + "GetPrivateIPs": sockaddr.GetPrivateIPs, + // Return a Public RFC 6890 IP address string that is attached // to the default route and a forwardable address. "GetPublicIP": sockaddr.GetPublicIP, + // Return allPublic RFC 6890 IP addresses as a space-delimited string of IP + // addresses. Addresses returned do not have to be on the interface with a + // default route. + "GetPublicIPs": sockaddr.GetPublicIPs, + // Return the first IP address of the named interface, sorted by // the largest network size. "GetInterfaceIP": sockaddr.GetInterfaceIP, + + // Return all IP addresses on the named interface, sorted by the largest + // network size. + "GetInterfaceIPs": sockaddr.GetInterfaceIPs, + } +} + +// Attr returns the attribute from the ifAddrRaw argument. If the argument is +// an IfAddrs, only the first element will be evaluated for resolution. +func Attr(selectorName string, ifAddrsRaw interface{}) (string, error) { + switch v := ifAddrsRaw.(type) { + case sockaddr.IfAddr: + return sockaddr.IfAttr(selectorName, v) + case sockaddr.IfAddrs: + return sockaddr.IfAttrs(selectorName, v) + default: + return "", fmt.Errorf("unable to obtain attribute %s from type %T (%v)", selectorName, ifAddrsRaw, ifAddrsRaw) } } |