<commit_before># debian-linux-lib.pl
# Networking functions for Debian linux >= 2.2 (aka. potato)
# Really, this won't work with releases prior to 2.2, don't even try it.
#
# <NAME>, July 2000
# Some code has been taken from redhat-linux-lib.pl

use File::Copy;

$network_interfaces_config = '/etc/network/interfaces';
$modules_config = '/etc/modprobe.d/arch/i386';
if (!-d $modules_config) {
	($modules_config) = glob('/etc/modprobe.d/arch/*');
	}
$network_interfaces = '/proc/net/dev';
$sysctl_config = "/etc/sysctl.conf";

do 'linux-lib.pl';

# boot_interfaces()
# Returns a list of interfaces brought up at boot time
sub boot_interfaces
{
my @ifaces = &get_interface_defs();
my @autos = &get_auto_defs();
my @rv;
my %v6map;
foreach $iface (@ifaces) {
	my ($name, $addrfam, $method, $options) = @$iface;
	if ($addrfam eq 'inet') {
		# IPv4 interface .. parse and add to list
		my $cfg = { };
		$cfg->{'fullname'} = $name;
		if ($cfg->{'fullname'} =~ /(\S+):(\d+)/) {
			$cfg->{'name'} = $1;
			$cfg->{'virtual'} = $2;
			}
		else {
			$cfg->{'name'} = $cfg->{'fullname'};
			}
		if ($cfg->{'fullname'} =~ /^br(\d+)$/) {
			$cfg->{'bridge'} = 1;
			}
		if ($gconfig{'os_version'} >= 3 || scalar(@autos)) {
			$cfg->{'up'} = &indexof($name, @autos) >= 0;
			}
		else {
			$cfg->{'up'} = 1;
			}
		foreach $option (@$options) {
			my ($param, $value) = @$option;
			if ($param eq 'noauto') {
				$cfg->{'up'} = 0;
				}
			elsif($param eq 'up') { 
				$cfg->{"partner"} =
				  &get_teaming_partner($cfg->{'name'}, $value);
				%options = &get_module_defs($name);
				$cfg->{'mode'} = $options{'mode'};
				$cfg->{'miimon'} = $options{'miimon'};
				$cfg->{'downdelay'} = $options{'downdelay'};
				$cfg->{'updelay'} = $options{'updelay'};
				}
			elsif($param =~ /^bond[_\-](mode|miimon|downdelay|updelay)$/) {
				$cfg->{$1} = $value;
				}
			elsif($param eq 'slaves') { 
				$cfg->{'partner'} = $value;
				}
			elsif($param eq 'hwaddress' || $param eq 'hwaddr') {
				local @v = split(/\s+/, $value);
				$cfg->{'ether_type'} = $v[0];
				$cfg->{'ether'} = $v[1];
				}
			elsif ($param eq 'bridge_ports') {
				$cfg->{'bridgeto'} = $value;
				}
			elsif ($param eq 'pre-up' &&
			       $value =~ /brctl\s+addif\s+br\d+\s+(\S+)/) {
				$cfg->{'bridgeto'} = $1;
				}
			else {
				$cfg->{$param} = $value;
				}
			}
		$cfg->{'dhcp'} = ($method eq 'dhcp');
		$cfg->{'bootp'} = ($method eq 'bootp');
		$cfg->{'edit'} = ($cfg->{'name'} !~ /^ppp|lo/);
		$cfg->{'index'} = scalar(@rv);	
		$cfg->{'file'} = $network_interfaces_config;
		if (!$cfg->{'broadcast'} &&
		    $cfg->{'address'} && $cfg->{'netmask'}) {
			$cfg->{'broadcast'} = &compute_broadcast(
				$cfg->{'address'}, $cfg->{'netmask'});
			}
		push(@rv, $cfg);
		}
	elsif ($addrfam eq "inet6") {
		# IPv6 interface .. add to matching v4 block
		my $v6cfg = { 'address6' => [ ],
			      'netmask6' => [ ] };
		foreach $option (@$options) {
			my ($param, $value) = @$option;
			if ($param eq "address") {
				push(@{$v6cfg->{'address6'}}, $value);
				}
			elsif ($param eq "netmask") {
				push(@{$v6cfg->{'netmask6'}}, $value);
				}
			elsif ($param eq "up" &&
			       $value =~ /ifconfig\s+(\S+)\s+inet6\s+add\s+([a-f0-9:]+)\/(\d+)/ &&
				$1 eq $name) {
				# Additional v6 address
				push(@{$v6cfg->{'address6'}}, $2);
				push(@{$v6cfg->{'netmask6'}}, $3);
				}
			}
		if ($method eq "manual" && !@{$v6cfg->{'address6'}}) {
			$v6cfg->{'auto6'} = 1;
			}
		$v6map{$name} = $v6cfg;
		}
	}
# Merge in v6 interface settings
foreach my $iface (@rv) {
	my $v6cfg = $v6map{$iface->{'fullname'}};
	if ($v6cfg) {
		foreach my $k (keys %$v6cfg) {
			$iface->{$k} = $v6cfg->{$k};
			}
		}
	}
return @rv;<commit_msg>Address and netmask could be on the same line http://virtualmin.com/node/37237<commit_after># debian-linux-lib.pl
# Networking functions for Debian linux >= 2.2 (aka. potato)
# Really, this won't work with releases prior to 2.2, don't even try it.
#
# <NAME>, July 2000
# Some code has been taken from redhat-linux-lib.pl

use File::Copy;

$network_interfaces_config = '/etc/network/interfaces';
$modules_config = '/etc/modprobe.d/arch/i386';
if (!-d $modules_config) {
	($modules_config) = glob('/etc/modprobe.d/arch/*');
	}
$network_interfaces = '/proc/net/dev';
$sysctl_config = "/etc/sysctl.conf";

do 'linux-lib.pl';

# boot_interfaces()
# Returns a list of interfaces brought up at boot time
sub boot_interfaces
{
my @ifaces = &get_interface_defs();
my @autos = &get_auto_defs();
my @rv;
my %v6map;
foreach $iface (@ifaces) {
	my ($name, $addrfam, $method, $options) = @$iface;
	if ($addrfam eq 'inet') {
		# IPv4 interface .. parse and add to list
		my $cfg = { };
		$cfg->{'fullname'} = $name;
		if ($cfg->{'fullname'} =~ /(\S+):(\d+)/) {
			$cfg->{'name'} = $1;
			$cfg->{'virtual'} = $2;
			}
		else {
			$cfg->{'name'} = $cfg->{'fullname'};
			}
		if ($cfg->{'fullname'} =~ /^br(\d+)$/) {
			$cfg->{'bridge'} = 1;
			}
		if ($gconfig{'os_version'} >= 3 || scalar(@autos)) {
			$cfg->{'up'} = &indexof($name, @autos) >= 0;
			}
		else {
			$cfg->{'up'} = 1;
			}
		foreach $option (@$options) {
			my ($param, $value) = @$option;
			if ($param eq 'noauto') {
				$cfg->{'up'} = 0;
				}
			elsif($param eq 'up') { 
				$cfg->{"partner"} =
				  &get_teaming_partner($cfg->{'name'}, $value);
				%options = &get_module_defs($name);
				$cfg->{'mode'} = $options{'mode'};
				$cfg->{'miimon'} = $options{'miimon'};
				$cfg->{'downdelay'} = $options{'downdelay'};
				$cfg->{'updelay'} = $options{'updelay'};
				}
			elsif($param =~ /^bond[_\-](mode|miimon|downdelay|updelay)$/) {
				$cfg->{$1} = $value;
				}
			elsif($param eq 'slaves') { 
				$cfg->{'partner'} = $value;
				}
			elsif($param eq 'hwaddress' || $param eq 'hwaddr') {
				local @v = split(/\s+/, $value);
				$cfg->{'ether_type'} = $v[0];
				$cfg->{'ether'} = $v[1];
				}
			elsif ($param eq 'bridge_ports') {
				$cfg->{'bridgeto'} = $value;
				}
			elsif ($param eq 'pre-up' &&
			       $value =~ /brctl\s+addif\s+br\d+\s+(\S+)/) {
				$cfg->{'bridgeto'} = $1;
				}
			else {
				$cfg->{$param} = $value;
				}
			}
		$cfg->{'dhcp'} = ($method eq 'dhcp');
		$cfg->{'bootp'} = ($method eq 'bootp');
		$cfg->{'edit'} = ($cfg->{'name'} !~ /^ppp|lo/);
		$cfg->{'index'} = scalar(@rv);	
		$cfg->{'file'} = $network_interfaces_config;
		if (!$cfg->{'broadcast'} &&
		    $cfg->{'address'} && $cfg->{'netmask'}) {
			$cfg->{'broadcast'} = &compute_broadcast(
				$cfg->{'address'}, $cfg->{'netmask'});
			}
		push(@rv, $cfg);
		}
	elsif ($addrfam eq "inet6") {
		# IPv6 interface .. add to matching v4 block
		my $v6cfg = { 'address6' => [ ],
			      'netmask6' => [ ] };
		foreach $option (@$options) {
			my ($param, $value) = @$option;
			if ($param eq "address") {
				$value =~ s/\s+dev\s+(\S+)//;
				if ($value =~ /^(\S+)\/(\d+)$/) {
					push(@{$v6cfg->{'address6'}}, $1);
					push(@{$v6cfg->{'netmask6'}}, $2);
					}
				else {
					push(@{$v6cfg->{'address6'}}, $value);
					}
				}
			elsif ($param eq "netmask") {
				push(@{$v6cfg->{'netmask6'}}, $value);
				}
			elsif ($param eq "up" &&
			       $value =~ /ifconfig\s+(\S+)\s+inet6\s+add\s+([a-f0-9:]+)\/(\d+)/ &&
				$1 eq $name) {
				# Additional v6 address
				push(@{$v6cfg->{'address6'}}, $2);
				push(@{$v6cfg->{'netmask6'}}, $3);
				}
			}
		if ($method eq "manual" && !@{$v6cfg->{'address6'}}) {
			$v6cfg->{'auto6'} = 1;
			}
		$v6map{$name} = $v6cfg;
		}
	}
# Merge in v6 interface settings
foreach my $iface (@rv) {
	my $v6cfg = $v6map{$iface->{'fullname'}};
	if ($v6cfg) {
		foreach my $k (keys %$v6cfg) {
			$iface->{$k} = $v6cfg->{$k};
			}
		}
	}
return @rv;
{'fraction_non_alphanumeric': 0.2620580891050072, 'fraction_numerical': 0.016690760940990933, 'mean_word_length': 3.1002155172413794, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1842428', 'n_tokens_mistral': 3637, 'n_tokens_neox': 3137, 'n_words': 616}