* Adding support of network routing to config page2.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent 30f87cd7c4
commit 65636100c6
  1. 107
      cgi-bin/home
  2. 6
      cgi-bin/words.xml
  3. 14
      html/skins/alteeve/main.html

@ -129,6 +129,7 @@ sub config_step2
my $problem = 0;
my $interface_form = "";
my $cgi = "";
my $links = [];
if ($interface_count >= $required_interfaces_for_bonds)
{
### Show the bonded ifaces form.
@ -136,6 +137,7 @@ sub config_step2
my $bcn_count = $an->data->{cgi}{bcn_count}{value} ? $an->data->{cgi}{bcn_count}{value} : 1;
foreach my $bcn (1..$bcn_count)
{
push @{$links}, "bcn_link".$bcn;
my $this_bcn_key = "bcn".$bcn;
my $this_ip_key = "bcn".$bcn."_ip";
my $this_subnet_key = "bcn".$bcn."_subnet";
@ -182,6 +184,7 @@ sub config_step2
my $ifn_count = $an->data->{cgi}{ifn_count}{value} ? $an->data->{cgi}{ifn_count}{value} : 1;
foreach my $ifn (1..$ifn_count)
{
push @{$links}, "ifn_link".$bcn;
my $this_ifn_key = "ifn".$ifn;
my $this_ip_key = "ifn".$ifn."_ip";
my $this_subnet_key = "ifn".$ifn."_subnet";
@ -230,6 +233,48 @@ sub config_step2
### Show the single iface per network form.
}
### TODO: Add a form for Gateway, DNS and which interface to use
# Gateway
my $say_default_gateway = "";
my $gateway_class = $an->data->{cgi}{gateway}{alert} ? "input_alert" : "input_clear";
my $say_gateway = $an->Template->get({file => "main.html", name => "input_text_form", variables => {
name => "gateway",
id => "gateway",
field => "#!string!striker_0035!#",
description => "#!string!striker_0036!#",
value => defined $an->data->{cgi}{gateway}{value} ? $an->data->{cgi}{gateway}{value} : $say_default_gateway,
class => $gateway_class,
extra => "",
}});
# DNS
my $dns_class = $an->data->{cgi}{dns}{alert} ? "input_alert" : "input_clear";
my $say_dns = $an->Template->get({file => "main.html", name => "input_text_form", variables => {
name => "dns",
id => "dns",
field => "#!string!striker_0037!#",
description => "#!string!striker_0038!#",
value => defined $an->data->{cgi}{dns}{value} ? $an->data->{cgi}{dns}{value} : "8.8.8.8, 8.8.4.4",
class => $dns_class,
extra => "",
}});
# Which interface gets the route?
my $default_dg_iface = defined $an->data->{cgi}{dg_iface}{value} ? $an->data->{cgi}{dg_iface}{value} : "ifn_link1";
my $dg_iface_select = $an->Template->select_form({
name => "dg_iface",
options => $links,
blank => 0,
selected => $default_dg_iface,
class => $an->data->{cgi}{dg_iface}{alert} ? "input_alert" : "input_clear",
});
my $dg_iface_class = $an->data->{cgi}{dg_iface}{alert} ? "input_alert" : "input_clear";
my $say_dg_iface = $an->Template->get({file => "main.html", name => "input_select_form", variables => {
field => "#!string!striker_0039!#",
description => "#!string!striker_0040!#",
'select' => "",
}});
# Hostname
my $say_default_hostname = $an->data->{cgi}{prefix}{value}."-striker0".$an->data->{cgi}{sequence}{value}.".".$an->data->{cgi}{domain}{value};
my $hostname_class = $an->data->{cgi}{hostname}{alert} ? "input_alert" : "input_clear";
@ -285,14 +330,74 @@ sub config_step2
interface_states => $interface_states,
striker_user_form => $say_striker_user,
striker_password_form => $say_striker_password,
gateway_form => $say_gateway,
dns_form => $say_dns,
hostname_form => $say_hostname,
cgi_list => $cgi."hostname,striker_user,striker_password",
cgi_list => $cgi."gateway,hostname,striker_user,striker_password",
}});
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { step2_body => $step2_body }});
return($step2_body);
}
# This sanity-checks step 2 and returns '1' if there was a problem.
sub sanity_check_step2
{
my ($an) = @_;
# This will flip if we run into a problem. We start by running through step1's sanity checks again.
# This should only fail is someone was passing raw data to us and screwed something up.
my $sane = sanity_check_step1($an);
# Do we have a host name, striker user and password?
if ((not defined $an->data->{cgi}{hostname}{value}) or (not $an->data->{cgi}{hostname}{value}))
{
$an->data->{cgi}{hostname}{alert} = 1;
$sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::hostname::alert" => $an->data->{cgi}{hostname}{alert} }});
}
if ((not defined $an->data->{cgi}{striker_user}{value}) or (not $an->data->{cgi}{striker_user}{value}))
{
$an->data->{cgi}{striker_user}{alert} = 1;
$sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::striker_user::alert" => $an->data->{cgi}{striker_user}{alert} }});
}
if ((not defined $an->data->{cgi}{striker_password}{value}) or (not $an->data->{cgi}{striker_password}{value}))
{
$an->data->{cgi}{striker_password}{alert} = 1;
$sane = 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane, "cgi::striker_password::alert" => $an->data->{cgi}{striker_password}{alert} }});
}
# Now it gets a bit tricker as we'll need to loop through the BCNs and IFNs.
my $bcn_count = $an->data->{cgi}{bcn_count}{value} ? $an->data->{cgi}{bcn_count}{value} : 1;
foreach my $bcn (1..$bcn_count)
{
my $this_bcn_key = "bcn".$bcn;
my $this_ip_key = "bcn".$bcn."_ip";
my $this_subnet_key = "bcn".$bcn."_subnet";
my $this_iface1_key = "bcn".$bcn."_iface1_mac";
my $this_iface2_key = "bcn".$bcn."_iface2_mac";
# If I only have the iface1, we'll create a non-bonded interface (even if the option for a
# bond was presented to the user). So to be sane, we need a valid IP, subnet
}
my $ifn_count = $an->data->{cgi}{ifn_count}{value} ? $an->data->{cgi}{ifn_count}{value} : 1;
foreach my $ifn (1..$ifn_count)
{
my $this_ifn_key = "ifn".$ifn;
my $this_ip_key = "ifn".$ifn."_ip";
my $this_subnet_key = "ifn".$ifn."_subnet";
my $this_iface1_key = "ifn".$ifn."_iface1_mac";
my $this_iface2_key = "ifn".$ifn."_iface2_mac";
}
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { sane => $sane }});
return($sane);
}
# This sanity-checks step 1 and returns '1' if there was a problem.
sub sanity_check_step1
{

@ -61,6 +61,12 @@ This is the AN::Tools master 'words' file.
<key name="striker_0032">This is the user name that you will log into Striker as and the name of the user that owns the database.</key>
<key name="striker_0033">Striker password</key>
<key name="striker_0034"><![CDATA[This will be the password used to log into this Striker and connect to its database.<br /><b>NOTE</b>: This password needs to be stored in plain text. Do not use a password you use elsewhere.]]></key>
<key name="striker_0035">Gateway</key>
<key name="striker_0036">This is the network gateway used to access the outside world.</key>
<key name="striker_0037">DNS</key>
<key name="striker_0038">This is the domain name server(s) to use when resolving domain names. You can specify 2 or more, separated by commas.</key>
<key name="striker_0039">Gateway Interface</key>
<key name="striker_0040">This is the interface with the internet access. Usually this is "ifn_link1".</key> <!-- Translation note; leave 'ifn_link1' as it is, it is the device name. -->
<!-- Errors -->
<key name="striker_error_0001">There are not enough network interfaces on this machine. You have: [#!variable!interface_count!#] interface(s), and you need at least: [#!variable!required_interfaces_for_single!#] interfaces to connect to the requested networks (one for Back-Channel and one for each Internet-Facing network).</key>

@ -100,6 +100,16 @@
</tr>
<tr>
<td>
#!variable!gateway_form!#
</td>
</tr>
<tr>
<td>
#!variable!dns_form!#
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
@ -206,12 +216,12 @@
<!-- end select_form -->
<!-- start input_text_form -->
<span id="description_id">#!variable!description!#</span><br />
#!variable!description!#<br />
<input type="text" name="#!variable!name!#" id="#!variable!id!#" value="#!variable!value!#" placeholder="#!variable!field!#" class="#!variable!class!#" #!variable!extra!#>
<!-- end input_text_form -->
<!-- start input_number_form -->
<span id="description_id">#!variable!description!#</span><br />
#!variable!description!#<br />
<input type="number" name="#!variable!name!#" id="#!variable!id!#" value="#!variable!value!#" placeholder="#!variable!field!#" class="#!variable!class!#" #!variable!extra!#>
<!-- end input_number_form -->

Loading…
Cancel
Save