Skip to content

Commit

Permalink
fix: fix HTTP server IPv6 support as HTTP::Daemon module now supports…
Browse files Browse the repository at this point in the history
… IPv6 natively

This fixes HTTP server not answering issue on MacOS
  • Loading branch information
g-bougard committed Sep 26, 2019
1 parent cf1ff3e commit dcb9795
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,9 @@ Revision history for FusionInventory agent

2.5.2 not released yet

core:
* fix HTTP server IPv6 support as HTTP::Daemon module now supports IPv6 natively

inventory:
* unix: fix last log user after a reboot
* added Samsung monitor serial support for models: B1940MR, B1940W, S22A450BW,
Expand Down
15 changes: 11 additions & 4 deletions lib/FusionInventory/Agent/HTTP/Server.pm
Expand Up @@ -12,6 +12,7 @@ use Net::IP;
use Text::Template;
use File::Glob;
use URI;
use Socket qw(IN6ADDR_ANY inet_ntop);

use FusionInventory::Agent::Version;
use FusionInventory::Agent::Logger;
Expand Down Expand Up @@ -586,8 +587,11 @@ sub handleRequests {
next;
}

my (undef, $iaddr) = sockaddr_in($socket);
my $clientIp = inet_ntoa($iaddr);
my $family = sockaddr_family($socket);
my $iaddr = $family == AF_INET ? unpack_sockaddr_in($socket) :
$family == AF_INET6 ? unpack_sockaddr_in6($socket) :
INADDR_ANY;
my $clientIp = inet_ntop($family, $iaddr);
my $request = $client->get_request();
$self->_handle_plugins($client, $request, $clientIp, $self->{listeners}->{$port}->{plugins});
}
Expand All @@ -601,8 +605,11 @@ sub handleRequests {
return;
}

my (undef, $iaddr) = sockaddr_in($socket);
my $clientIp = inet_ntoa($iaddr);
my $family = sockaddr_family($socket);
my $iaddr = $family == AF_INET ? unpack_sockaddr_in($socket) :
$family == AF_INET6 ? unpack_sockaddr_in6($socket) :
INADDR_ANY;
my $clientIp = inet_ntop($family, $iaddr);
my $request = $client->get_request();
$self->_handle($client, $request, $clientIp);

Expand Down

0 comments on commit dcb9795

Please sign in to comment.