0
votes

I use IO:Socket::SSL to connect to a number of upstream sources. There is an IPv6 connectivity issue with one of the sources which I want to circumvent by using IPv4 for the time being. To do so, I have used the IPv4 address in my conf file instead of the hostnname. However, I would prefer using the hostname and an additional option to force IPv4 for this source.

Now I am unsure what option to use with IO::Socket::SSL. Perldoc reads "you can either force IPv4 by specifying and AF_INET as theDomain" which seems a bit garbled.

I'd appreciate if someone could provide an example how to do that. To clarify, I would not like to use IO::Socket::SSL qw (inet) as other connections shan't be affected.

Best, Marcus

1

1 Answers

1
votes

If you're looping over each system, this (untested) code should do what you want. If you have multiple v4 servers, you can put them all into an array, then instead of doing an eq for a single name, use grep instead.

for (@servers){

    my %params = (
        Proto       => $proto,
        PeerAddr    => $_,
        PeerPort    => $port,
        ...
    );

    my $sock;

    if ($_ eq 'ipv4_servername'){
        $sock = IO::Socket::SSL->new(%params, Domain => AF_INET);
    }
    else {
        $sock = IO::Socket::SSL->new(%params);
    }
    ...
}