mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-11 15:41:11 +02:00
Don't allow worker nodes to act as apid routers: * don't try to issue client certificate for apid on worker nodes * if worker nodes receives incoming connections with `--nodes` set to one of the local addresses of the nodd, it routes the request to itself without proxying Second point allows using `talosctl -e worker -n worker` to connect directly to the worker if the connection from the control plane is not available for some reason. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package director_test
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/talos-systems/grpc-proxy/proxy"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
type mockBackend struct {
|
|
target string
|
|
}
|
|
|
|
func (m *mockBackend) String() string {
|
|
return m.target
|
|
}
|
|
|
|
func (m *mockBackend) GetConnection(ctx context.Context) (context.Context, *grpc.ClientConn, error) {
|
|
return ctx, nil, nil
|
|
}
|
|
|
|
func (m *mockBackend) AppendInfo(streaming bool, resp []byte) ([]byte, error) {
|
|
return resp, nil
|
|
}
|
|
|
|
func (m *mockBackend) BuildError(streaming bool, err error) ([]byte, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func mockBackendFactory(target string) (proxy.Backend, error) {
|
|
return &mockBackend{target: target}, nil
|
|
}
|
|
|
|
type mockLocalAddressProvider struct {
|
|
local map[string]struct{}
|
|
}
|
|
|
|
func (m *mockLocalAddressProvider) IsLocalTarget(t string) bool {
|
|
_, ok := m.local[t]
|
|
|
|
return ok
|
|
}
|