Added '--use_all_a_records'

If a hostname resolves to multiple IP addresses, allow to connect
to all of them, not just the first one found.

Thanks to Simon Fraser
This commit is contained in:
Duncan Ferguson 2010-09-10 16:00:01 +01:00
parent 198c8bc2ab
commit bb9237d888
4 changed files with 36 additions and 0 deletions

View file

@ -2,6 +2,7 @@
* Fix test error on 5.8.8 (reported by Wei Wang)
* Added '--list', '-L' to list available cluster tags (idea from Markus Manzke)
* Fix terminal size only set on last windows (Sf bug 3061999)
* Added '--use_all_a_records' (Simon Fraser)
2010-06-20 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.00_05

1
THANKS
View file

@ -36,3 +36,4 @@ Ian Marsh
Roland Rosenfeld
Wei Wang
Markus Manzke
Simon Fraser

View file

@ -208,6 +208,11 @@ Enable|Disable window tiling (overriding the config file)
Specify the initial part of the title used in the console and client windows
=item --use_all_a_records,-A
If a hostname resolves to multiple IP addresses, toggle whether or not to
connect to all of them, or just the first one (see also config file entry)
=item --username,-l $LOGNAME
Specify the default username to use for connections (if different from the
@ -539,6 +544,11 @@ This defaults to "no" as it causes some problems with the FVWM window
manager. If you are experiencing problems with redraws, you can set it to
"yes" to allow the window to be unmapped before it is repositioned.
=item use_all_a_records = no
If a hostname resolves to multiple IP addresses, set to C<yes> to connect
to all of them, not just the first one found.
=item use_hotkeys = yes
Setting to anything other than C<yes> will disable all hotkeys.

View file

@ -32,6 +32,7 @@ use Net::hostent;
use Carp;
use Sys::Hostname;
use English;
use Socket;
# Notes on general order of processing
#
@ -88,6 +89,7 @@ my @options_spec = (
'output-config|u',
'font|f=s',
'list|L',
'use_all_a_records|A',
);
my %options;
my %config;
@ -249,6 +251,8 @@ sub load_config_defaults() {
$config{menu_host_autotearoff} = 0;
$config{send_menu_xml_file} = $ENV{HOME} . '/.csshrc_send_menu';
$config{use_all_a_records} = 0;
}
# load in config file settings
@ -387,6 +391,10 @@ sub check_config() {
$config{show_history} = 1 if $options{'show-history'};
$config{command} = $options{action} if ( $options{action} );
if ( $options{use_all_a_records} ) {
$config{use_all_a_records} = !$config{use_all_a_records} || 0;
}
}
sub load_configfile() {
@ -705,6 +713,22 @@ sub resolve_names(@) {
if ( $dirty =~ s/^(.*)@// ) {
$username = $1;
}
if ( $config{use_all_a_records}
&& $dirty !~ m/^(\d{1,3}\.?){4}$/
&& !defined( $clusters{$dirty} ) )
{
my $hostobj = gethostbyname($dirty);
if ( defined($hostobj) ) {
my @alladdrs = map { inet_ntoa($_) } @{ $hostobj->addr_list };
if ( $#alladdrs > 0 ) {
$clusters{$dirty} = join ' ', @alladdrs;
logmsg( 3, 'Expanded to ', $clusters{$dirty} );
}
else {
logmsg( 3, 'Only one A record' );
}
}
}
if ( $clusters{$dirty} ) {
logmsg( 3, '... it is a cluster' );
foreach my $node ( split( / /, $clusters{$dirty} ) ) {