Skip to content

Commit

Permalink
Merge pull request #7617 from rancher-sandbox/allow-listening-udp
Browse files Browse the repository at this point in the history
Windows guest agent: Not always listen on TCP
  • Loading branch information
mook-as authored Oct 11, 2024
2 parents 5307312 + 2e940b3 commit 735dcca
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/go/guestagent/pkg/tracker/apitracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ func (a *APITracker) Add(containerID string, portMap nat.PortMap) error {
for portProto, portBindings := range portMap {
var tmpPortBinding []nat.PortBinding

log.Debugf("called add with portProto: %+v, portBindings: %+v\n", portProto, portBindings)

for _, portBinding := range portBindings {
// The expose API only supports IPv4
ipv4, err := isIPv4(portBinding.HostIP)
Expand All @@ -100,8 +102,9 @@ func (a *APITracker) Add(containerID string, portMap nat.PortMap) error {

err = a.apiForwarder.Expose(
&types.ExposeRequest{
Local: ipPortBuilder(a.determineHostIP(portBinding.HostIP), portBinding.HostPort),
Remote: ipPortBuilder(a.tapInterfaceIP, portBinding.HostPort),
Local: ipPortBuilder(a.determineHostIP(portBinding.HostIP), portBinding.HostPort),
Remote: ipPortBuilder(a.tapInterfaceIP, portBinding.HostPort),
Protocol: types.TransportProtocol(portProto.Proto()),
})
if err != nil {
errs = append(errs, fmt.Errorf("exposing %+v failed: %w", portBinding, err))
Expand Down Expand Up @@ -147,7 +150,7 @@ func (a *APITracker) Remove(containerID string) error {

var errs []error

for _, portBindings := range portMap {
for portProto, portBindings := range portMap {
for _, portBinding := range portBindings {
// The unexpose API only supports IPv4
ipv4, err := isIPv4(portBinding.HostIP)
Expand All @@ -160,7 +163,8 @@ func (a *APITracker) Remove(containerID string) error {

err = a.apiForwarder.Unexpose(
&types.UnexposeRequest{
Local: ipPortBuilder(a.determineHostIP(portBinding.HostIP), portBinding.HostPort),
Local: ipPortBuilder(a.determineHostIP(portBinding.HostIP), portBinding.HostPort),
Protocol: types.TransportProtocol(portProto.Proto()),
})
if err != nil {
errs = append(errs,
Expand Down

0 comments on commit 735dcca

Please sign in to comment.