* Added a check/cycle to Remote->call that checks to see if the channel was established and loops up to five times, with a second delay in each try. Also disable the Time::HiRes stuff in this method for now.

* Fixed a bug where "form::error_massage" was default to ' ' which caused simple checks to thing there was an error when all was fine.
* Got the "add new sync peer" form confirmation box displaying and cleaned up the CSS a bit.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 1f8c27ccfb
commit a364141d81
  1. 63
      Anvil/Tools/Remote.pm
  2. 15
      cgi-bin/home
  3. 16
      html/skins/alteeve/main.css
  4. 102
      html/skins/alteeve/striker.html
  5. 2
      share/words.xml

@ -404,18 +404,22 @@ sub call
if ($ssh_fh !~ /^Net::SSH2/)
{
use Time::HiRes qw (usleep ualarm gettimeofday tv_interval nanosleep
clock_gettime clock_getres clock_nanosleep clock
stat);
# use Time::HiRes qw (usleep ualarm gettimeofday tv_interval nanosleep
# clock_gettime clock_getres clock_nanosleep clock
# stat);
### NOTE: Nevermind, timeout isn't supported... >_< Find a newer version if IO::Socket::IP?
### TODO: Make the timeout user-configurable to handle slow connections. Make it
### 'sys::timeout::{all|host} = x'
my $start_time = [gettimeofday];
# my $start_time = [gettimeofday];
$ssh_fh = Net::SSH2->new(timeout => 1000);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
ssh_fh => $ssh_fh,
target => $target,
port => $port,
}});
if (not $ssh_fh->connect($target, $port))
{
my $connect_time = tv_interval ($start_time, [gettimeofday]);
# my $connect_time = tv_interval ($start_time, [gettimeofday]);
#print "[".$connect_time."] - Connection failed time to: [$target:$port]\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", list => {
@ -454,7 +458,7 @@ sub call
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => $message_key, variables => $variables});
}
my $connect_time = tv_interval ($start_time, [gettimeofday]);
# my $connect_time = tv_interval ($start_time, [gettimeofday]);
#print "[".$connect_time."] - Connect time to: [$target:$port]\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { error => $error, ssh_fh => $ssh_fh }});
@ -519,8 +523,49 @@ sub call
# We need to open a channel every time for 'exec' calls. We want to keep blocking off, but we
# need to enable it for the channel() call.
$ssh_fh->blocking(1);
my $channel = $ssh_fh->channel() or $ssh_fh->die_with_error;
$ssh_fh->blocking(0);
my $channel = $ssh_fh->channel(); # or $ssh_fh->die_with_error;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { channel => $channel }});
if (not $channel)
{
my $try = 0;
my $ok = 0;
until ($ok)
{
sleep 1;
if ($try > 5)
{
### Give up.
# If we're in a web interface, set 'form::error_massage'.
my $message = $anvil->Words->string({key => "striker_warning_0006", variables => {
target => $remote_user."\@".$target,
error => $ssh_fh->error,
} });
$error = $message;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", raw => $message});
if ($anvil->environment eq" html")
{
$anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $message }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { "form::error_massage" => $anvil->data->{form}{error_massage} }});
}
return($error, []);
}
$channel = $ssh_fh->channel(); # or $ssh_fh->die_with_error;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { channel => $channel }});
if ($channel)
{
$ok = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ok => $ok }});
}
else
{
$try++;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { try => $try }});
}
}
}
$ssh_fh->blocking(0);
# Make the shell call
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { channel => $channel }});

