bugfix: network/start now resets to default, added icons for pages

This commit is contained in:
Darryl Quinn 2015-04-09 10:14:04 -05:00
parent fcce4039db
commit cf1ddb900b
8 changed files with 24 additions and 16 deletions

View File

@ -49,12 +49,12 @@ options_config() {
allowed_client_config() {
local cfg="$1"
local new_file="$2"
local enabled node pwd netip clientip serverip persist compress keepalive proto
local enabled name pwd netip clientip serverip persist compress keepalive proto
if [ $TUNNUM -lt $MAXTUNNUM ]
then
config_get_bool enabled "$cfg" enabled
config_get node "$cfg" node
config_get name "$cfg" name
config_get passwd "$cfg" passwd
config_get netip "$cfg" netip
config_get clientip "$cfg" clientip
@ -64,9 +64,11 @@ allowed_client_config() {
config_get keepalive "$cfg" keepalive "yes"
config_get proto "$cfg" proto "tcp"
cname=`echo $name`-`echo $netip | tr "." "-"`
if [ $enabled -eq 1 ]
then
echo "node $node {" >> $new_file
echo "$cname {" >> $new_file
echo " passwd $passwd;" >> $new_file
echo " type tun;" >> $new_file
echo " proto $proto;" >> $new_file
@ -90,7 +92,8 @@ allowed_client_config() {
}
apply_uci_config() {
sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
#sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
sh -c '. /lib/functions.sh; include /lib/config'
}
start() {
@ -111,7 +114,7 @@ start() {
stop() {
# find the vtund SERVER process... --- FIX THIS
for x in `ps -w|grep -F 'vtund[s]:'|grep -v grep|tr -s ' '|cut -d' ' -f2`
for x in `ps -w|grep -F 'vtund[s]:'|grep -v grep|tr -s ' '|cut -d' ' -f1`
do
s=`echo $s $x`
done

View File

@ -24,7 +24,7 @@ sub get_server_network_address()
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_section_type("vtun","network");
#($rc,$uciresult)=&uci_add_sectiontype("vtun","network");
($rc,$uciresult)=&uci_set_indexed_option("vtun","network","0","start",$server_net);
$rc=&uci_commit("vtun");
}

View File

@ -68,10 +68,10 @@ sub uci_add_sectiontype()
return ($rc,$res);
}
sub uci_delete_sectiontype()
sub uci_delete_option()
{
my ($config,$stype)=@_;
my $cmd=sprintf('uci delete %s.%s',$config,$stype);
my ($config,$stype,$index,$option)=@_;
my $cmd=sprintf('uci delete %s.@%s[%s].%s',$config,$stype,$index,$option);
my $res=`$cmd`;
my $rc=$?;
chomp($res);

View File

@ -42,8 +42,8 @@ get_active_tun();
if($parms{button_reset})
{
($rc,$res)=&uci_revert("vtun");
# ($rc,$res)=&uci_delete_sectiontype("vtun","network");
# $rc=&uci_commit("vtun");
($rc,$res)=&uci_delete_option("vtun","network",0,"start");
$rc=&uci_commit("vtun");
}
#################
@ -57,6 +57,9 @@ if($parms{button_reset})
#################
if($parms{button_reset} or not $parms{reload})
{
# revert to previous state on initial load
($rc,$res)=&uci_revert("vtun");
# load clients from UCI
&get_client_info();
@ -146,6 +149,8 @@ $rc=save_clients();
#################
# SAVE the server network numbers into the UCI
#################
$netw[2]=$parms{server_net1};
$netw[3]=$parms{server_net2};
$rc=save_network();
#################
@ -170,9 +175,8 @@ if($parms{button_save} and not (@cli_err or @serv_err))
######################################################################################
http_header() unless $debug == 2;
html_header("$node setup", 1);
print "<body><center>\n";
print "<form method=post action=/cgi-bin/vpn enctype='multipart/form-data'>\n" unless $debug == 2;
print "<form id=vpn method=post action=/cgi-bin/vpn enctype='multipart/form-data'>\n" unless $debug == 2;
print "<form method=post action=test>\n" if $debug == 2;
print "<table width=790>\n";
@ -331,12 +335,13 @@ sub print_vpn_clients()
$fullnet=sprintf("%d.%d.%d.%d",@netw[0],@netw[1],@netw[2],$lastnet);
print "<td>&nbsp;$fullnet</td>";
print "<td>&nbsp;";
print "<img class='tun_client_active_img' src='/dot.png'/>" if((&is_tunnel_active($name)) && ($val ne "_add"));
print "<td align=center>&nbsp;";
print "<img class='tun_client_active_img' src='/plug-connect.png'/>" if (&is_tunnel_active($name) && ($val ne "_add"));
print "<img class='tun_client_inactive_img' src='/plug-disconnect.png'/>" if ($val ne "_add");
print "</td>";
print "<td><input type=submit name=client_add value=Add title='Add this client'>" if($val eq "_add");
print "</td>";
print "<td class='tun_client_mailto'><a href='mailto:?subject=AREDN%20Tunnel%20Connection&body=Your%20connection%20details:%0D%0AName:%20$name%0D%0APassword:%20$pass%0D%0ANetwork:%20$fullnet%0D%0AServer%20address:%20<your%20server%20dns%20name>'>Email</a></td>" unless($val eq "_add");
print "<td class='tun_client_mailto'><a href='mailto:?subject=AREDN%20Tunnel%20Connection&body=Your%20connection%20details:%0D%0AName:%20$name%0D%0APassword:%20$pass%0D%0ANetwork:%20$fullnet%0D%0AServer%20address:%20<your%20server%20dns%20name>'><img class='tun_client_mailto_img' src='/email.png'/></a></td>" unless($val eq "_add");
print "</tr>\n";
# display any errors

BIN
files/www/email.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

BIN
files/www/plug-connect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
files/www/trash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B