diff options
author | jake <jake@jakes-mail.top> | 2022-08-18 07:50:57 -0400 |
---|---|---|
committer | jake <jake@jakes-mail.top> | 2022-08-18 07:50:57 -0400 |
commit | e5f02794ed7db70410ab838ca48de229ed955f8f (patch) | |
tree | d78c90ce8ddfabcdd2839e4cd3f672924df86e10 | |
parent | 4983ab890effe9690d46e5caeb53121470844628 (diff) |
Use IO::Socket::IP over IO::Socket::INET
IO::Socket::IP supports both IPv4 and IPv6
-rwxr-xr-x | gmi.pl | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -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 { |