[fix] allow IPv6 controllers, workers, and targets (#5221)
Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
This commit is contained in:
1 parent
680bb02af9
commit
62c41191ff
42 files changed
+1996
-546
No files matched your search
@@ -14,7 +14,6 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/daemon/cluster"
|
||||
"github.com/hashicorp/boundary/internal/daemon/cluster/handlers"
|
||||
@@ -50,14 +49,14 @@ func (w *Worker) StartControllerConnections() error {
|
||||
case strings.HasPrefix(addr, "/"):
|
||||
initialAddrs = append(initialAddrs, addr)
|
||||
default:
|
||||
host, port, err := net.SplitHostPort(addr)
|
||||
if err != nil && strings.Contains(err.Error(), globals.MissingPortErrStr) {
|
||||
host, port, err = net.SplitHostPort(net.JoinHostPort(addr, "9201"))
|
||||
}
|
||||
host, port, err := util.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error parsing upstream address: %w", err)
|
||||
}
|
||||
initialAddrs = append(initialAddrs, net.JoinHostPort(host, port))
|
||||
if port == "" {
|
||||
port = "9201"
|
||||
}
|
||||
initialAddrs = append(initialAddrs, util.JoinHostPort(host, port))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -236,6 +236,9 @@ type TestWorkerOpts struct {
|
||||
// Enable observation events
|
||||
EnableObservationEvents bool
|
||||
|
||||
// Enable IPv6
|
||||
EnableIPv6 bool
|
||||
|
||||
// Enable error events
|
||||
EnableErrorEvents bool
|
||||
}
|
||||
@@ -272,6 +275,7 @@ func NewTestWorker(t testing.TB, opts *TestWorkerOpts) *TestWorker {
|
||||
configOpts = append(configOpts, config.WithAuditEventsEnabled(opts.EnableAuditEvents))
|
||||
configOpts = append(configOpts, config.WithSysEventsEnabled(opts.EnableSysEvents))
|
||||
configOpts = append(configOpts, config.WithObservationsEnabled(opts.EnableObservationEvents))
|
||||
configOpts = append(configOpts, config.WithIPv6Enabled(opts.EnableIPv6))
|
||||
configOpts = append(configOpts, config.TestWithErrorEventsEnabled(t, opts.EnableErrorEvents))
|
||||
opts.Config, err = config.DevWorker(configOpts...)
|
||||
if err != nil {
|
||||
@@ -561,7 +565,7 @@ func NewTestMultihopWorkers(t testing.TB,
|
||||
// NewAuthorizedPkiTestWorker creates a new test worker with the provided upstreams
|
||||
// and creates it in the provided repo as an authorized worker. It returns
|
||||
// The TestWorker and it's boundary id.
|
||||
func NewAuthorizedPkiTestWorker(t *testing.T, repo *server.Repository, name string, upstreams []string) (*TestWorker, string) {
|
||||
func NewAuthorizedPkiTestWorker(t *testing.T, repo *server.Repository, name string, upstreams []string, opt ...config.Option) (*TestWorker, string) {
|
||||
t.Helper()
|
||||
logger := hclog.New(&hclog.LoggerOptions{
|
||||
Level: hclog.Trace,
|
||||
|
||||
@@ -209,6 +209,30 @@ func TestNewTestMultihopWorkers(t *testing.T) {
|
||||
require.NoError(t, c.WaitForNextWorkerStatusUpdate(childKmsWorker.Name()))
|
||||
}
|
||||
|
||||
func TestWorkerIPv6(t *testing.T) {
|
||||
require, assert := require.New(t), assert.New(t)
|
||||
w := NewTestWorker(t, &TestWorkerOpts{
|
||||
EnableIPv6: true,
|
||||
})
|
||||
require.NotNil(w)
|
||||
validateIPv6 := func(addr, name string) {
|
||||
host, _, err := net.SplitHostPort(addr)
|
||||
require.NoError(err)
|
||||
require.NotEmpty(host, "missing host")
|
||||
ip := net.ParseIP(host)
|
||||
assert.NotNil(ip, "failed to parse %s", name)
|
||||
assert.NotNil(ip.To16(), "%s is not IPv6 %s", name, addr)
|
||||
}
|
||||
for _, addr := range w.addrs {
|
||||
validateIPv6(addr, "worker addr")
|
||||
}
|
||||
for _, addr := range w.ProxyAddrs() {
|
||||
validateIPv6(addr, "proxy addr")
|
||||
}
|
||||
require.NotNil(w.Worker().proxyListener)
|
||||
validateIPv6(w.Worker().proxyListener.ProxyListener.Addr().String(), "proxy listener addr")
|
||||
}
|
||||
|
||||
func createTestCert(t *testing.T) ([]byte, ed25519.PublicKey, ed25519.PrivateKey) {
|
||||
pub, priv, err := ed25519.GenerateKey(rand.Reader)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in new issue
Block a user