Changeset 85462fb for fedkit


Ignore:
Timestamp:
May 25, 2010 5:39:21 AM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
479a7d9
Parents:
acaa9b9
Message:

Move get_ip into the library so others can use it. Minor other fixes to support the use of Net::hostent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedkit/gateway_lib.pm

    racaa9b9 r85462fb  
    2020use File::Temp;
    2121use File::Copy;
     22use Net::hostent;
    2223
    2324# Standard locations of these commands (FreeBSD)
     
    7778    my $start = time();
    7879    $sleep = 5 unless $sleep;
    79     my @rv;
    80 
    81     while (!@rv) {
    82         @rv = gethostbyname($name);
     80    my $rv;
     81
     82    while (!$rv) {
     83        $rv = gethostbyname($name);
    8384        die "Timeout waiting for DNS to get $name\n"
    8485            if ($timeout && time() - $start > $timeout);
    85         sleep($sleep) unless @rv;
     86        sleep($sleep) unless $rv;
    8687    }
    8788}
     
    438439}
    439440
     441sub get_ip {
     442    my($name) = @_;
     443    my $gwip;
     444    if ( my $hent = gethostbyname($name) ) {
     445        $gwip = inet_ntoa($hent->addr_list->[0]);
     446    }
     447    return $gwip;
     448}
     449
    4404501;
Note: See TracChangeset for help on using the changeset viewer.