mirror of
https://github.com/webmin/webmin.git
synced 2025-07-21 23:40:34 +00:00
Use ui-lib standard functions
This commit is contained in:
@ -41,8 +41,8 @@ if ($serv->{'virtualmin'} && &foreign_check("virtual-server")) {
|
||||
&foreign_require("virtual-server");
|
||||
$d = &virtual_server::get_domain($serv->{'virtualmin'});
|
||||
if ($d) {
|
||||
print "<b>",&text('mon_virtualmin',
|
||||
&virtual_server::show_domain_name($d)),"</b> <p>\n";
|
||||
print &ui_alert_box(&text('mon_virtualmin',
|
||||
&virtual_server::show_domain_name($d)), 'warn');
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ else {
|
||||
}
|
||||
|
||||
print &ui_table_end();
|
||||
print "<p>\n";
|
||||
|
||||
print &ui_table_start($text{'mon_header5'}, "width=100%", 2, \@tds);
|
||||
|
||||
# Show emailing schedule
|
||||
@ -222,7 +222,7 @@ if (@servs) {
|
||||
}
|
||||
|
||||
print &ui_table_end();
|
||||
print "<p>\n";
|
||||
|
||||
print &ui_table_start($text{'mon_header2'}, "width=100%", 2, \@tds);
|
||||
|
||||
# Show commands to run on up/down
|
||||
@ -249,7 +249,6 @@ print &ui_table_row($text{'mon_runon'},
|
||||
undef, \@tds);
|
||||
|
||||
print &ui_table_end();
|
||||
print "<p>\n";
|
||||
|
||||
# Show history, in a hidden section
|
||||
if (!$in{'type'}) {
|
||||
|
81
status/smtp-monitor.pl
Normal file
81
status/smtp-monitor.pl
Normal file
@ -0,0 +1,81 @@
|
||||
# Connect to an SMTP server, login and try to send a message
|
||||
|
||||
sub get_smtp_status
|
||||
{
|
||||
my ($serv) = @_;
|
||||
|
||||
&foreign_require("mailboxes");
|
||||
$main::error_must_die = 1;
|
||||
eval {
|
||||
my $h = { 'fh' => 'MAIL' };
|
||||
&open_socket($server, $port, $h->{'fh'});
|
||||
if ($serv->{'ssl'} == 1) {
|
||||
# Switch to SSL mode right now
|
||||
&switch_smtp_to_ssl($h);
|
||||
}
|
||||
my $callpkg = (caller(0))[0];
|
||||
$h->{'fh'} = $callpkg."::".$h->{'fh'};
|
||||
&mailboxes::smtp_command($h);
|
||||
&mailboxes::smtp_command($h, "helo ".&get_system_hostname()."\r\n");
|
||||
if ($ssl == 2) {
|
||||
# Switch to SSL with STARTTLS
|
||||
my $rv = &mailboxes::smtp_command($h, "starttls\r\n", 1);
|
||||
if ($rv =~ /^2\d+/) {
|
||||
&switch_smtp_to_ssl($h);
|
||||
}
|
||||
else {
|
||||
$serv->{'ssl'} = 0;
|
||||
}
|
||||
}
|
||||
# XXX
|
||||
};
|
||||
if ($@) {
|
||||
$err = &entities_to_ascii(&html_tags_to_text("$@"));
|
||||
$err =~ s/at\s+\S+\s+line\s+\d+.*//;
|
||||
return { 'up' => 0,
|
||||
'desc' => $err };
|
||||
}
|
||||
return { 'up' => 1 };
|
||||
}
|
||||
|
||||
sub switch_smtp_to_ssl
|
||||
{
|
||||
my ($h) = @_;
|
||||
eval "use Net::SSLeay";
|
||||
$@ && die($text{'link_essl'});
|
||||
eval "Net::SSLeay::SSLeay_add_ssl_algorithms()";
|
||||
eval "Net::SSLeay::load_error_strings()";
|
||||
$h->{'ssl_ctx'} = Net::SSLeay::CTX_new() ||
|
||||
die("Failed to create SSL context");
|
||||
$h->{'ssl_con'} = Net::SSLeay::new($h->{'ssl_ctx'}) ||
|
||||
die("Failed to create SSL connection");
|
||||
Net::SSLeay::set_fd($h->{'ssl_con'}, fileno(MAIL));
|
||||
Net::SSLeay::connect($h->{'ssl_con'}) ||
|
||||
die("SSL connect() failed");
|
||||
}
|
||||
|
||||
sub show_smtp_dialog
|
||||
{
|
||||
my ($serv) = @_;
|
||||
|
||||
print &ui_table_row($text{'smtp_host'},
|
||||
&ui_textbox("host", $serv->{'host'}, 25));
|
||||
|
||||
print &ui_table_row($text{'smtp_port'},
|
||||
&ui_textbox("port", $serv->{'port'}, 5));
|
||||
}
|
||||
|
||||
sub parse_tcp_dialog
|
||||
{
|
||||
my ($serv) = @_;
|
||||
|
||||
&to_ipaddress($in{'host'}) || &to_ip6address($in{'host'}) ||
|
||||
&error($text{'smtp_ehost'});
|
||||
$serv->{'host'} = $in{'host'};
|
||||
|
||||
$in{'port'} =~ /^\d+$/ || &error($text{'smtp_eport'});
|
||||
$serv->{'port'} = $in{'port'};
|
||||
}
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user