summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/hashicorp
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp')
-rw-r--r--vendor/github.com/hashicorp/go-sockaddr/ifaddr_test.go117
-rw-r--r--vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go75
-rw-r--r--vendor/github.com/hashicorp/go-sockaddr/template/doc.go8
-rw-r--r--vendor/github.com/hashicorp/hcl/.travis.yml3
-rw-r--r--vendor/github.com/hashicorp/hcl/decoder.go31
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go2
-rw-r--r--vendor/github.com/hashicorp/hcl/json/scanner/scanner.go2
-rw-r--r--vendor/github.com/hashicorp/memberlist/memberlist.go12
-rw-r--r--vendor/github.com/hashicorp/memberlist/memberlist_test.go2
-rw-r--r--vendor/github.com/hashicorp/memberlist/suspicion.go2
-rw-r--r--vendor/github.com/hashicorp/memberlist/util.go42
-rw-r--r--vendor/github.com/hashicorp/memberlist/util_test.go41
12 files changed, 279 insertions, 58 deletions
diff --git a/vendor/github.com/hashicorp/go-sockaddr/ifaddr_test.go b/vendor/github.com/hashicorp/go-sockaddr/ifaddr_test.go
index 859c3e421..45a0cc788 100644
--- a/vendor/github.com/hashicorp/go-sockaddr/ifaddr_test.go
+++ b/vendor/github.com/hashicorp/go-sockaddr/ifaddr_test.go
@@ -411,6 +411,114 @@ func TestIfAddrMath(t *testing.T) {
wantFail: true,
},
{
+ name: "ipv4 mask operand equals input ipv4 subnet mask",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv4Addr("10.20.30.40/8"),
+ },
+ operation: "mask",
+ value: "8",
+ expected: "10.0.0.0/8",
+ },
+ {
+ name: "ipv4 mask operand larger than input ipv4 subnet mask",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv4Addr("192.168.10.20/24"),
+ },
+ operation: "mask",
+ value: "16",
+ expected: "192.168.0.0/16",
+ },
+ {
+ name: "ipv4 host upper bound mask operand larger than input ipv4 subnet mask",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv4Addr("192.168.255.255/24"),
+ },
+ operation: "mask",
+ value: "16",
+ expected: "192.168.0.0/16",
+ },
+ {
+ name: "ipv4 mask operand smaller than ipv4 subnet mask",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv4Addr("10.20.30.40/8"),
+ },
+ operation: "mask",
+ value: "16",
+ expected: "10.20.0.0/8",
+ },
+ {
+ name: "ipv4 host upper bound mask operand smaller than input ipv4 subnet mask",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv4Addr("10.20.255.255/8"),
+ },
+ operation: "mask",
+ value: "16",
+ expected: "10.20.0.0/8",
+ },
+ {
+ name: "ipv4 mask bad value upper bound",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv4Addr("127.0.0.1/8"),
+ },
+ operation: "mask",
+ value: "33",
+ wantFail: true,
+ },
+ {
+ name: "ipv4 mask bad value lower bound",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv4Addr("127.0.0.1/8"),
+ },
+ operation: "mask",
+ value: "-1",
+ wantFail: true,
+ },
+ {
+ name: "ipv6 mask operand equals input ipv6 subnet mask",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv6Addr("2001:0db8:85a3::8a2e:0370:7334/64"),
+ },
+ operation: "mask",
+ value: "64",
+ expected: "2001:db8:85a3::/64",
+ },
+ {
+ name: "ipv6 mask operand larger than input ipv6 subnet mask",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv6Addr("2001:0db8:85a3::8a2e:0370:7334/64"),
+ },
+ operation: "mask",
+ value: "32",
+ expected: "2001:db8::/32",
+ },
+ {
+ name: "ipv6 mask operand smaller than input ipv6 subnet mask",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv6Addr("2001:0db8:85a3::8a2e:0370:7334/64"),
+ },
+ operation: "mask",
+ value: "96",
+ expected: "2001:db8:85a3::8a2e:0:0/64",
+ },
+ {
+ name: "ipv6 mask bad value upper bound",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv6Addr("::1/128"),
+ },
+ operation: "mask",
+ value: "129",
+ wantFail: true,
+ },
+ {
+ name: "ipv6 mask bad value lower bound",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustIPv6Addr("::1/128"),
+ },
+ operation: "mask",
+ value: "-1",
+ wantFail: true,
+ },
+ {
name: "unix unsupported operation",
ifAddr: sockaddr.IfAddr{
SockAddr: sockaddr.MustUnixSock("/tmp/bar"),
@@ -428,6 +536,15 @@ func TestIfAddrMath(t *testing.T) {
value: "+123",
wantFail: true,
},
+ {
+ name: "unix unsupported operation",
+ ifAddr: sockaddr.IfAddr{
+ SockAddr: sockaddr.MustUnixSock("/tmp/foo"),
+ },
+ operation: "mask",
+ value: "8",
+ wantFail: true,
+ },
}
for i, test := range tests {
diff --git a/vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go b/vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go
index b87589a22..4b4e63808 100644
--- a/vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go
+++ b/vendor/github.com/hashicorp/go-sockaddr/ifaddrs.go
@@ -1,6 +1,7 @@
package sockaddr
import (
+ "encoding/binary"
"errors"
"fmt"
"math/big"
@@ -866,6 +867,80 @@ func IfAddrMath(operation, value string, inputIfAddr IfAddr) (IfAddr, error) {
default:
return IfAddr{}, fmt.Errorf("unsupported type for operation %q: %T", operation, sockType)
}
+ case "mask":
+ // "mask" operates on the IP address and returns the IP address on
+ // which the given integer mask has been applied. If the applied mask
+ // corresponds to a larger network than the mask of the IP address,
+ // the latter will be replaced by the former.
+ switch sockType := inputIfAddr.SockAddr.Type(); sockType {
+ case TypeIPv4:
+ i, err := strconv.ParseUint(value, 10, 32)
+ if err != nil {
+ return IfAddr{}, fmt.Errorf("unable to convert %q to int for operation %q: %v", value, operation, err)
+ }
+
+ if i > 32 {
+ return IfAddr{}, fmt.Errorf("parameter for operation %q on ipv4 addresses must be between 0 and 32", operation)
+ }
+
+ ipv4 := *ToIPv4Addr(inputIfAddr.SockAddr)
+
+ ipv4Mask := net.CIDRMask(int(i), 32)
+ ipv4MaskUint32 := binary.BigEndian.Uint32(ipv4Mask)
+
+ maskedIpv4 := ipv4.NetIP().Mask(ipv4Mask)
+ maskedIpv4Uint32 := binary.BigEndian.Uint32(maskedIpv4)
+
+ maskedIpv4MaskUint32 := uint32(ipv4.Mask)
+
+ if ipv4MaskUint32 < maskedIpv4MaskUint32 {
+ maskedIpv4MaskUint32 = ipv4MaskUint32
+ }
+
+ return IfAddr{
+ SockAddr: IPv4Addr{
+ Address: IPv4Address(maskedIpv4Uint32),
+ Mask: IPv4Mask(maskedIpv4MaskUint32),
+ },
+ Interface: inputIfAddr.Interface,
+ }, nil
+ case TypeIPv6:
+ i, err := strconv.ParseUint(value, 10, 32)
+ if err != nil {
+ return IfAddr{}, fmt.Errorf("unable to convert %q to int for operation %q: %v", value, operation, err)
+ }
+
+ if i > 128 {
+ return IfAddr{}, fmt.Errorf("parameter for operation %q on ipv6 addresses must be between 0 and 64", operation)
+ }
+
+ ipv6 := *ToIPv6Addr(inputIfAddr.SockAddr)
+
+ ipv6Mask := net.CIDRMask(int(i), 128)
+ ipv6MaskBigInt := new(big.Int)
+ ipv6MaskBigInt.SetBytes(ipv6Mask)
+
+ maskedIpv6 := ipv6.NetIP().Mask(ipv6Mask)
+ maskedIpv6BigInt := new(big.Int)
+ maskedIpv6BigInt.SetBytes(maskedIpv6)
+
+ maskedIpv6MaskBigInt := new(big.Int)
+ maskedIpv6MaskBigInt.Set(ipv6.Mask)
+
+ if ipv6MaskBigInt.Cmp(maskedIpv6MaskBigInt) == -1 {
+ maskedIpv6MaskBigInt = ipv6MaskBigInt
+ }
+
+ return IfAddr{
+ SockAddr: IPv6Addr{
+ Address: IPv6Address(maskedIpv6BigInt),
+ Mask: IPv6Mask(maskedIpv6MaskBigInt),
+ },
+ Interface: inputIfAddr.Interface,
+ }, nil
+ default:
+ return IfAddr{}, fmt.Errorf("unsupported type for operation %q: %T", operation, sockType)
+ }
default:
return IfAddr{}, fmt.Errorf("unsupported math operation: %q", operation)
}
diff --git a/vendor/github.com/hashicorp/go-sockaddr/template/doc.go b/vendor/github.com/hashicorp/go-sockaddr/template/doc.go
index 90c8784a3..8cc6730a4 100644
--- a/vendor/github.com/hashicorp/go-sockaddr/template/doc.go
+++ b/vendor/github.com/hashicorp/go-sockaddr/template/doc.go
@@ -212,6 +212,13 @@ Supported operations include:
from the network's broadcast address (e.g. 127.0.0.1 `"network" "-1"` will
return "127.255.255.255"). Values that overflow the network size will
safely wrap.
+ - `mask`: Applies the given network mask to the address. The network mask is
+ expressed as a decimal value (e.g. network mask "24" corresponds to
+ `255.255.255.0`). After applying the network mask, the network mask of the
+ resulting address will be either the applied network mask or the network mask
+ of the input address depending on which network is larger
+ (e.g. 192.168.10.20/24 `"mask" "16"` will return "192.168.0.0/16" but
+ 192.168.10.20/24 `"mask" "28"` will return "192.168.10.16/24").
Example:
@@ -219,6 +226,7 @@ Example:
{{ GetPrivateInterfaces | include "type" "IP" | math "address" "-256" | attr "address" }}
{{ GetPrivateInterfaces | include "type" "IP" | math "network" "+2" | attr "address" }}
{{ GetPrivateInterfaces | include "type" "IP" | math "network" "-2" | attr "address" }}
+ {{ GetPrivateInterfaces | include "type" "IP" | math "mask" "24" | attr "address" }}
{{ GetPrivateInterfaces | include "flags" "forwardable|up" | include "type" "IPv4" | math "network" "+2" | attr "address" }}
diff --git a/vendor/github.com/hashicorp/hcl/.travis.yml b/vendor/github.com/hashicorp/hcl/.travis.yml
index 3f83d9023..cb63a3216 100644
--- a/vendor/github.com/hashicorp/hcl/.travis.yml
+++ b/vendor/github.com/hashicorp/hcl/.travis.yml
@@ -3,7 +3,8 @@ sudo: false
language: go
go:
- - 1.8
+ - 1.x
+ - tip
branches:
only:
diff --git a/vendor/github.com/hashicorp/hcl/decoder.go b/vendor/github.com/hashicorp/hcl/decoder.go
index b88f322a8..bed9ebbe1 100644
--- a/vendor/github.com/hashicorp/hcl/decoder.go
+++ b/vendor/github.com/hashicorp/hcl/decoder.go
@@ -573,7 +573,11 @@ func (d *decoder) decodeStruct(name string, node ast.Node, result reflect.Value)
// Compile the list of all the fields that we're going to be decoding
// from all the structs.
- fields := make(map[*reflect.StructField]reflect.Value)
+ type field struct {
+ field reflect.StructField
+ val reflect.Value
+ }
+ fields := []field{}
for len(structs) > 0 {
structVal := structs[0]
structs = structs[1:]
@@ -616,7 +620,7 @@ func (d *decoder) decodeStruct(name string, node ast.Node, result reflect.Value)
}
// Normal struct field, store it away
- fields[&fieldType] = structVal.Field(i)
+ fields = append(fields, field{fieldType, structVal.Field(i)})
}
}
@@ -624,26 +628,27 @@ func (d *decoder) decodeStruct(name string, node ast.Node, result reflect.Value)
decodedFields := make([]string, 0, len(fields))
decodedFieldsVal := make([]reflect.Value, 0)
unusedKeysVal := make([]reflect.Value, 0)
- for fieldType, field := range fields {
- if !field.IsValid() {
+ for _, f := range fields {
+ field, fieldValue := f.field, f.val
+ if !fieldValue.IsValid() {
// This should never happen
panic("field is not valid")
}
// If we can't set the field, then it is unexported or something,
// and we just continue onwards.
- if !field.CanSet() {
+ if !fieldValue.CanSet() {
continue
}
- fieldName := fieldType.Name
+ fieldName := field.Name
- tagValue := fieldType.Tag.Get(tagName)
+ tagValue := field.Tag.Get(tagName)
tagParts := strings.SplitN(tagValue, ",", 2)
if len(tagParts) >= 2 {
switch tagParts[1] {
case "decodedFields":
- decodedFieldsVal = append(decodedFieldsVal, field)
+ decodedFieldsVal = append(decodedFieldsVal, fieldValue)
continue
case "key":
if item == nil {
@@ -654,10 +659,10 @@ func (d *decoder) decodeStruct(name string, node ast.Node, result reflect.Value)
}
}
- field.SetString(item.Keys[0].Token.Value().(string))
+ fieldValue.SetString(item.Keys[0].Token.Value().(string))
continue
case "unusedKeys":
- unusedKeysVal = append(unusedKeysVal, field)
+ unusedKeysVal = append(unusedKeysVal, fieldValue)
continue
}
}
@@ -684,7 +689,7 @@ func (d *decoder) decodeStruct(name string, node ast.Node, result reflect.Value)
// because we actually want the value.
fieldName = fmt.Sprintf("%s.%s", name, fieldName)
if len(prefixMatches.Items) > 0 {
- if err := d.decode(fieldName, prefixMatches, field); err != nil {
+ if err := d.decode(fieldName, prefixMatches, fieldValue); err != nil {
return err
}
}
@@ -694,12 +699,12 @@ func (d *decoder) decodeStruct(name string, node ast.Node, result reflect.Value)
decodeNode = &ast.ObjectList{Items: ot.List.Items}
}
- if err := d.decode(fieldName, decodeNode, field); err != nil {
+ if err := d.decode(fieldName, decodeNode, fieldValue); err != nil {
return err
}
}
- decodedFields = append(decodedFields, fieldType.Name)
+ decodedFields = append(decodedFields, field.Name)
}
if len(decodedFieldsVal) > 0 {
diff --git a/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go b/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go
index 69662367f..6601ef76e 100644
--- a/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go
+++ b/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go
@@ -351,7 +351,7 @@ func (s *Scanner) scanNumber(ch rune) token.Type {
return token.NUMBER
}
-// scanMantissa scans the mantissa begining from the rune. It returns the next
+// scanMantissa scans the mantissa beginning from the rune. It returns the next
// non decimal rune. It's used to determine wheter it's a fraction or exponent.
func (s *Scanner) scanMantissa(ch rune) rune {
scanned := false
diff --git a/vendor/github.com/hashicorp/hcl/json/scanner/scanner.go b/vendor/github.com/hashicorp/hcl/json/scanner/scanner.go
index dd5c72bb3..fe3f0f095 100644
--- a/vendor/github.com/hashicorp/hcl/json/scanner/scanner.go
+++ b/vendor/github.com/hashicorp/hcl/json/scanner/scanner.go
@@ -246,7 +246,7 @@ func (s *Scanner) scanNumber(ch rune) token.Type {
return token.NUMBER
}
-// scanMantissa scans the mantissa begining from the rune. It returns the next
+// scanMantissa scans the mantissa beginning from the rune. It returns the next
// non decimal rune. It's used to determine wheter it's a fraction or exponent.
func (s *Scanner) scanMantissa(ch rune) rune {
scanned := false
diff --git a/vendor/github.com/hashicorp/memberlist/memberlist.go b/vendor/github.com/hashicorp/memberlist/memberlist.go
index e1e38fc94..bdf333b43 100644
--- a/vendor/github.com/hashicorp/memberlist/memberlist.go
+++ b/vendor/github.com/hashicorp/memberlist/memberlist.go
@@ -308,23 +308,17 @@ func (m *Memberlist) tcpLookupIP(host string, defaultPort uint16) ([]ipPort, err
// resolveAddr is used to resolve the address into an address,
// port, and error. If no port is given, use the default
func (m *Memberlist) resolveAddr(hostStr string) ([]ipPort, error) {
- // Normalize the incoming string to host:port so we can apply Go's
- // parser to it.
- port := uint16(0)
- if !hasPort(hostStr) {
- hostStr += ":" + strconv.Itoa(m.config.BindPort)
- }
+ // This captures the supplied port, or the default one.
+ hostStr = ensurePort(hostStr, m.config.BindPort)
host, sport, err := net.SplitHostPort(hostStr)
if err != nil {
return nil, err
}
-
- // This will capture the supplied port, or the default one added above.
lport, err := strconv.ParseUint(sport, 10, 16)
if err != nil {
return nil, err
}
- port = uint16(lport)
+ port := uint16(lport)
// If it looks like an IP address we are done. The SplitHostPort() above
// will make sure the host part is in good shape for parsing, even for
diff --git a/vendor/github.com/hashicorp/memberlist/memberlist_test.go b/vendor/github.com/hashicorp/memberlist/memberlist_test.go
index ecda7fb55..ee2fc5d52 100644
--- a/vendor/github.com/hashicorp/memberlist/memberlist_test.go
+++ b/vendor/github.com/hashicorp/memberlist/memberlist_test.go
@@ -424,7 +424,7 @@ func TestMemberList_ResolveAddr_TCP_First(t *testing.T) {
}
port := uint16(m.config.BindPort)
expected := []ipPort{
- ipPort{net.ParseIP("127.0.0.1").To4(), port},
+ ipPort{net.ParseIP("127.0.0.1"), port},
ipPort{net.ParseIP("2001:db8:a0b:12f0::1"), port},
}
if !reflect.DeepEqual(ips, expected) {
diff --git a/vendor/github.com/hashicorp/memberlist/suspicion.go b/vendor/github.com/hashicorp/memberlist/suspicion.go
index 5f573e1fc..f8aa9e20a 100644
--- a/vendor/github.com/hashicorp/memberlist/suspicion.go
+++ b/vendor/github.com/hashicorp/memberlist/suspicion.go
@@ -117,7 +117,7 @@ func (s *suspicion) Confirm(from string) bool {
// stop the timer then we will call the timeout function directly from
// here.
n := atomic.AddInt32(&s.n, 1)
- elapsed := time.Now().Sub(s.start)
+ elapsed := time.Since(s.start)
remaining := remainingSuspicionTime(n, s.k, elapsed, s.min, s.max)
if s.timer.Stop() {
if remaining > 0 {
diff --git a/vendor/github.com/hashicorp/memberlist/util.go b/vendor/github.com/hashicorp/memberlist/util.go
index a4f926e3a..e2381a698 100644
--- a/vendor/github.com/hashicorp/memberlist/util.go
+++ b/vendor/github.com/hashicorp/memberlist/util.go
@@ -217,20 +217,6 @@ func decodeCompoundMessage(buf []byte) (trunc int, parts [][]byte, err error) {
return
}
-// Given a string of the form "host", "host:port",
-// "ipv6::addr" or "[ipv6::address]:port",
-// return true if the string includes a port.
-func hasPort(s string) bool {
- last := strings.LastIndex(s, ":")
- if last == -1 {
- return false
- }
- if s[0] == '[' {
- return s[last-1] == ']'
- }
- return strings.Index(s, ":") == last
-}
-
// compressPayload takes an opaque input buffer, compresses it
// and wraps it in a compress{} message that is encoded.
func compressPayload(inp []byte) (*bytes.Buffer, error) {
@@ -294,3 +280,31 @@ func decompressBuffer(c *compress) ([]byte, error) {
func joinHostPort(host string, port uint16) string {
return net.JoinHostPort(host, strconv.Itoa(int(port)))
}
+
+// hasPort is given a string of the form "host", "host:port", "ipv6::address",
+// or "[ipv6::address]:port", and returns true if the string includes a port.
+func hasPort(s string) bool {
+ // IPv6 address in brackets.
+ if strings.LastIndex(s, "[") == 0 {
+ return strings.LastIndex(s, ":") > strings.LastIndex(s, "]")
+ }
+
+ // Otherwise the presence of a single colon determines if there's a port
+ // since IPv6 addresses outside of brackets (count > 1) can't have a
+ // port.
+ return strings.Count(s, ":") == 1
+}
+
+// ensurePort makes sure the given string has a port number on it, otherwise it
+// appends the given port as a default.
+func ensurePort(s string, port int) string {
+ if hasPort(s) {
+ return s
+ }
+
+ // If this is an IPv6 address, the join call will add another set of
+ // brackets, so we have to trim before we add the default port.
+ s = strings.Trim(s, "[]")
+ s = net.JoinHostPort(s, strconv.Itoa(port))
+ return s
+}
diff --git a/vendor/github.com/hashicorp/memberlist/util_test.go b/vendor/github.com/hashicorp/memberlist/util_test.go
index e1d8eba01..b7f2b4199 100644
--- a/vendor/github.com/hashicorp/memberlist/util_test.go
+++ b/vendor/github.com/hashicorp/memberlist/util_test.go
@@ -7,24 +7,31 @@ import (
"time"
)
-func Test_hasPort(t *testing.T) {
- cases := []struct {
- s string
- expected bool
+func TestUtil_PortFunctions(t *testing.T) {
+ tests := []struct {
+ addr string
+ hasPort bool
+ ensurePort string
}{
- {"", false},
- {":80", true},
- {"127.0.0.1", false},
- {"127.0.0.1:80", true},
- {"::1", false},
- {"2001:db8:a0b:12f0::1", false},
- {"[2001:db8:a0b:12f0::1]", false},
- {"[2001:db8:a0b:12f0::1]:80", true},
- }
- for _, c := range cases {
- if hasPort(c.s) != c.expected {
- t.Fatalf("bad: '%s' hasPort was not %v", c.s, c.expected)
- }
+ {"1.2.3.4", false, "1.2.3.4:8301"},
+ {"1.2.3.4:1234", true, "1.2.3.4:1234"},
+ {"2600:1f14:e22:1501:f9a:2e0c:a167:67e8", false, "[2600:1f14:e22:1501:f9a:2e0c:a167:67e8]:8301"},
+ {"[2600:1f14:e22:1501:f9a:2e0c:a167:67e8]", false, "[2600:1f14:e22:1501:f9a:2e0c:a167:67e8]:8301"},
+ {"[2600:1f14:e22:1501:f9a:2e0c:a167:67e8]:1234", true, "[2600:1f14:e22:1501:f9a:2e0c:a167:67e8]:1234"},
+ {"localhost", false, "localhost:8301"},
+ {"localhost:1234", true, "localhost:1234"},
+ {"hashicorp.com", false, "hashicorp.com:8301"},
+ {"hashicorp.com:1234", true, "hashicorp.com:1234"},
+ }
+ for _, tt := range tests {
+ t.Run(tt.addr, func(t *testing.T) {
+ if got, want := hasPort(tt.addr), tt.hasPort; got != want {
+ t.Fatalf("got %v want %v", got, want)
+ }
+ if got, want := ensurePort(tt.addr, 8301), tt.ensurePort; got != want {
+ t.Fatalf("got %v want %v", got, want)
+ }
+ })
}
}