mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
network: add auto-detection of optimal MTU for WireGuard interface, --wg-mtu flag, set max_mtu for Corrosion to 1232
This commit is contained in:
@@ -30,6 +30,7 @@ type addOptions struct {
|
||||
version string
|
||||
wgEndpoints []string
|
||||
wgPort int
|
||||
wgMTU int
|
||||
yes bool
|
||||
}
|
||||
|
||||
@@ -104,6 +105,10 @@ Connection methods:
|
||||
"Multiple endpoints can be specified by repeating the flag or using a comma-separated list.\n"+
|
||||
"Defaults to the auto-detected public and routable machine IPs.",
|
||||
)
|
||||
cmd.Flags().IntVar(
|
||||
&opts.wgMTU, "wg-mtu", 0,
|
||||
"MTU of the WireGuard network interface on the machine. (default auto-detects the optimal value)",
|
||||
)
|
||||
cmd.Flags().IntVar(
|
||||
&opts.wgPort, "wg-port", network.DefaultWireGuardPort,
|
||||
"UDP port WireGuard listens on for incoming connections from other machines.",
|
||||
@@ -133,12 +138,17 @@ func add(ctx context.Context, uncli *cli.CLI, remoteMachine *cli.RemoteMachine,
|
||||
if opts.wgPort < 1 || opts.wgPort > 65535 {
|
||||
return fmt.Errorf("invalid WireGuard port %d: must be between 1 and 65535", opts.wgPort)
|
||||
}
|
||||
if opts.wgMTU != 0 && (opts.wgMTU < network.MinWireGuardMTU || opts.wgMTU > 65535) {
|
||||
return fmt.Errorf("invalid WireGuard MTU %d: must be 0 (auto-detect) or between %d and 65535",
|
||||
opts.wgMTU, network.MinWireGuardMTU)
|
||||
}
|
||||
addOpts := cli.AddMachineOptions{
|
||||
MachineName: opts.name,
|
||||
PublicIP: publicIP,
|
||||
RemoteMachine: remoteMachine,
|
||||
SkipInstall: opts.noInstall,
|
||||
Version: opts.version,
|
||||
WireguardMTU: opts.wgMTU,
|
||||
WireguardPort: opts.wgPort,
|
||||
AutoConfirm: opts.yes,
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ type initOptions struct {
|
||||
version string
|
||||
wgEndpoints []string
|
||||
wgPort int
|
||||
wgMTU int
|
||||
yes bool
|
||||
}
|
||||
|
||||
@@ -143,6 +144,10 @@ Connection methods:
|
||||
"Multiple endpoints can be specified by repeating the flag or using a comma-separated list.\n"+
|
||||
"Defaults to the auto-detected public and routable machine IPs.",
|
||||
)
|
||||
cmd.Flags().IntVar(
|
||||
&opts.wgMTU, "wg-mtu", 0,
|
||||
"MTU of the WireGuard network interface on the machine. (default auto-detects the optimal value)",
|
||||
)
|
||||
cmd.Flags().IntVar(
|
||||
&opts.wgPort, "wg-port", network.DefaultWireGuardPort,
|
||||
"UDP port WireGuard listens on for incoming connections from other machines.",
|
||||
@@ -186,6 +191,10 @@ func initCluster(ctx context.Context, uncli *cli.CLI, remoteMachine *cli.RemoteM
|
||||
if opts.wgPort < 1 || opts.wgPort > 65535 {
|
||||
return fmt.Errorf("invalid WireGuard port %d: must be between 1 and 65535", opts.wgPort)
|
||||
}
|
||||
if opts.wgMTU != 0 && (opts.wgMTU < network.MinWireGuardMTU || opts.wgMTU > 65535) {
|
||||
return fmt.Errorf("invalid WireGuard MTU %d: must be 0 (auto-detect) or between %d and 65535",
|
||||
opts.wgMTU, network.MinWireGuardMTU)
|
||||
}
|
||||
initOpts := cli.InitClusterOptions{
|
||||
Context: opts.context,
|
||||
MachineName: opts.name,
|
||||
@@ -194,6 +203,7 @@ func initCluster(ctx context.Context, uncli *cli.CLI, remoteMachine *cli.RemoteM
|
||||
RemoteMachine: remoteMachine,
|
||||
SkipInstall: opts.noInstall,
|
||||
Version: opts.version,
|
||||
WireguardMTU: opts.wgMTU,
|
||||
WireguardPort: opts.wgPort,
|
||||
AutoConfirm: opts.yes,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user