You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new command line argument internalPortRange explicitly defines the ports to be used to communicate with backends. The inquiry response is updated to include the internal port assigned to the client.
Copy file name to clipboardExpand all lines: Program.cs
+28-7Lines changed: 28 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -64,7 +64,8 @@ static class Program
64
64
/// <summary>
65
65
/// Sessionless UDP Load Balancer sends packets to targets without session affinity.
66
66
/// </summary>
67
-
/// <param name="serverPortRange">Set the ports to listen to and forward to backend targets</param>
67
+
/// <param name="serverPortRange">Set the ports to listen to and forward to backend targets (can't overlap with internalPortRange or contain adminPort)</param>
68
+
/// <param name="internalPortRange">Set the ports to use to forward to backend targets (can't overlap with serverPortRange or contain adminPort)</param>
68
69
/// <param name="adminIp">Set the IP to listen on for watchdog events (default is first private IP)</param>
69
70
/// <param name="adminPort">Set the port that targets will send watchdog events</param>
70
71
/// <param name="clientTimeout">Seconds to allow before cleaning-up idle clients</param>
@@ -75,22 +76,33 @@ static class Program
75
76
/// <param name="defaultGroupId">Sets the group ID to assign to backends that when a registration packet doesn't include one, and when port isn't assigned a group</param>
76
77
/// <param name="useProxyProtocol">When specified packet data will be prepended with a Proxy Protocol v2 header when sent to the backend</param>
77
78
/// <param name="proxyProtocolTLV">Use to specify one or more TLVs to add to PPv2 headers (ignored when PPv2 isn't enabled). Example value: "0xDA=smurf".</param>
_ =>thrownewArgumentException($"Invalid internal port range: {internalPortRange}.",nameof(internalPortRange))
92
+
};
93
+
94
+
if(ports.Intersect(internal_ports).Any()){
95
+
thrownewArgumentException($"Server and internal port ranges must not overlap and mustn't include the admin port: {serverPortRange}, {internalPortRange} and {adminPort}.",nameof(serverPortRange));
96
+
}
86
97
87
98
awaitConsole.Out.WriteLineAsync($"{DateTime.UtcNow:s}: Welcome to the simplest UDP Load Balancer. Hit Ctrl-C to Stop.");
awaitConsole.Out.WriteLineAsync($"{DateTime.UtcNow:s}: The server port range is {serverPortRange} ({ports.Length} port{(ports.Length>1?"s":"")}).");
92
-
awaitConsole.Out.WriteLineAsync($"{DateTime.UtcNow:s}: The watchdog endpoint is {admin_ip}:{adminPort}.");
93
-
awaitConsole.Out.WriteLineAsync($"{DateTime.UtcNow:s}: Timeouts are: {clientTimeout}s for clients, and {targetTimeout}s for targets.");
103
+
awaitConsole.Out.WriteLineAsync($"{DateTime.UtcNow:s}: The internal port range is {internalPortRange} ({internal_ports.Length} port{(internal_ports.Length>1?"s":"")}).");
104
+
awaitConsole.Out.WriteLineAsync($"{DateTime.UtcNow:s}: The admin/watchdog endpoint is {admin_ip}:{adminPort}.");
105
+
awaitConsole.Out.WriteLineAsync($"{DateTime.UtcNow:s}: Timeouts are: {clientTimeout}s for clients, and {targetTimeout}s for targets.");
94
106
awaitConsole.Out.WriteLineAsync($"{DateTime.UtcNow:s}: Proxy Protocol v2 for targets is {(useProxyProtocol?"enabled":"disabled")}.");
var (internal_client,_)= clients.AddOrUpdate((request.RemoteEndPoint,port), ep =>(newUdpClient().Configure(),DateTime.UtcNow),(ep,c)=>(c.internal_client,DateTime.UtcNow));
210
+
var (_,internal_client,_)= clients.AddOrUpdate((request.RemoteEndPoint,port),
0 commit comments