Index: ldirectord =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord,v retrieving revision 1.34 diff -u -r1.34 ldirectord --- ldirectord 2001/07/25 06:04:50 1.34 +++ ldirectord 2001/07/25 20:52:41 @@ -15,7 +15,7 @@ =head1 SYNOPSIS -B I [B<-d>] [B<-h>] +B [B<-d>] [B<-h>] I B|B|B|B|B @@ -147,10 +147,12 @@ The following commands must follow a B entry and must be indented with a minimum of 4 spaces or one tab. -B Iip_address|hostname]:portnumber|servicename> B|B|B [I] [B<">IB<", ">IB<">] +B Iip_address|hostname][:portnumber|servicename>] B|B|B [I] [B<">IB<", ">IB<">] Defines a real service by IP-address (or hostname) and port (or -servicename). Optionally a range of IP addresses (or two hostnames) may be +servicename). If the port is omitted then a 0 will be used, this is +intended primarily for fwmark services where the port for real servers is +ignored. Optionally a range of IP addresses (or two hostnames) may be given, in which case each IP address in the range will be treated as a real server using the given port. The second argument defines the forwarding method, must be B, B or B. The thrid argument is @@ -362,7 +364,7 @@ # search for the correct configuration file if ( !defined $ARGV[0] ) { - init_error("Usage ldirectord [configfile] [-d] \{start|stop|restart|reload|status\}\nRun ldirectord -h for more information"); + init_error("Usage ldirectord [-d] [configfile] \{start|stop|restart|reload|status\}\nRun ldirectord -h for more information"); } if ( defined $ARGV[0] && defined $ARGV[1] ) { $CONFIG = $ARGV[0]; @@ -376,7 +378,7 @@ $CMD = $ARGV[0]; } if ( $CMD ne "start" && $CMD ne "stop" && $CMD ne "status" && $CMD ne "restart" && $CMD ne "reload") { - init_error("Usage ldirectord [configfile] [-d] \{start|stop|restart|reload|status\}\nType ldirectord -h for more information"); + init_error("Usage ldirectord [-d] [configfile] \{start|stop|restart|reload|status\}\nType ldirectord -h for more information"); } if ( -f "/etc/ha.d/$CONFIG" ) { $CONFIG = "/etc/ha.d/$CONFIG"; @@ -842,26 +844,42 @@ for $i (@$rsrv_todo) { ($str, $line)=@$i; - $str =~ /(\d+\.\d+\.\d+\.\d+|[A-Za-z0-9.-]+)(->(\d+\.\d+\.\d+\.\d+|[A-Za-z0-9.-]+))?:(\d+|[A-Za-z0-9-]+)\s+(.*)/ + $str =~ /(\d+\.\d+\.\d+\.\d+|[A-Za-z0-9.-]+)(->(\d+\.\d+\.\d+\.\d+|[A-Za-z0-9.-]+))?(:(\d+|[A-Za-z0-9-]+))?\s+(.*)/ or &config_error($line, - "invalid address for real server"); + "invalid address for real server" . + " (wrong format)"); $ip1=$1; $ip2=$3; - $port=$4; - $flags=$5; - $ip1=&ld_gethostbyname($ip1) or - &config_error($line, "invalid address for real server"); + if(defined($5)){ + $port=$5; + } + else { + $port="0"; + } + $flags=$6; + $ip1=&ld_gethostbyname($ip1); + unless( defined($ip1) ) { + &config_error($line, + "invalid address for real server" . + " (could not resolve host)"); + } if( defined($port) ){ - $port=&ld_getservbyname($port) or + $port=&ld_getservbyname($port); + unless( defined($port) ){ &config_error($line, - "invalid port for real server"); + "invalid port for real server" . + " (could not resolve port)"); + } } if ( defined ($ip2) ) { - $ip2=&ld_gethostbyname($ip2) or + $ip2=&ld_gethostbyname($ip2); + unless( defined ($ip2) ) { &config_error($line, - "invalid address for real server"); - &add_real_server_range($line, $vsrv, - $ip1, $ip2, $port, $flags); + "invalid address for real server" . + " (could not resolve end host)"); + } + &add_real_server_range($line, $vsrv, $ip1, $ip2, + $port, $flags); } else { &add_real_server($line, $vsrv, $ip1, $port, $flags); }