mirror of
https://github.com/duncs/clusterssh.git
synced 2025-07-02 01:21:14 +00:00
Get the hostname reolution code working again
Fix option -A (use_all_a_records)
This commit is contained in:
parent
4fdfb00f9f
commit
be0ff95430
3 changed files with 46 additions and 29 deletions
|
@ -534,10 +534,8 @@ sub get_clusters() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub resolve_names(@) {
|
sub resolve_names(@) {
|
||||||
my %config;
|
my ( $self, @servers ) = @_;
|
||||||
warn 'TODO: rework resolve code';
|
|
||||||
logmsg( 2, 'Resolving cluster names: started' );
|
logmsg( 2, 'Resolving cluster names: started' );
|
||||||
my @servers = @_;
|
|
||||||
|
|
||||||
foreach (@servers) {
|
foreach (@servers) {
|
||||||
my $dirty = $_;
|
my $dirty = $_;
|
||||||
|
@ -547,7 +545,7 @@ sub resolve_names(@) {
|
||||||
if ( $dirty =~ s/^(.*)@// ) {
|
if ( $dirty =~ s/^(.*)@// ) {
|
||||||
$username = $1;
|
$username = $1;
|
||||||
}
|
}
|
||||||
if ( $config{use_all_a_records}
|
if ( $self->config->{use_all_a_records}
|
||||||
&& $dirty !~ m/^(\d{1,3}\.?){4}$/
|
&& $dirty !~ m/^(\d{1,3}\.?){4}$/
|
||||||
&& !defined( $clusters{$dirty} ) )
|
&& !defined( $clusters{$dirty} ) )
|
||||||
{
|
{
|
||||||
|
@ -991,7 +989,8 @@ sub retile_hosts {
|
||||||
my %config;
|
my %config;
|
||||||
|
|
||||||
if ( $self->config->{window_tiling} ne "yes" && !$force ) {
|
if ( $self->config->{window_tiling} ne "yes" && !$force ) {
|
||||||
logmsg( 3, "Not meant to be tiling; just reshow windows as they were" );
|
logmsg( 3,
|
||||||
|
"Not meant to be tiling; just reshow windows as they were" );
|
||||||
|
|
||||||
foreach my $server ( reverse( keys(%servers) ) ) {
|
foreach my $server ( reverse( keys(%servers) ) ) {
|
||||||
$xdisplay->req( 'MapWindow', $servers{$server}{wid} );
|
$xdisplay->req( 'MapWindow', $servers{$server}{wid} );
|
||||||
|
@ -1016,13 +1015,15 @@ sub retile_hosts {
|
||||||
$self->config->{internal_terminal_cols}
|
$self->config->{internal_terminal_cols}
|
||||||
= ( $self->config->{terminal_size} =~ /(\d+)x.*/ )[0];
|
= ( $self->config->{terminal_size} =~ /(\d+)x.*/ )[0];
|
||||||
$self->config->{internal_terminal_width}
|
$self->config->{internal_terminal_width}
|
||||||
= ( $self->config->{internal_terminal_cols} * $self->config->{internal_font_width} )
|
= ( $self->config->{internal_terminal_cols}
|
||||||
|
* $self->config->{internal_font_width} )
|
||||||
+ $self->config->{terminal_decoration_width};
|
+ $self->config->{terminal_decoration_width};
|
||||||
|
|
||||||
$self->config->{internal_terminal_rows}
|
$self->config->{internal_terminal_rows}
|
||||||
= ( $self->config->{terminal_size} =~ /.*x(\d+)/ )[0];
|
= ( $self->config->{terminal_size} =~ /.*x(\d+)/ )[0];
|
||||||
$self->config->{internal_terminal_height}
|
$self->config->{internal_terminal_height}
|
||||||
= ( $self->config->{internal_terminal_rows} * $self->config->{internal_font_height} )
|
= ( $self->config->{internal_terminal_rows}
|
||||||
|
* $self->config->{internal_font_height} )
|
||||||
+ $self->config->{terminal_decoration_height};
|
+ $self->config->{terminal_decoration_height};
|
||||||
|
|
||||||
# fetch screen size
|
# fetch screen size
|
||||||
|
@ -1043,7 +1044,10 @@ sub retile_hosts {
|
||||||
|
|
||||||
# Work out the number of rows we need to use to fit everything on screen
|
# Work out the number of rows we need to use to fit everything on screen
|
||||||
$self->config->{internal_rows} = int(
|
$self->config->{internal_rows} = int(
|
||||||
( $self->config->{internal_total} / $self->config->{internal_columns} ) + 0.999 );
|
( $self->config->{internal_total}
|
||||||
|
/ $self->config->{internal_columns}
|
||||||
|
) + 0.999
|
||||||
|
);
|
||||||
|
|
||||||
logmsg( 2, "Screen Columns: ", $self->config->{internal_columns} );
|
logmsg( 2, "Screen Columns: ", $self->config->{internal_columns} );
|
||||||
logmsg( 2, "Screen Rows: ", $self->config->{internal_rows} );
|
logmsg( 2, "Screen Rows: ", $self->config->{internal_rows} );
|
||||||
|
@ -1081,10 +1085,10 @@ sub retile_hosts {
|
||||||
if ( $self->config->{window_tiling_direction} =~ /right/i ) {
|
if ( $self->config->{window_tiling_direction} =~ /right/i ) {
|
||||||
logmsg( 2, "Tiling top left going bot right" );
|
logmsg( 2, "Tiling top left going bot right" );
|
||||||
@hosts = sort( keys(%servers) );
|
@hosts = sort( keys(%servers) );
|
||||||
$current_x
|
$current_x = $self->config->{screen_reserve_left}
|
||||||
= $self->config->{screen_reserve_left} + $self->config->{terminal_reserve_left};
|
+ $self->config->{terminal_reserve_left};
|
||||||
$current_y
|
$current_y = $self->config->{screen_reserve_top}
|
||||||
= $self->config->{screen_reserve_top} + $self->config->{terminal_reserve_top};
|
+ $self->config->{terminal_reserve_top};
|
||||||
$current_row = 0;
|
$current_row = 0;
|
||||||
$current_col = 0;
|
$current_col = 0;
|
||||||
}
|
}
|
||||||
|
@ -1123,7 +1127,8 @@ sub retile_hosts {
|
||||||
logmsg( 2, "Moving $server window" );
|
logmsg( 2, "Moving $server window" );
|
||||||
send_resizemove(
|
send_resizemove(
|
||||||
$servers{$server}{wid},
|
$servers{$server}{wid},
|
||||||
$current_x, $current_y,
|
$current_x,
|
||||||
|
$current_y,
|
||||||
$self->config->{internal_terminal_width},
|
$self->config->{internal_terminal_width},
|
||||||
$self->config->{internal_terminal_height}
|
$self->config->{internal_terminal_height}
|
||||||
);
|
);
|
||||||
|
@ -1291,7 +1296,8 @@ sub add_host_by_name() {
|
||||||
|
|
||||||
if ( $menus{host_entry} ) {
|
if ( $menus{host_entry} ) {
|
||||||
logmsg( 2, "host=", $menus{host_entry} );
|
logmsg( 2, "host=", $menus{host_entry} );
|
||||||
my @names = resolve_names( split( /\s+/, $menus{host_entry} ) );
|
my @names
|
||||||
|
= $self->resolve_names( split( /\s+/, $menus{host_entry} ) );
|
||||||
logmsg( 0, 'Opening to: ', join( ' ', @names ) );
|
logmsg( 0, 'Opening to: ', join( ' ', @names ) );
|
||||||
open_client_windows(@names);
|
open_client_windows(@names);
|
||||||
}
|
}
|
||||||
|
@ -1299,7 +1305,7 @@ sub add_host_by_name() {
|
||||||
if ( $menus{listbox}->curselection() ) {
|
if ( $menus{listbox}->curselection() ) {
|
||||||
my @hosts = $menus{listbox}->get( $menus{listbox}->curselection() );
|
my @hosts = $menus{listbox}->get( $menus{listbox}->curselection() );
|
||||||
logmsg( 2, "host=", join( ' ', @hosts ) );
|
logmsg( 2, "host=", join( ' ', @hosts ) );
|
||||||
open_client_windows( resolve_names(@hosts) );
|
open_client_windows( $self->resolve_names(@hosts) );
|
||||||
}
|
}
|
||||||
|
|
||||||
build_hosts_menu();
|
build_hosts_menu();
|
||||||
|
@ -1951,6 +1957,11 @@ sub run {
|
||||||
|
|
||||||
$self->config->load_configs( $options{'config-file'} );
|
$self->config->load_configs( $options{'config-file'} );
|
||||||
|
|
||||||
|
if ( $options{use_all_a_records} ) {
|
||||||
|
$self->config->{use_all_a_records}
|
||||||
|
= !$self->config->{use_all_a_records} || 0;
|
||||||
|
}
|
||||||
|
|
||||||
$self->config->dump() if ( $options{'output-config'} );
|
$self->config->dump() if ( $options{'output-config'} );
|
||||||
|
|
||||||
$self->evaluate_commands() if ( $options{evaluate} );
|
$self->evaluate_commands() if ( $options{evaluate} );
|
||||||
|
@ -1964,11 +1975,12 @@ sub run {
|
||||||
list_tags() if ( $options{'list'} );
|
list_tags() if ( $options{'list'} );
|
||||||
|
|
||||||
if (@ARGV) {
|
if (@ARGV) {
|
||||||
@servers = resolve_names(@ARGV);
|
@servers = $self->resolve_names(@ARGV);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( $clusters{default} ) {
|
if ( $clusters{default} ) {
|
||||||
@servers = resolve_names( split( /\s+/, $clusters{default} ) );
|
@servers
|
||||||
|
= $self->resolve_names( split( /\s+/, $clusters{default} ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,8 @@ my %default_config = (
|
||||||
menu_send_autotearoff => 0,
|
menu_send_autotearoff => 0,
|
||||||
menu_host_autotearoff => 0,
|
menu_host_autotearoff => 0,
|
||||||
|
|
||||||
|
use_all_a_records => 0,
|
||||||
|
|
||||||
send_menu_xml_file => $ENV{HOME} . '/.csshrc_send_menu',
|
send_menu_xml_file => $ENV{HOME} . '/.csshrc_send_menu',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,8 @@ Readonly::Hash my %default_config => {
|
||||||
menu_send_autotearoff => 0,
|
menu_send_autotearoff => 0,
|
||||||
menu_host_autotearoff => 0,
|
menu_host_autotearoff => 0,
|
||||||
|
|
||||||
|
use_all_a_records => 0,
|
||||||
|
|
||||||
send_menu_xml_file => $ENV{HOME} . '/.csshrc_send_menu',
|
send_menu_xml_file => $ENV{HOME} . '/.csshrc_send_menu',
|
||||||
|
|
||||||
# other bits inheritted from App::ClusterSSH::Base
|
# other bits inheritted from App::ClusterSSH::Base
|
||||||
|
@ -477,6 +479,7 @@ terminal_reserve_top=5
|
||||||
terminal_size=80x24
|
terminal_size=80x24
|
||||||
terminal_title_opt=-T
|
terminal_title_opt=-T
|
||||||
unmap_on_redraw=no
|
unmap_on_redraw=no
|
||||||
|
use_all_a_records=0
|
||||||
use_hotkeys=yes
|
use_hotkeys=yes
|
||||||
window_tiling=yes
|
window_tiling=yes
|
||||||
window_tiling_direction=right
|
window_tiling_direction=right
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue