diff options
-rw-r--r-- | Ivy.pm | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -87,9 +87,10 @@ sub _toBePruned ($$); use constant VERSION => 3; use constant MSG_FMT => "%d %d\002%s\n"; -# On plante en dur les adresses reseau sur lesquelles on broadcaste -# le bonjour, ATTENTION, ca PLANTERA au SITEF !! -use constant BROADCAST_ADDRS => ("143.196.1.255", "143.196.2.255", "143.196.53.255") ; +# par defaut, on diffuse le bonjour en local +# (sauf pour l'instant, pour rester compatible) +#use constant BROADCAST_ADDRS => "127.255.255.255" ; +use constant BROADCAST_ADDRS => "143.196.1.255, 143.196.2.255, 143.196.53.255"; use constant BYE => 0; use constant REGEXP => 1; @@ -291,11 +292,25 @@ sub start (@) $supSock->sockopt (SO_BROADCAST, 1); - # envoie le bonjour : "no de version no de port" + # on determine la liste des adresses de broadcast + my $broadcastAddrs = $ENV{'IVYDOMAINS'}; + $broadcastAddrs = BROADCAST_ADDRS unless defined $broadcastAddrs; + $broadcastAddrs =~ s/ //g; + my @broadcastAddrs = split (',', $broadcastAddrs); + + # et on envoie envoie le bonjour : "no de version no de port" my $bonjourMsg = sprintf ("%d %d\n", VERSION, $connSock->sockport()); - - foreach my $netAddr (BROADCAST_ADDRS) { + foreach my $netAddr (@broadcastAddrs) { + # on complete la fin de l'adresse par des 255 si necessaire + my @addrElems = split ('\.', $netAddr); + $netAddr = ''; + my $i = 0; + while ($i <4) { + $netAddr .= (defined ($addrElems[$i]) ? $addrElems[$i] : '255'); + $netAddr .= '.' if ($i++ < 3); + } +# print "[$netAddr]\n"; my $netAddrInet = inet_aton ($netAddr); my $netBroadcastAddr = pack_sockaddr_in ($broadcastPort, $netAddrInet); send ($supSock, $bonjourMsg, 0, $netBroadcastAddr) or |