Add UI to limit global and per-IP connections http://www.virtualmin.com/node/70253

This commit is contained in:
Jamie Cameron
2020-12-29 15:11:46 -08:00
parent 026c8cbf7d
commit dfeef5ae12
3 changed files with 32 additions and 4 deletions

View File

@@ -98,6 +98,22 @@ else {
$miniserv{'host'} = $in{'hostname'};
}
$miniserv{'no_resolv_myname'} = $in{'no_resolv_myname'};
if ($in{'maxconns_def'}) {
delete($miniserv{'maxconns'});
}
else {
$in{'maxconns'} =~ /^\d+$/ && $in{'maxconns'} > 1 ||
&error($text{'bind_emaxconns'});
$miniserv{'maxconns'} = $in{'maxconns'};
}
if ($in{'maxconns_per_ip_def'}) {
delete($miniserv{'maxconns_per_ip'});
}
else {
$in{'maxconns_per_ip'} =~ /^\d+$/ && $in{'maxconns_per_ip'} > 1 ||
&error($text{'bind_emaxconns_per_ip'});
$miniserv{'maxconns_per_ip'} = $in{'maxconns_per_ip'};
}
&put_miniserv_config(\%miniserv);
&unlock_file($ENV{'MINISERV_CONFIG'});

View File

@@ -46,24 +46,32 @@ print &ui_table_row($text{'bind_sockets'}, $stable);
# IPv6 enabled?
print &ui_table_row($text{'bind_ipv6'},
&ui_yesno_radio("ipv6", $miniserv{'ipv6'}), undef, [ "valign=middle","valign=middle" ]);
&ui_yesno_radio("ipv6", $miniserv{'ipv6'}));
# Show UDP listen address
print &ui_table_row($text{'bind_listen'},
&ui_radio("listen_def", $miniserv{"listen"} ? 0 : 1,
[ [ 1, $text{'bind_none'} ],
[ 0, &ui_textbox("listen", $miniserv{"listen"}, 6) ] ]), undef, [ "valign=middle","valign=middle" ]);
[ 0, &ui_textbox("listen", $miniserv{"listen"}, 6) ] ]));
# Show web server hostname
print &ui_table_row($text{'bind_hostname'},
&ui_radio("hostname_def", $miniserv{"host"} ? 0 : 1,
[ [ 1, $text{'bind_auto'} ],
[ 0, &ui_textbox("hostname", $miniserv{"host"}, 25) ] ]), undef, [ "valign=middle","valign=middle" ]);
[ 0, &ui_textbox("hostname", $miniserv{"host"}, 25) ] ]));
# Reverse-lookup hostname
print &ui_table_row($text{'bind_resolv_myname'},
&ui_radio("no_resolv_myname", int($miniserv{'no_resolv_myname'}),
[ [ 0, $text{'yes'} ], [ 1, $text{'no'} ] ]), undef, [ "valign=middle","valign=middle" ]);
[ [ 0, $text{'yes'} ], [ 1, $text{'no'} ] ]));
# Max concurrent connections
print &ui_table_row($text{'bind_maxconns'},
&ui_opt_textbox("maxconns", $miniserv{'maxconns'}, 5,
$text{'default'}." (50)"));
print &ui_table_row($text{'bind_maxconns_per_ip'},
&ui_opt_textbox("maxconns_per_ip", $miniserv{'maxconns_per_ip'}, 5,
$text{'default'}." (25)"));
print &ui_table_end();
print &ui_form_end([ [ "save", $text{'save'} ] ]);

View File

@@ -63,6 +63,10 @@ bind_eipv6=IPv6 cannot be enabled unless the $1 Perl module is installed
bind_redirecting=Redirecting to new URL ..
bind_elsof=New port $1 is already in use by another process
bind_eonsystem=The IP address $1 is not active on this system, and so cannot be used
bind_maxconns=Maximum total concurrent connections
bind_maxconns_per_ip=Maximum concurrent connections per IP
bind_emaxconns=Maximum concurrent connections must be a number greater than 1
bind_emaxconns_per_ip=Maximum concurrent connections per IP must be a number greater than 1
log_title=Logging
log_desc=Webmin can be configured to write a log of web server hits, in the standard CLF log file format. If logging is enabled, you can also choose whether IP addresses or hostnames are recorded, and how often the log file is cleared. When enabled, logs are written to the file $1.