@ -38,7 +38,7 @@ $anvil->Storage->read_config();
### Setup some variables.
$anvil->data->{skin}{url} = $anvil->data->{path}{urls}{skins}."/".$anvil->Template->skin;
$anvil->data->{form}{body} = "";
$anvil->data->{form}{error_massage} = "&nbsp;";
$anvil->data->{form}{error_massage} = "";
$anvil->data->{form}{back_link} = "";
$anvil->data->{form}{refresh_link} = "";
@ -148,7 +148,7 @@ sub print_and_exit
my $body = $anvil->Template->get({debug => 3, file => "main.html", name => "master", variables => {
header => $header,
skin_url => $anvil->data->{path}{urls}{skins}."/".$anvil->Template->skin,
center_top_bar => $anvil->data->{form}{error_massage},
center_top_bar => $anvil->data->{form}{error_massage} ? $anvil->data->{form}{error_massage} : "&nbsp;",
right_top_bar => $right_buttons,
left_top_bar => $left_buttons,
center_body => $anvil->data->{form}{body},
@ -538,10 +538,11 @@ sub add_sync_peer
$password =~ s/:/\:/g;
my $body = $host.":".$port.":".$name.":".$user.":".$password;
$anvil->Storage->write_file({
file => $pgpass_file,
body => $body,
mode => "0600",
secure => 1,
file => $pgpass_file,
body => $body,
mode => "0600",
secure => 1,
overwrite => 1,
});
# This will return '1' only, if it works.
@ -554,7 +555,7 @@ sub add_sync_peer
}
# Delete the pgpass file.
#unlink $pgpass_file;
unlink $pgpass_file;
}
# If an error was set, clear the 'save' and 'confirm' values.

@ -95,6 +95,22 @@ tr.data_row {
border-top: 1px solid #5f5f5f;
}
td.button_cell {
padding: 10px 5px;
text-align: center;
}
td.top_padded_cell {
padding-top: 5px;
padding-left: 5px;
padding-right: 5px;
padding-bottom: 0px;
}
td.padded_cell {
padding: 0px 5px;
}
td.column_header {
text-align: left;
color: #9ba0a5;

@ -1,52 +1,66 @@
<!-- start confirm-new-peer -->
<table>
<form name="confirm-new-peer" action="" method="post">
<div id="confirm-new-peer">
<table align="center">
<tr>
<td colspan="2">
<td class="menu_title">
#!string!striker_0078!#
</td>
</tr>
<tr>
<td>
#!string!striker_0079!#:
</td>
<td class="fixed_width">
#!variable!access!#
<td class="menu_details">
#!string!striker_0081!#
</td>
</tr>
<tr>
<td>
#!string!striker_0080!#:
</td>
<td class="fixed_width">
#!variable!ping!#
&nbsp;
</td>
</tr>
<tr>
<td>
#!string!striker_0072!#:
</td>
<td class="fixed_width">
#!variable!bidirectional!#
<table align="center" class="data_table">
<form name="confirm-new-peer" action="" method="post">
<div id="confirm-new-peer">
<tr>
<td class="top_padded_cell">
#!string!striker_0079!#:
</td>
<td class="top_padded_cell" class="fixed_width">
#!variable!access!#
</td>
</tr>
<tr>
<td class="padded_cell">
#!string!striker_0080!#:
</td>
<td class="padded_cell" class="fixed_width">
#!variable!ping!#
</td>
</tr>
<tr>
<td class="padded_cell">
#!string!striker_0072!#:
</td>
<td class="padded_cell" class="fixed_width">
#!variable!bidirectional!#
</td>
</tr>
<tr>
<td class="button_cell" colspan="2">
<input type="submit" name="confirm" id="confirm" value="#!string!striker_0082!#">
</td>
</tr>
<input type="hidden" name="new_peer_access" id="new_peer_access" value="#!data!cgi::new_peer_access::value!#">
<input type="hidden" name="new_peer_password" id="new_peer_password" value="#!data!cgi::new_peer_password::value!#">
<input type="hidden" name="new_peer_bidirection" id="new_peer_bidirection" value="#!data!cgi::new_peer_bidirection::value!#">
<input type="hidden" name="new_peer_ping" id="new_peer_ping" value="#!data!cgi::new_peer_ping::value!#">
<input type="hidden" name="striker" id="striker" value="#!data!cgi::striker::value!#">
<input type="hidden" name="task" id="task" value="#!data!cgi::task::value!#">
<input type="hidden" name="save" id="save" value="#!data!cgi::save::value!#">
</form>
</div>
</table>
</td>
</tr>
<tr>
<td colspan="5" class="subtle_text" style="text-align: center;">
#!string!striker_0081!#
</td>
</tr>
</div>
<input type="hidden" name="new_peer_access" id="new_peer_access" value="#!data!cgi::new_peer_access::value!#">
<input type="hidden" name="new_peer_password" id="new_peer_password" value="#!data!cgi::new_peer_password::value!#">
<input type="hidden" name="new_peer_bidirection" id="new_peer_bidirection" value="#!data!cgi::new_peer_bidirection::value!#">
<input type="hidden" name="new_peer_ping" id="new_peer_ping" value="#!data!cgi::new_peer_ping::value!#">
<input type="hidden" name="striker" id="striker" value="#!data!cgi::striker::value!#">
<input type="hidden" name="task" id="task" value="#!data!cgi::task::value!#">
<input type="hidden" name="save" id="save" value="#!data!cgi::save::value!#">
<input type="hidden" name="confirm" id="confirm" value="true">
</form>
</table>
<!-- end confirm-new-peer -->
<!-- start striker-login -->
@ -205,22 +219,22 @@
#!variable!peer_table!#
</tr>
<tr>
<td style="padding: 0px 5px;">
<td class="padded_cell">
<input type="text" id="new_peer_access" name="new_peer_access" placeholder="#!string!striker_0069!#" value="#!variable!new_peer_access!#" readonly onfocus="this.removeAttribute('readonly');" />
</td>
<td style="padding: 0px 5px;">
<td class="padded_cell">
<!-- To prevent browsers from offering to save the user/password, we'll set the password to a text field and use css to obfuscate echoing back what the user typed -->
<input type="text" id="new_peer_password" name="new_peer_password" placeholder="#!string!striker_0051!#" value="#!variable!new_peer_password!#" readonly onfocus="this.removeAttribute('readonly');" style="-webkit-text-security: disc;" />
</td>
<td style="padding: 0px 5px;">
<td class="padded_cell">
#!string!striker_0071!#: <input type="checkbox" id="new_peer_ping" name="new_peer_ping" checked />
</td>
<td style="padding: 0px 5px;">
<td class="padded_cell">
#!string!striker_0072!#: <input type="checkbox" id="new_peer_bidirection" name="new_peer_bidirection" checked />
</td>
</tr>
<tr>
<td style="padding: 10px 5px;" colspan="4" align="center">
<td class="button_cell" colspan="4" align="center">
<input type="submit" id="save" name="save" value="#!string!striker_0067!#" />
</td>
</tr>
@ -271,16 +285,16 @@
<!-- start striker-sync-entry -->
<tr>
<td width="25%" style="padding: 0px 5px;">
<td width="25%" class="padded_cell">
#!variable!access!#
</td>
<td width="25%" style="padding: 0px 5px;">
<td width="25%" class="padded_cell">
#!variable!password!#
</td>
<td width="25%" style="padding: 0px 5px;">
<td width="25%" class="padded_cell">
#!string!striker_0071!# <input type="checkbox" id="#!variable!access!#_ping" name="#!variable!access!#_ping" #!variable!ping_checked!# />
</td>
<td width="25%" style="padding: 0px 5px;" align="center">
<td width="25%" class="padded_cell" align="center">
<a href="striker=true&task=sync&delete=#!variable!access!#" id="#!variable!access!#_delete" class="button">#!string!striker_0068!#"<a/>
</td>
</tr>
@ -288,10 +302,10 @@
<!-- start striker-sync-inbound -->
<tr>
<td width="25%" style="padding: 0px 5px;" class="code">
<td width="25%" class="padded_cell" class="code">
#!variable!access!#
</td>
<td width="75%" style="padding: 0px 5px;" colspan="3">
<td width="75%" class="padded_cell" colspan="3">
#!variable!note!#
</td>
</tr>

@ -406,6 +406,7 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
<key name="striker_0079">Peer</key>
<key name="striker_0080">Ping before connect</key>
<key name="striker_0081">The test connection was successful. When saved, the resynchronization process might take a few minutes, and cause maintenance periods where some features are offline until complete.</key>
<key name="striker_0082">Confirm</key>
<!-- Strings used by jobs -->
<key name="job_0001">Configure Network</key>
@ -417,6 +418,7 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
<key name="striker_warning_0003">Test access to the peer (using SSH) failed. There may be details in the log file.</key>
<key name="striker_warning_0004">Accessing the peer over SSH worked, but a test connection to the database failed.</key>
<key name="striker_warning_0005">There was a problem reading the peer's UUID. Read: [#!variable!uuid!#], which appears to be invalid.</key>
<key name="striker_warning_0006">An SSH connection was established to: [#!variable!target!#], but we failed to establish a channel. The last error was: [#!variable!error!#].</key>
<!-- Errors -->
<key name="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>

Loading…
Cancel
Save