cleanup based on shellcheck tests

This commit is contained in:
Darryl Quinn 2015-05-07 22:55:15 -05:00
parent 5afde21c9f
commit f19d8e33fd
2 changed files with 16 additions and 27 deletions

View File

@ -62,10 +62,10 @@ sub get_server_network_address()
@MACS=split(/:/, $mac);
push @list, "172";
push @list, "31";
push @list, hex @MACS[5];
push @list, hex $MACS[5];
# strip off the high bits
push @list, ((hex @MACS[4]) << 2) & 255;
$server_net=sprintf("%d.%d.%d.%d",@list[0],@list[1],@list[2],@list[3]);
push @list, ((hex $MACS[4]) << 2) & 255;
$server_net=sprintf("%d.%d.%d.%d",$list[0],$list[1],$list[2],$list[3]);
#($rc,$uciresult)=&uci_add_sectiontype("vtun","network");
($rc,$uciresult)=&uci_set_indexed_option("vtun","network","0","start",$server_net);
@ -80,8 +80,8 @@ sub get_active_tun()
foreach(`ps -w|grep vtun|grep ' tun '`)
{
@parts = $_ =~ /.*\:.*-(172-31-.*)\stun\stun.*/g;1;
@parts[0] =~ s/\-/\./g;
push(@active_tun,@parts[0]);
$parts[0] =~ s/\-/\./g;
push(@active_tun,$parts[0]);
}
return @active_tun;
}
@ -274,16 +274,5 @@ sub generate_ips()
sub addrtoint { return( unpack( "N", pack( "C4", split( /[.]/,$_[0]))))};
sub inttoaddr { return( join( ".", unpack( "C4", pack( "N", $_[0]))))};
sub DEBUGEXIT()
{
my ($text) = @_;
http_header();
html_header("$node setup", 1);
print "DEBUG-";
print $text;
print "</body>";
exit;
}
#weird uhttpd/busybox error requires a 1 at the end of this file
1

View File

@ -44,7 +44,7 @@ $config = nvram_get("config");
$node = nvram_get("node");
$node = "NOCALL" if $node eq "";
$unode = uc $node; # UPPER CASE NODENAME
$tun_server_start_num=50;
#$tun_server_start_num=50;
read_postdata();
@ -95,8 +95,8 @@ if($parms{button_reset} or not $parms{reload})
# load clients from UCI
&get_client_info();
$parms{server_net1}=@netw[2];
$parms{server_net2}=@netw[3];
$parms{server_net1}=$netw[2];
$parms{server_net2}=$netw[3];
$parms{dns}=$dns;
@ -312,10 +312,10 @@ sub print_vpn_clients()
print "<table cellpadding=0 cellspacing=0>";
print "<br /><tr class=tun_network_row><td colspan=6 align=center valign=top>Tunnel Server Network: ";
printf("%d.%d.",@netw[0],@netw[1]);
print "<input type='text' name='server_net1' size='3' maxlen='3' value='@netw[2]' onChange='form.submit()' >";
printf("%d.%d.",$netw[0],$netw[1]);
print "<input type='text' name='server_net1' size='3' maxlen='3' value='$netw[2]' onChange='form.submit()' >";
print ".";
print "<input type='text' name='server_net2' size='3' maxlen='3' value='@netw[3]' onChange='form.submit()'>";
print "<input type='text' name='server_net2' size='3' maxlen='3' value='$netw[3]' onChange='form.submit()'>";
print " (must be between 0 and 254)";
print "<br /><hr>Tunnel Server DNS Name: ";
@ -364,8 +364,8 @@ sub print_vpn_clients()
print "></td>";
# handle rollover of netw[3]
if(@netw[3]+($cnum * 4) > 252) {
@netw[2]++;
if($netw[3]+($cnum * 4) > 252) {
$netw[2]++;
$netw[3] = 0;
$net=0;
$cnum=0;
@ -373,9 +373,9 @@ sub print_vpn_clients()
$net=$cnum;
}
if($val eq "_add") { $lastnet=@netw[3]+(($net) * 4); }
else { $lastnet=@netw[3]+($net * 4); }
$fullnet=sprintf("%d.%d.%d.%d",@netw[0],@netw[1],@netw[2],$lastnet);
if($val eq "_add") { $lastnet=$netw[3]+(($net) * 4); }
else { $lastnet=$netw[3]+($net * 4); }
$fullnet=sprintf("%d.%d.%d.%d",$netw[0],$netw[1],$netw[2],$lastnet);
print "<td>&nbsp;$fullnet";
print "<input type=hidden name=client${val}_netip value='$fullnet'/></td>";
print "<td align=center>&nbsp;";