Skip to content

Commit

Permalink
fix more incorrect type conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
dduzgun-security committed Jun 4, 2024
1 parent 7a2ea4b commit 442dca7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
15 changes: 9 additions & 6 deletions agent/xds/proxystateconverter/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,17 @@ func (s *Converter) filterSubsetEndpoints(subset *structs.ServiceResolverSubset,

// used in clusters.go
func makeHostPortEndpoint(host string, port int) *pbproxystate.Endpoint {
return &pbproxystate.Endpoint{
Address: &pbproxystate.Endpoint_HostPort{
HostPort: &pbproxystate.HostPortAddress{
Host: host,
Port: uint32(port),
if port >= 0 && port <= 65535 {
return &pbproxystate.Endpoint{
Address: &pbproxystate.Endpoint_HostPort{
HostPort: &pbproxystate.HostPortAddress{
Host: host,
Port: uint32(port),
},
},
},
}
}
return nil
}

func makeUnixSocketEndpoint(path string) *pbproxystate.Endpoint {
Expand Down
21 changes: 12 additions & 9 deletions agent/xds/proxystateconverter/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,17 +764,20 @@ func makeListenerWithDefault(opts makeListenerOpts) *pbproxystate.Listener {
// // Since access logging is non-essential for routing, warn and move on
// opts.logger.Warn("error generating access log xds", err)
//}
return &pbproxystate.Listener{
Name: fmt.Sprintf("%s:%s:%d", opts.name, opts.addr, opts.port),
//AccessLog: accessLog,
BindAddress: &pbproxystate.Listener_HostPort{
HostPort: &pbproxystate.HostPortAddress{
Host: opts.addr,
Port: uint32(opts.port),
if opts.port >= 0 && opts.port <= 65535 {
return &pbproxystate.Listener{
Name: fmt.Sprintf("%s:%s:%d", opts.name, opts.addr, opts.port),
//AccessLog: accessLog,
BindAddress: &pbproxystate.Listener_HostPort{
HostPort: &pbproxystate.HostPortAddress{
Host: opts.addr,
Port: uint32(opts.port),
},
},
},
Direction: opts.direction,
Direction: opts.direction,
}
}
return nil
}

func makePipeListener(opts makeListenerOpts) *pbproxystate.Listener {
Expand Down

0 comments on commit 442dca7

Please sign in to comment.