#!/usr/local/bin/perl # index.cgi # Display all existing SSL tunnels require './stunnel-lib.pl'; # Check if stunnel is installed if (!-x $config{'stunnel_path'}) { &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1); print &text('index_estunnel', "$config{'stunnel_path'}", "$gconfig{'webprefix'}/config.cgi?$module_name"),"

\n"; &ui_print_footer("/", $text{"index"}); exit; } # Check if inetd or xinetd is installed if (!$has_inetd && !$has_xinetd) { &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1); print "$text{'index_einetd'}

\n"; &ui_print_footer("/", $text{"index"}); exit; } # Get the version $ver = &get_stunnel_version(\$out); &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0, &help_search_link("stunnel", "man", "doc"), undef, undef, &text('index_version', $ver)); #if ($ver >= 4) { # print "

",&text('index_eversion', $ver, 4.0),"

\n"; # print &ui_hr(); # &ui_print_footer("/", $text{'index'}); # exit; # } # List all tunnels currently setup in inetd @tunnels = &list_stunnels(); @links = ( &select_all_link("d"), &select_invert_link("d"), "$text{'index_add'}" ); if (@tunnels) { print &ui_form_start("delete_tunnels.cgi", "post"); @tds = ( "width=5" ); print &ui_links_row(\@links); print &ui_columns_start([ "", $text{'index_name'}, $text{'index_port'}, $text{'index_active'}, $text{'index_action'} ], 100, 0, \@tds); foreach $t (@tunnels) { local @cols; if ($ver > 4) { # Parse new-style stunnel config file if ($t->{'args'} =~ /^(\S+)\s+(\S+)/) { $cfile = $2; @conf = &get_stunnel_config($cfile); ($conf) = grep { !$_->{'name'} } @conf; } } if ($ver > 4 && !$cfile) { push(@cols, &html_escape($t->{'name'})); } else { push(@cols, "". &html_escape($t->{'name'}).""); } push(@cols, &html_escape($t->{'port'})); push(@cols, $t->{'active'} ? $text{'yes'} : "$text{'no'}"); if ($ver > 4) { # Parse new-style stunnel config file if ($exec = $conf->{'values'}->{'exec'}) { $args = $conf->{'values'}->{'execargs'}; push(@cols, &text('index_cmd', $args ? "".&html_escape($args)."" : "".&html_escape($exec)."")); } elsif ($conn = $conf->{'values'}->{'connect'}) { push(@cols, &text('index_remote', "".&html_escape($conn)."")); } elsif ($cfile) { push(@cols, &text('index_conf', "$cfile")); } else { push(@cols, $text{'index_noconf'}); } } else { # Parse old-style stunnel args if ($t->{'args'} =~ /\s*-([lL])\s+(\S+)\s+--\s+(.*)/ || $t->{'args'} =~ /\s*-([lL])\s+(\S+)/) { push(@cols, &text('index_cmd', $3 ? "".&html_escape($3)."" : "".&html_escape($2)."")); } elsif ($t->{'args'} =~ /-r\s+(\S+):(\d+)/) { push(@cols, &text('index_remote', "".&html_escape("$1:$2")."")); } elsif ($t->{'args'} =~ /-r\s+(\d+)/) { push(@cols, &text('index_rport', "".&html_escape($1)."")); } else { push(@cols, "".&html_escape($t->{'args'}).""); } } print &ui_checked_columns_row(\@cols, \@tds, "d",$t->{'index'}); } print &ui_columns_end(); print &ui_links_row(\@links); print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]); } else { print "$text{'index_none'}

\n"; print &ui_links_row([ $links[2] ]); } print &ui_hr(); print "\n"; print "\n"; print "\n"; if ($has_inetd && $has_xinetd) { print "\n"; } elsif ($has_inetd) { print "\n"; } else { print "\n"; } print "
$text{'index_applymsg1'}$text{'index_applymsg2'}$text{'index_applymsg3'}
\n"; &ui_print_footer("/", $text{'index'});