From e5f02794ed7db70410ab838ca48de229ed955f8f Mon Sep 17 00:00:00 2001 From: jake Date: Thu, 18 Aug 2022 07:50:57 -0400 Subject: Use IO::Socket::IP over IO::Socket::INET IO::Socket::IP supports both IPv4 and IPv6 --- gmi.pl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gmi.pl b/gmi.pl index b427ca5..6d50ce7 100755 --- a/gmi.pl +++ b/gmi.pl @@ -7,11 +7,12 @@ use warnings; use 5.010; #use diagnostics; -our $VERSION = 'v0.0.12'; +our $VERSION = 'v0.0.13'; # Modules use IO::Socket::SSL; # CPAN use IO::Socket::SSL::Utils; # CPAN +use IO::Socket::IP -register; use URL::XS qw(parse_url split_url_path parse_url_query); # CPAN use Path::Naive qw(normalize_path); # CPAN #use Smart::Comments; # CPAN @@ -68,7 +69,7 @@ if ($err) { ### $config my %ssl_config = ssl_config($config); -my %inet_config = inet_config($config); +my %ip_config = ip_config($config); my $working_dir = working_dir($config); my $cert_key_dir = cert_key_dir($config); my $out = logging($config); @@ -88,9 +89,7 @@ my $ft = File::Type->new(); my $log; -#my $srv = IO::Socket::SSL->new(%ssl_config) -# or die "error=$ERRNO, ssl_error=$SSL_ERROR"; -my $srv = IO::Socket::INET->new(%inet_config) +my $srv = IO::Socket::IP->new(%ip_config) or die "error=$ERRNO"; say "$PROGRAM_NAME ($VERSION) started on ". localtime; @@ -567,9 +566,9 @@ sub ssl_config { return %ssl; } -sub inet_config { +sub ip_config { my ($conf_ref) = @_; - my %inet = ( + my %ip = ( LocalAddr => '0.0.0.0', LocalPort => $DEFAULT_GEMINI_PORT, Listen => 10, @@ -578,16 +577,16 @@ sub inet_config { ); for my $item (keys %{ $conf_ref->{default} }) { if ($item eq 'bind') { - $inet{LocalAddr} = $conf_ref->{default}{bind}; + $ip{LocalAddr} = $conf_ref->{default}{bind}; } elsif ($item eq 'ports') { for my $port ( @{ $conf_ref->{default}{ports} } ) { # TODO; enable more than one port. - $inet{LocalPort} = $conf_ref->{default}{ports}[0]; + $ip{LocalPort} = $conf_ref->{default}{ports}[0]; } } } - return %inet; + return %ip; } sub logging { -- cgit v1.2.3