Skip to content

Commit

Permalink
skip port 20 in dedicated port forward mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tocsoft committed Feb 27, 2023
1 parent 9bf25ab commit 7c58430
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions KubeConnect/PortForwarding/PortForwarderHandlerSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,35 @@ public void Configure(KestrelServerOptions options)
foreach (var service in manager.Services)
{
var serviceSelector = service.StringSelector;

// no real harm in always doing this
// add in the ssh port to allow for bridge injection
var sshendpoint = new IPEndPoint(service.AssignedAddress, 22);
options.Listen(sshendpoint, builder =>
{
var binding = new PortBinding()
{
Name = service.ServiceName,
Namespace = service.Namespace,
TargetPort = 2222,
Selector = $"{serviceSelector},kubeconnect.bridge/ssh=true" // onlly support finding ssh server for this particular port forward
};

builder.Use(next =>
// can only do this if we are in standard mode
if (args.AllServices)
{
// no real harm in always doing this
// add in the ssh port to allow for bridge injection
var sshendpoint = new IPEndPoint(service.AssignedAddress, 22);
options.Listen(sshendpoint, builder =>
{
return async (context) =>
var binding = new PortBinding()
{
context.Features.Set(binding);
await next(context);
Name = service.ServiceName,
Namespace = service.Namespace,
TargetPort = 2222,
Selector = $"{serviceSelector},kubeconnect.bridge/ssh=true" // onlly support finding ssh server for this particular port forward
};
});
builder.UseConnectionHandler<PortForwardingConnectionHandler>();
});
builder.Use(next =>
{
return async (context) =>
{
context.Features.Set(binding);
await next(context);
};
});
builder.UseConnectionHandler<PortForwardingConnectionHandler>();
});
}

foreach (var portDetails in service.TcpPorts)
{
Expand Down

0 comments on commit 7c58430

Please sign in to comment.