diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rwxr-xr-x | bin/draknetadvanced | 77 | ||||
-rwxr-xr-x | lib/network/netcenter.pm | 10 | ||||
-rw-r--r-- | lib/network/network.pm | 34 |
5 files changed, 49 insertions, 78 deletions
@@ -1,5 +1,5 @@ NAME = drakx-net -VERSION = 0.58 +VERSION = 0.59 DESTDIR= libdir=/usr/lib @@ -1,3 +1,7 @@ +0.59: +- Moved advanced network settings to draknetcenter, and removed + draknetadvanced. + 0.58: - Added draknetadvanced to control advanced network parameters such as IPv6 and TCP Window Scaling (#27070, #28829, #33623, #38662). diff --git a/bin/draknetadvanced b/bin/draknetadvanced deleted file mode 100755 index 9c88040..0000000 --- a/bin/draknetadvanced +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/perl - -# DrakNetAdvanced - -# Copyright (C) 2009 Mandriva (eugeni@mandriva.com) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -use lib qw(/usr/lib/libDrakX); - -# i18n: IMPORTANT: to get correct namespace (drakx-net instead of libDrakX) -BEGIN { unshift @::textdomains, 'drakx-net' } -use standalone; #- warning, standalone must be loaded very first, for 'explanations' -use interactive; -use network::network; -use any; -use common; - -sub replace_in_file { - my ($f, $old, $new) = @_; - my @lines; - foreach (cat_($f)) { - # remove - /$old/ or push(@lines, $_); - } - open(my $F, ">$f") or die "output in file $f failed: $!\n"; - foreach (@lines) { - print $F $_; - } - # saving new line - $new and print $F $new."\n"; - close($F); -} - -$ugtk2::wm_icon = "/usr/share/mcc/themes/default/drakproxy-mdk.png"; -my $modprobe = "$::prefix/etc/modprobe.conf"; -my $sysctl = "$::prefix/etc/sysctl.conf"; - -# ipv6 -my $ipv6_disabled=0; -foreach (cat_($modprobe)) { - /^install ipv6 \/bin\/true$/ and $ipv6_disabled=1; -} cat_($modprobe); - -# sysctl -my $window_scaling=0; -foreach (cat_($sysctl)) { - /^net\.ipv4\.tcp_window_scaling\s*=\s*0/ and $window_scaling=1; -} cat_($modprobe); - -my $u = { ipv6_disabled => $ipv6_disabled, window_scaling => $window_scaling }; -my $in = 'interactive'->vnew('su'); -if (network::network::advanced_choose($in, $u)) { - if ($u->{ipv6_disabled}) { - replace_in_file("$::prefix/etc/modprobe.conf", "^install ipv6", "install ipv6 \/bin\/true"); - } else { - replace_in_file("$::prefix/etc/modprobe.conf", "^install ipv6 \/bin\/true"); - } - if ($u->{window_scaling}) { - replace_in_file("$::prefix/etc/sysctl.conf", "^net.ipv4.tcp_window_scaling", "net.ipv4.tcp_window_scaling=0"); - } else { - replace_in_file("$::prefix/etc/sysctl.conf", "net\.ipv4\.tcp_window_scaling", "net.ipv4.tcp_window_scaling=1"); - } -} -$in->exit(0); diff --git a/lib/network/netcenter.pm b/lib/network/netcenter.pm index a43c52a..27a56c6 100755 --- a/lib/network/netcenter.pm +++ b/lib/network/netcenter.pm @@ -11,6 +11,7 @@ use ugtk2 qw(:create :helpers :wrappers); use network::connection; use network::connection_manager; use network::tools; +use network::network; sub build_cmanager { my ($in, $net, $w, $pixbufs, $connection) = @_; @@ -128,6 +129,14 @@ sub get_connections() { ); } +sub advanced_settings { + my ($in) = @_; + my $u = network::network::advanced_settings_read(); + if (network::network::advanced_choose($in, $u)) { + network::network::advanced_settings_write($u); + } +} + sub main { my ($in, $net, $dbus) = @_; @@ -157,6 +166,7 @@ sub main { map_index { build_cmanager_box($_, $::i == 0) } @cmanagers, ])), 0, gtknew('HButtonBox', spacing => 6, layout => 'end', children_loose => [ + gtknew('Button', text => N("Advanced settings"), clicked => sub { advanced_settings($in) }), gtknew('Button', text => N("Quit"), clicked => sub { Gtk2->main_quit }), ]), ]), diff --git a/lib/network/network.pm b/lib/network/network.pm index 8bb291d..e2bdb54 100644 --- a/lib/network/network.pm +++ b/lib/network/network.pm @@ -434,6 +434,40 @@ sub netprofile_read { $net->{PROFILE} = $config->{PROFILE} || 'default'; } +sub advanced_settings_read { + my $modprobe = "$::prefix/etc/modprobe.conf"; + my $sysctl = "$::prefix/etc/sysctl.conf"; + + # ipv6 + my $ipv6_disabled=0; + foreach (cat_($modprobe)) { + /^install ipv6 \/bin\/true$/ and $ipv6_disabled=1; + } cat_($modprobe); + + # sysctl + my $window_scaling=0; + foreach (cat_($sysctl)) { + /^net\.ipv4\.tcp_window_scaling\s*=\s*0/ and $window_scaling=1; + } cat_($modprobe); + { ipv6_disabled => $ipv6_disabled, window_scaling => $window_scaling }; +} + +sub advanced_settings_write { + my ($u) = @_; + if ($u->{ipv6_disabled}) { + my $line = "install ipv6 /bin/true\n"; + substInFile { s/^install ipv6 .*//; $_ = $line if eof } "$::prefix/etc/modprobe.conf"; + } else { + substInFile { s/^install ipv6 \/bin\/true// } "$::prefix/etc/modprobe.conf"; + } + if ($u->{window_scaling}) { + my $line = "net.ipv4.tcp_window_scaling=0\n"; + substInFile { s/^net\.ipv4\.tcp_window_scaling=.*//; $_ = $line if eof } "$::prefix/etc/sysctl.conf"; + } else { + my $line = "net.ipv4.tcp_window_scaling=1\n"; + substInFile { s/^net\.ipv4\.tcp_window_scaling=.*//; $_ = $line if eof } "$::prefix/etc/sysctl.conf"; + } +} sub advanced_choose { my ($in, $u) = @_; |