open-consul/vendor/github.com/hashicorp/go-sockaddr
R.B. Boyer 1d54909333
connect: intermediate CA certs generated with the vault provider lack URI SANs (#6491)
This only affects vault versions >=1.1.1 because the prior code
accidentally relied upon a bug that was fixed in
https://github.com/hashicorp/vault/pull/6505

The existing tests should have caught this, but they were using a
vendored copy of vault version 0.10.3. This fixes the tests by running
an actual copy of vault instead of an in-process copy. This has the
added benefit of changing the dependency on vault to just vault/api.

Also update VaultProvider to use similar SetIntermediate validation code
as the ConsulProvider implementation.
2019-09-23 12:04:40 -05:00
..
template vendor: update github.com/hashicorp/go-sockaddr (#3633) 2017-10-31 17:05:57 -07:00
.gitignore Update vendoring from go mod. (#5566) 2019-03-26 17:50:42 -04:00
GNUmakefile connect: intermediate CA certs generated with the vault provider lack URI SANs (#6491) 2019-09-23 12:04:40 -05:00
LICENSE Import github.com/hashicorp/go-sockaddr 2016-12-02 15:14:44 +11:00
README.md Update hashicorp/go-sockaddr to the latest version. 2017-05-23 16:47:17 -07:00
doc.go Updates memberlist and Serf (and adds new dependencies). 2017-02-08 13:56:07 -08:00
go.mod connect: intermediate CA certs generated with the vault provider lack URI SANs (#6491) 2019-09-23 12:04:40 -05:00
go.sum connect: intermediate CA certs generated with the vault provider lack URI SANs (#6491) 2019-09-23 12:04:40 -05:00
ifaddr.go Update hashicorp/go-sockaddr to the latest version. 2017-05-23 16:47:17 -07:00
ifaddrs.go connect: intermediate CA certs generated with the vault provider lack URI SANs (#6491) 2019-09-23 12:04:40 -05:00
ifattr.go Import github.com/hashicorp/go-sockaddr 2016-12-02 15:14:44 +11:00
ipaddr.go Update `hashicorp/go-sockaddr` to account for `tun(4)` interfaces. 2017-01-17 12:37:56 -08:00
ipaddrs.go Import github.com/hashicorp/go-sockaddr 2016-12-02 15:14:44 +11:00
ipv4addr.go Revert monkey patch since it is not clear whether this is an issue at all. 2017-09-26 13:42:32 +02:00
ipv6addr.go Import github.com/hashicorp/go-sockaddr 2016-12-02 15:14:44 +11:00
rfc.go Update hashicorp/go-sockaddr to the latest version. 2017-05-23 16:47:17 -07:00
route_info.go Update `hashicorp/go-sockaddr` to account for `tun(4)` interfaces. 2017-01-17 12:37:56 -08:00
route_info_android.go connect: intermediate CA certs generated with the vault provider lack URI SANs (#6491) 2019-09-23 12:04:40 -05:00
route_info_bsd.go Updates memberlist and Serf (and adds new dependencies). 2017-02-08 13:56:07 -08:00
route_info_default.go Update `hashicorp/go-sockaddr` to account for `tun(4)` interfaces. 2017-01-17 12:37:56 -08:00
route_info_linux.go connect: intermediate CA certs generated with the vault provider lack URI SANs (#6491) 2019-09-23 12:04:40 -05:00
route_info_solaris.go Updates memberlist and Serf (and adds new dependencies). 2017-02-08 13:56:07 -08:00
route_info_windows.go Updates memberlist and Serf (and adds new dependencies). 2017-02-08 13:56:07 -08:00
sockaddr.go vendor: update github.com/hashicorp/go-sockaddr (#3633) 2017-10-31 17:05:57 -07:00
sockaddrs.go Import github.com/hashicorp/go-sockaddr 2016-12-02 15:14:44 +11:00
unixsock.go Import github.com/hashicorp/go-sockaddr 2016-12-02 15:14:44 +11:00

README.md

go-sockaddr

sockaddr Library

Socket address convenience functions for Go. go-sockaddr is a convenience library that makes doing the right thing with IP addresses easy. go-sockaddr is loosely modeled after the UNIX sockaddr_t and creates a union of the family of sockaddr_t types (see below for an ascii diagram). Library documentation is available at https://godoc.org/github.com/hashicorp/go-sockaddr. The primary intent of the library was to make it possible to define heuristics for selecting the correct IP addresses when a configuration is evaluated at runtime. See the docs, template package, tests, and CLI utility for details and hints as to how to use this library.

For example, with this library it is possible to find an IP address that:

Or any combination or variation therein.

There are also a few simple helper functions such as GetPublicIP and GetPrivateIP which both return strings and select the first public or private IP address on the default interface, respectively. Similarly, there is also a helper function called GetInterfaceIP which returns the first usable IP address on the named interface.

sockaddr CLI

Given the possible complexity of the sockaddr library, there is a CLI utility that accompanies the library, also called sockaddr. The sockaddr utility exposes nearly all of the functionality of the library and can be used either as an administrative tool or testing tool. To install the sockaddr, run:

$ go get -u github.com/hashicorp/go-sockaddr/cmd/sockaddr

If you're familiar with UNIX's sockaddr struct's, the following diagram mapping the C sockaddr (top) to go-sockaddr structs (bottom) and interfaces will be helpful:

+-------------------------------------------------------+
|                                                       |
|                        sockaddr                       |
|                        SockAddr                       |
|                                                       |
| +--------------+ +----------------------------------+ |
| | sockaddr_un  | |                                  | |
| | SockAddrUnix | |           sockaddr_in{,6}        | |
| +--------------+ |                IPAddr            | |
|                  |                                  | |
|                  | +-------------+ +--------------+ | |
|                  | | sockaddr_in | | sockaddr_in6 | | |
|                  | |   IPv4Addr  | |   IPv6Addr   | | |
|                  | +-------------+ +--------------+ | |
|                  |                                  | |
|                  +----------------------------------+ |
|                                                       |
+-------------------------------------------------------+

Inspiration and Design

There were many subtle inspirations that led to this design, but the most direct inspiration for the filtering syntax was OpenBSD's pf.conf(5) firewall syntax that lets you select the first IP address on a given named interface. The original problem stemmed from:

  • needing to create immutable images using Packer that ran the Consul process (Consul can only use one IP address at a time);
  • images that may or may not have multiple interfaces or IP addresses at runtime; and
  • we didn't want to rely on configuration management to render out the correct IP address if the VM image was being used in an auto-scaling group.

Instead we needed some way to codify a heuristic that would correctly select the right IP address but the input parameters were not known when the image was created.