From c6fbb62abb5a8a9a4aafc5ac343d84b0ea8efcec Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Thu, 26 May 2005 11:53:15 +0000 Subject: create $ask_shorewall_interface_label, shorewall_interface_choices() and set_net_interface() out of ask_shorewall_interface() to avoid code duplication --- perl-install/network/shorewall.pm | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/perl-install/network/shorewall.pm b/perl-install/network/shorewall.pm index 5df61ec9b..ab427d2d4 100644 --- a/perl-install/network/shorewall.pm +++ b/perl-install/network/shorewall.pm @@ -54,22 +54,28 @@ sub get_shorewall_interface() { $default_dev; } -sub ask_shorewall_interface { - my ($in, $interface) = @_; +our $ask_shorewall_interface_label = N_("Please enter the name of the interface connected to the internet. + +Examples: + ppp+ for modem or DSL connections, + eth0, or eth1 for cable connection, + ippp+ for a isdn connection. +"); + +sub shorewall_interface_choices { + my ($refval) = @_; my $modules_conf = modules::any_conf->read; my @all_cards = network::ethernet::get_eth_cards($modules_conf); my %net_devices = network::ethernet::get_eth_cards_names(@all_cards); put_in_hash(\%net_devices, { 'ppp+' => 'ppp+', 'ippp+' => 'ippp+' }); - $in->ask_from('', - N("Please enter the name of the interface connected to the internet. + [ { label => N("Net Device"), val => $refval, list => [ sort keys %net_devices ], format => sub { $net_devices{$_[0]} || $_[0] }, not_edit => 0 } ]; +} + +sub ask_shorewall_interface { + my ($in, $interface) = @_; -Examples: - ppp+ for modem or DSL connections, - eth0, or eth1 for cable connection, - ippp+ for a isdn connection. -"), - [ { label => N("Net Device"), val => \$interface, list => [ sort keys %net_devices ], format => sub { $net_devices{$_[0]} || $_[0] }, not_edit => 0 } ]); + $in->ask_from('', translate($ask_shorewall_interface_label), shorewall_interface_choices(\$interface)); $interface; } @@ -77,6 +83,11 @@ sub read_default_interfaces { my ($conf, $o_in) = @_; my $interface = get_shorewall_interface(); $o_in and $interface = ask_shorewall_interface($o_in, $interface); + set_net_interface($conf, $interface); +} + +sub set_net_interface { + my ($conf, $interface) = @_; $conf->{net_interface} = $interface; $conf->{loc_interface} = [ grep { $_ ne $interface } detect_devices::getNet() ]; } -- cgit v1.2.1