mirror of https://github.com/aredn/aredn.git
enhancement: added contact info/comment field for each tunnel connect… (#479)
* enhancement: added contact info/comment field for each tunnel connection. Allows for a short comment or an email address so you can remember who to contact for each tunnel. The field is optional and does not need to be filled out to get a tunnel connection up. Also cleaned up some of the layout on the tunnel pages and hopefully made it a bit easier to tell what is what. Fixes #457 * added `maxlength='50'` to the comment/contact field. 50 characters should be enough for an email address or a short comment. * Allow for spaces in the Tunnel contact/comment field
This commit is contained in:
parent
812c007825
commit
ff2e93565b
|
@ -45,6 +45,21 @@ body table {
|
|||
border-radius: 10px;
|
||||
background-color: rgb(108,231,232);
|
||||
}
|
||||
.tun_client_row td {
|
||||
padding: 2px;
|
||||
}
|
||||
.tun_client_list1:nth-child(odd) {
|
||||
background: rgba(192,192,192,0.5);
|
||||
}
|
||||
.tun_client_list2:nth-child(even) {
|
||||
background: rgba(192,192,192,0.5);
|
||||
}
|
||||
.tun_client_center_item {
|
||||
vertical-align:middle;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
|
||||
#node_description_entry {
|
||||
vertical-align: middle;
|
||||
resize: none;
|
||||
|
|
|
@ -33,6 +33,27 @@ body table {
|
|||
.AREDNLogo { background: white; position:absolute; left:10%; width:175; height:95; }
|
||||
.PartOfAREDN { font-family:Verdana; font-size:xx-small; text-align:center; }
|
||||
|
||||
/* Tunnel Page Classes */
|
||||
.tun_network_row td {
|
||||
padding: 5px;
|
||||
border: solid 1px black;
|
||||
border-radius: 10px;
|
||||
background-color: rgb(108,231,232);
|
||||
}
|
||||
.tun_client_row td {
|
||||
padding: 2px;
|
||||
}
|
||||
.tun_client_list1:nth-child(odd) {
|
||||
background: rgba(192,192,192,0.5);
|
||||
}
|
||||
.tun_client_list2:nth-child(even) {
|
||||
background: rgba(192,192,192,0.5);
|
||||
}
|
||||
.tun_client_center_item {
|
||||
vertical-align:middle;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#node_description_entry {
|
||||
vertical-align: middle;
|
||||
resize: none;
|
||||
|
|
|
@ -245,7 +245,7 @@ sub uci_delete_indexed_type()
|
|||
sub uci_set_named_option()
|
||||
{
|
||||
my ($config,$sname,$option,$val)=@_;
|
||||
my $cmd=sprintf('uci set %s.%s.%s=%s',$config,$sname,$option,$val);
|
||||
my $cmd=sprintf('uci set %s.%s.%s="%s"',$config,$sname,$option,$val);
|
||||
#uci set olsrd.tunnelserver.Ip4Broadcast=255.255.255.255
|
||||
my $res=`$cmd`;
|
||||
my $rc=$?;
|
||||
|
|
|
@ -65,13 +65,16 @@ sub save_clients()
|
|||
push(@cli_err,"Problem saving UCI vtun client net IP (#$i): $rc") if $rc;
|
||||
|
||||
$rc=&uci_set_named_option("vtun","client_$i","enabled",$parms{"client${i}_enabled"});
|
||||
push(@cli_err,"Problem saving UCI vtun client (#$i): $rc") if $rc;
|
||||
push(@cli_err,"Problem saving UCI vtun client enabled (#$i): $rc") if $rc;
|
||||
|
||||
$rc=&uci_set_named_option("vtun","client_$i","name",$parms{"client${i}_name"});
|
||||
push(@cli_err,"Problem saving UCI vtun client (#$i): $rc") if $rc;
|
||||
push(@cli_err,"Problem saving UCI vtun client name (#$i): $rc") if $rc;
|
||||
|
||||
$rc=&uci_set_named_option("vtun","client_$i","contact",$parms{"client${i}_contact"});
|
||||
push(@cli_err,"Problem saving UCI vtun client contact (#$i): $rc") if $rc;
|
||||
|
||||
$rc=&uci_set_named_option("vtun","client_$i","passwd",$parms{"client${i}_passwd"});
|
||||
push(@cli_err,"Problem saving UCI vtun client (#$i): $rc") if $rc;
|
||||
push(@cli_err,"Problem saving UCI vtun client password (#$i): $rc") if $rc;
|
||||
|
||||
# generate the VTUN NODE name based on the node name and netip
|
||||
$net=~ s/\./\-/g;
|
||||
|
@ -174,7 +177,7 @@ $client_num = 0;
|
|||
|
||||
foreach $val (@list)
|
||||
{
|
||||
foreach $var (qw(enabled name passwd netip))
|
||||
foreach $var (qw(enabled name passwd netip contact))
|
||||
{
|
||||
$varname = "client${val}_$var";
|
||||
$parms{$varname} = "0" if($val eq "enabled" and $parms{$varname} eq "");
|
||||
|
@ -196,7 +199,7 @@ foreach $val (@list)
|
|||
if($val eq "_add")
|
||||
{
|
||||
# skip any null values on add or save
|
||||
next unless ($enabled or $name or $passwd) and ($parms{client_add} or $parms{button_save});
|
||||
next unless ($enabled or $name or $passwd or $contact) and ($parms{client_add} or $parms{button_save});
|
||||
} # no delete capabilities as net renumbering is not allowed
|
||||
|
||||
|
||||
|
@ -226,7 +229,7 @@ foreach $val (@list)
|
|||
# Clear out the ADD values
|
||||
if($val eq "_add")
|
||||
{
|
||||
foreach $var (qw(net enabled name passwd netip))
|
||||
foreach $var (qw(net enabled name passwd netip contact))
|
||||
{
|
||||
$parms{"client_add_${var}"} = "";
|
||||
}
|
||||
|
@ -385,11 +388,12 @@ sub print_vpn_clients()
|
|||
print "<input type='text' name='dns' size='30' value='$dns' onChange='form.submit()' ></td></tr>";
|
||||
|
||||
print "</table>";
|
||||
print "<hr />";
|
||||
print "<table class=tun_client_table cellpadding=0 cellspacing=0>";
|
||||
#print "<hr />";
|
||||
print "<table cellpadding=0 cellspacing=0>";
|
||||
print "<tr><th colspan=6 align=center valign=top> </th></tr>\n";
|
||||
print "<tr class=tun_client_row>";
|
||||
print "<tr><th colspan=6>Allow the following clients to connect to this server:</th></tr>\n";
|
||||
print "<tr><th colspan=6><hr></th></tr>\n";
|
||||
print "<tr><th>Enabled?</th><th>Client</th><th>Pwd</th><th>Net</th><th>Active </td><th>Action</th></tr>\n";
|
||||
|
||||
for($i = 0, @list = (); $i < $parms{client_num}; ++$i) { push @list, $i };
|
||||
|
@ -399,14 +403,14 @@ sub print_vpn_clients()
|
|||
$cnum=0;
|
||||
foreach $val (@list)
|
||||
{
|
||||
foreach $var (qw(enabled name passwd))
|
||||
foreach $var (qw(enabled name passwd contact))
|
||||
{
|
||||
eval sprintf("\$%s = \$parms{client%s_%s}", $var, $val, $var);
|
||||
}
|
||||
|
||||
print "<tr class=tun_client_add_row><td height=10></td></tr>\n" if $val eq "_add" and scalar(@list) > 1;
|
||||
print "<tr class=tun_client_row>";
|
||||
print "<td>";
|
||||
print "<tr class='tun_client_list2 tun_client_row'>";
|
||||
print "<td class='tun_client_center_item' rowspan='2'>";
|
||||
|
||||
# Required to be first, so, if the checkbox is cleared, a value will still POST
|
||||
print "<input type='hidden' name='client${val}_enabled' value='0'>" unless($val eq "_add");
|
||||
|
@ -420,7 +424,7 @@ sub print_vpn_clients()
|
|||
# print " disabled" unless $val eq "_add";
|
||||
print " title='client name'></td>";
|
||||
|
||||
print "<td> <input type=text size=25 name=client${val}_passwd value='$passwd' ";
|
||||
print "<td><input type=text size=25 name=client${val}_passwd value='$passwd' ";
|
||||
print " onChange='form.submit()'" unless $val eq "_add";
|
||||
print " title='client password'";
|
||||
#print " disabled" unless $val eq "_add";
|
||||
|
@ -439,18 +443,25 @@ sub print_vpn_clients()
|
|||
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> $fullnet";
|
||||
print "<td rowspan='2' class='tun_client_center_item'> $fullnet";
|
||||
print "<input type=hidden name=client${val}_netip value='$fullnet'/></td>";
|
||||
print "<td align=center> ";
|
||||
print "<td rowspan='2' class='tun_client_center_item' align=center> ";
|
||||
if (&is_tunnel_active($fullnet,@active_tun) && ($val ne "_add")) {
|
||||
print "<img class='tun_client_active_img' src='/connected.png' title='Connected' />";
|
||||
} else {
|
||||
print "<img class='tun_client_inactive_img' src='/disconnected.png' title='Not connected' />";
|
||||
}
|
||||
print "</td>";
|
||||
print "<td><input type=submit name=client_add value=Add title='Add this client'>" if($val eq "_add");
|
||||
print "<td rowspan='2' class='tun_client_center_item'><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$passwd%0D%0ANetwork:%20$fullnet%0D%0AServer%20address:%20$dns'><img class='tun_client_mailto_img' src='/email.png' title='Email details' /></a></td>" unless($val eq "_add");
|
||||
print "<td rowspan='2' class='tun_client_center_item tun_client_mailto'><a href='mailto:?subject=AREDN%20Tunnel%20Connection&body=Your%20connection%20details:%0D%0AName:%20$name%0D%0APassword:%20$passwd%0D%0ANetwork:%20$fullnet%0D%0AServer%20address:%20$dns'><img class='tun_client_mailto_img' src='/email.png' title='Email details' /></a></td>" unless($val eq "_add");
|
||||
|
||||
#contact info for the tunnel
|
||||
print "</tr>";
|
||||
print "<tr class='tun_client_list1 tun_client_row tun_loading_css_comment'><td colspan='2' align='right'>Contact Info/Comment (Optional): <input type=text maxlength='50' size=40 name=client${val}_contact value='$contact'";
|
||||
print " onChange='form.submit()'" unless ($val eq "_add" || $val eq "");
|
||||
print " title='client contact info'></td>";
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
# display any errors
|
||||
|
@ -480,10 +491,11 @@ sub get_client_info()
|
|||
{
|
||||
my $myclient={};
|
||||
$myclient=&uci_get_named_section("vtun",$_);
|
||||
foreach $var (qw(enabled name passwd netip))
|
||||
foreach $var (qw(enabled name passwd netip contact))
|
||||
{
|
||||
$parms{"client${c}_$var"} = $myclient->{$var};
|
||||
$parms{"client${c}_$var"} = "0" if($parms{"client${c}_$var"} eq "");
|
||||
$myclient->{$var} = "";
|
||||
}
|
||||
$c++;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,10 @@ sub save_connections()
|
|||
$rc=&uci_set_named_option("vtun","server_$i","node",$vtun_node_name);
|
||||
push(@conn_err,"Problem saving UCI vtun connection name (#$i)") if $rc;
|
||||
|
||||
foreach $var (qw(enabled host passwd netip))
|
||||
$rc=&uci_set_named_option("vtun","server_$i","contact",$contact);
|
||||
push(@conn_err,"Problem saving UCI vtun contact info (#$i)") if $rc;
|
||||
|
||||
foreach $var (qw(enabled host passwd netip contact))
|
||||
{
|
||||
$rc=&uci_set_named_option("vtun","server_$i",$var,$parms{"conn${i}_$var"});
|
||||
push(@conn_err,"Problem saving UCI vtun connection (#$i)") if $rc;
|
||||
|
@ -137,7 +140,7 @@ if($parms{button_reset} or not $parms{reload})
|
|||
&get_connection_info();
|
||||
|
||||
# initialize the "add" entries to clear them
|
||||
foreach $var (qw(enabled host passwd netip))
|
||||
foreach $var (qw(enabled host passwd netip contact))
|
||||
{
|
||||
$varname = "conn${val}_$var";
|
||||
$parms{$varname} = "";
|
||||
|
@ -155,7 +158,7 @@ $conn_num = 0;
|
|||
|
||||
foreach $val (@list)
|
||||
{
|
||||
foreach $var (qw(enabled host passwd netip))
|
||||
foreach $var (qw(enabled host passwd netip contact))
|
||||
{
|
||||
$varname = "conn${val}_$var";
|
||||
$parms{$varname} = "0" if($val eq "enabled" and $parms{$varname} eq "");
|
||||
|
@ -174,7 +177,7 @@ foreach $val (@list)
|
|||
|
||||
|
||||
# Validate ADDed values
|
||||
if($val eq "_add") { next unless ($enabled or $host or $passwd or $netip) and ($parms{conn_add} or $parms{button_save}) }
|
||||
if($val eq "_add") { next unless ($enabled or $host or $passwd or $netip or $contact) and ($parms{conn_add} or $parms{button_save}) }
|
||||
else { next if $parms{"conn${val}_del"} }
|
||||
|
||||
# Validate password is vtun compliant
|
||||
|
@ -198,6 +201,7 @@ foreach $val (@list)
|
|||
$parms{"conn${conn_num}_host"} = $host;
|
||||
$parms{"conn${conn_num}_passwd"} = $passwd;
|
||||
$parms{"conn${conn_num}_netip"} = $netip;
|
||||
$parms{"conn${conn_num}_contact"} = $contact;
|
||||
|
||||
# Commit the data for this connection
|
||||
$conn_num++;
|
||||
|
@ -205,7 +209,7 @@ foreach $val (@list)
|
|||
# Clear out the ADD values
|
||||
if($val eq "_add")
|
||||
{
|
||||
foreach $var (qw(enabled host passwd netip))
|
||||
foreach $var (qw(enabled host passwd netip contact))
|
||||
{
|
||||
$parms{"conn_add_${var}"} = "";
|
||||
}
|
||||
|
@ -359,14 +363,14 @@ sub print_vpn_connections()
|
|||
$cnum=0;
|
||||
foreach $val (@list)
|
||||
{
|
||||
foreach $var (qw(enabled host passwd netip))
|
||||
foreach $var (qw(enabled host passwd netip contact))
|
||||
{
|
||||
eval sprintf("\$%s = \$parms{conn%s_%s}", $var, $val, $var);
|
||||
}
|
||||
|
||||
print "<tr><td height=10></td></tr>\n" if $val eq "_add" and scalar(@list) > 1;
|
||||
print "<tr>";
|
||||
print "<td>";
|
||||
print "<tr class='tun_client_list2 tun_client_row'>";
|
||||
print "<td class='tun_client_center_item' rowspan='2'>";
|
||||
|
||||
# Required to be first, so, if the checkbox is cleared, a value will still POST
|
||||
print "<input type='hidden' name='conn${val}_enabled' value='0'>" unless($val eq "_add");
|
||||
|
@ -381,31 +385,39 @@ sub print_vpn_connections()
|
|||
# print " disabled" unless $val eq "_add";
|
||||
print " title='connection name'></td>";
|
||||
|
||||
print "<td> <input type=text size=20 name=conn${val}_passwd value='$passwd' ";
|
||||
print "<td><input type=text size=20 name=conn${val}_passwd value='$passwd' ";
|
||||
print " onChange='form.submit()'" unless $val eq "_add";
|
||||
print " title='connection password'";
|
||||
#print " disabled" unless $val eq "_add";
|
||||
print "></td>";
|
||||
|
||||
print "<td> <input type=text size=14 name=conn${val}_netip value='$netip'";
|
||||
print "<td><input type=text size=14 name=conn${val}_netip value='$netip'";
|
||||
print " onChange='form.submit()'" unless $val eq "_add";
|
||||
# print " disabled" unless $val eq "_add";
|
||||
print " title='connection network'></td>";
|
||||
|
||||
print "</td>";
|
||||
print "<td> ";
|
||||
print "<td class='tun_client_center_item' rowspan='2'> ";
|
||||
if (&is_tunnel_active($netip,@active_tun) && ($val ne "_add")) {
|
||||
print "<img class='tun_client_active_img' src='/connected.png' title='Connected' />";
|
||||
} else {
|
||||
print "<img class='tun_client_inactive_img' src='/disconnected.png' title='Not connected' />" if ($val ne "_add");
|
||||
}
|
||||
print "</td>";
|
||||
print "<td> ";
|
||||
print "<td class='tun_client_center_item' rowspan='2'> ";
|
||||
|
||||
print "<input type=submit name=";
|
||||
if($val eq "_add") { print "conn_add value=Add title='Add this connection'" }
|
||||
else { print "conn${val}_del value=Del title='Delete this connection'" }
|
||||
print "></td></tr>\n";
|
||||
|
||||
print "></td>";
|
||||
#contact info for this tunnel
|
||||
print "</tr>\n";
|
||||
print "<tr class='tun_client_list1 tun_client_row tun_loading_css_comment'><td colspan='3' align='right'>Contact Info/Comment (Optional): <input type=text maxlength='50' size=40 name=conn${val}_contact value='$contact'";
|
||||
print " onChange='form.submit()'" unless ($val eq "_add" || $val eq "");
|
||||
print " title='client contact info'></td>";
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
# display any errors
|
||||
while(@conn_err and $conn_err[0] =~ /^$val /)
|
||||
|
@ -435,10 +447,11 @@ sub get_connection_info()
|
|||
{
|
||||
my $myconn={};
|
||||
$myconn=&uci_get_named_section("vtun",$_);
|
||||
foreach $var (qw(enabled host passwd netip))
|
||||
foreach $var (qw(enabled host passwd netip contact))
|
||||
{
|
||||
$parms{"conn${c}_$var"} = $myconn->{$var};
|
||||
$parms{"conn${c}_$var"} = "0" if($parms{"conn${c}_$var"} eq "");
|
||||
$myconn->{$var} = "";
|
||||
}
|
||||
$c++;
|
||||
}
|
||||
|
|
|
@ -80,3 +80,27 @@ background-color: whitesmoke;
|
|||
font-size: 12pt;
|
||||
width: 40%;
|
||||
}
|
||||
/* Tunnel Page Classes */
|
||||
.tun_network_row td {
|
||||
padding: 5px;
|
||||
border: solid 1px black;
|
||||
border-radius: 10px;
|
||||
background-color: rgb(108,231,232);
|
||||
}
|
||||
.tun_client_row td {
|
||||
padding: 2px;
|
||||
}
|
||||
.tun_client_list1:nth-child(odd) {
|
||||
background: rgba(192,192,192,0.5)
|
||||
}
|
||||
.tun_client_list2:nth-child(even) {
|
||||
background: rgba(192,192,192,0.5)
|
||||
}
|
||||
.tun_client_center_item {
|
||||
vertical-align:middle;
|
||||
text-align:center;
|
||||
}
|
||||
.tun_loading_css_comment {
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,27 @@ body table {
|
|||
.AREDNLogo { background: white; position:absolute; left:10%; width:175; height:95; }
|
||||
.PartOfAREDN { font-family:Verdana; font-size:xx-small; text-align:center; }
|
||||
|
||||
/* Tunnel Page Classes */
|
||||
.tun_network_row td {
|
||||
padding: 5px;
|
||||
border: solid 1px black;
|
||||
border-radius: 10px;
|
||||
background-color: rgb(108,231,232);
|
||||
}
|
||||
.tun_client_row td {
|
||||
padding: 2px;
|
||||
}
|
||||
.tun_client_list1:nth-child(odd) {
|
||||
background: rgba(64,64,64,0.5);
|
||||
}
|
||||
.tun_client_list2:nth-child(even) {
|
||||
background: rgba(64,64,64,0.5);
|
||||
}
|
||||
.tun_client_center_item {
|
||||
vertical-align:middle;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#node_description_entry {
|
||||
vertical-align: middle;
|
||||
resize: none;
|
||||
|
|
|
@ -33,6 +33,29 @@ body table {
|
|||
.AREDNLogo { background: white; position:absolute; left:10%; width:175; height:95; }
|
||||
.PartOfAREDN { font-family:Verdana; font-size:xx-small; text-align:center; }
|
||||
|
||||
/* Tunnel Page Classes */
|
||||
.tun_network_row td {
|
||||
padding: 5px;
|
||||
border: solid 1px black;
|
||||
border-radius: 10px;
|
||||
background-color: rgb(108,231,232);
|
||||
}
|
||||
.tun_client_row td {
|
||||
padding: 2px;
|
||||
}
|
||||
.tun_client_list1:nth-child(odd) {
|
||||
/* background: #f2f2f2; */
|
||||
background: rgba(64,64,64,0.5);
|
||||
}
|
||||
.tun_client_list2:nth-child(even) {
|
||||
/* background: #f2f2f2; */
|
||||
background: rgba(64,64,64,0.5);
|
||||
}
|
||||
.tun_client_center_item {
|
||||
vertical-align:middle;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#node_description_entry {
|
||||
vertical-align: middle;
|
||||
resize: none;
|
||||
|
|
|
@ -33,6 +33,27 @@ body table {
|
|||
.AREDNLogo { background: white; position:absolute; left:10%; width:175; height:95; }
|
||||
.PartOfAREDN { font-family:Verdana; font-size:xx-small; text-align:center; }
|
||||
|
||||
/* Tunnel Page Classes */
|
||||
.tun_network_row td {
|
||||
padding: 5px;
|
||||
border: solid 1px black;
|
||||
border-radius: 10px;
|
||||
background-color: rgb(108,231,232);
|
||||
}
|
||||
.tun_client_row td {
|
||||
padding: 2px;
|
||||
}
|
||||
.tun_client_list1:nth-child(odd) {
|
||||
background: rgba(64,64,64,0.5)
|
||||
}
|
||||
.tun_client_list2:nth-child(even) {
|
||||
background: rgba(64,64,64,0.5)
|
||||
}
|
||||
.tun_client_center_item {
|
||||
vertical-align:middle;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#node_description_entry {
|
||||
vertical-align: middle;
|
||||
resize: none;
|
||||
|
|
Loading…
Reference in New Issue