Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v17] Honor the proxy peering listen address specified in the configuration #49589

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4020,10 +4020,7 @@ func (process *TeleportProcess) setupProxyListeners(networkingConfig types.Clust
}

if !cfg.Proxy.DisableReverseTunnel && tunnelStrategy == types.ProxyPeering {
addr, err := process.Config.Proxy.PeerAddr()
if err != nil {
return nil, trace.Wrap(err)
}
addr := process.Config.Proxy.PeerListenAddr()

listener, err := process.importOrCreateListener(ListenerProxyPeer, addr.String())
if err != nil {
Expand Down
22 changes: 14 additions & 8 deletions lib/service/servicecfg/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,15 @@ func (c ProxyConfig) KubeAddr() (string, error) {
}

// PublicPeerAddr attempts to returns the public address the proxy advertises
// for proxy peering clients if available. It falls back to PeerAddr othewise.
// for proxy peering clients if available; otherwise, it falls back to trying to
// guess an appropriate public address based on the listen address.
func (c ProxyConfig) PublicPeerAddr() (*utils.NetAddr, error) {
addr := &c.PeerPublicAddr
if addr.IsEmpty() || addr.IsHostUnspecified() {
return c.PeerAddr()
if !addr.IsEmpty() && !addr.IsHostUnspecified() {
return addr, nil
}
return addr, nil
}

// PeerAddr returns the address the proxy advertises for proxy peering clients.
func (c ProxyConfig) PeerAddr() (*utils.NetAddr, error) {
addr := &c.PeerAddress
addr = &c.PeerAddress
if addr.IsEmpty() {
addr = defaults.ProxyPeeringListenAddr()
}
Expand All @@ -243,6 +240,15 @@ func (c ProxyConfig) PeerAddr() (*utils.NetAddr, error) {
return addr, nil
}

// PeerListenAddr returns the proxy peering listen address that was configured,
// or the default one otherwise.
func (c ProxyConfig) PeerListenAddr() *utils.NetAddr {
if c.PeerAddress.IsEmpty() {
return defaults.ProxyPeeringListenAddr()
}
return &c.PeerAddress
}

// KubeProxyConfig specifies the Kubernetes configuration for Teleport's proxy service
type KubeProxyConfig struct {
// Enabled turns kubernetes proxy role on or off for this process
Expand Down
Loading