Skip to content

HTTPClientSession source IP address #2271

@roccocorsi

Description

@roccocorsi

Expected behavior

When the target host IP family used by HTTPClientSession is not known ahead of time, it would be useful to allow setting both an IPv4 and an IPv6 source IP address, and selecting the appropriate one once the IP family of the host is determined by HTTPClientSession.

This is useful when passing a domain name for the host to HTTPClientSession, and no prior address family verification is done on host address by the application. Adapt to whatever host we might be dealing with, without the application having to make decisions or DNS lookups to figure out address family ahead of time to set appropriate family source IP address.

Useful in environments that are handling mixed address family traffic.

Actual behavior

Current implementation supports target IP address and source IP address if they are from the same family (IPv4 or IPv6). If mismatched IPv4 (target) and IPv6 (source) values; or the reverse case IPv6 (target) and IPv4 (source), then a family exception will be thrown.

Steps to reproduce the problem

Here is a simple example using the SetSourceIP sample program to force the bad IPv4/IPv6 situation, but normally the address in uri would be a domain name where we don't know ahead of time if the DNS is going to return an IPv4 or IPv6 address.

./SetSourceIP --sourceip 192.168.15.4 http://[fd17:625c:f037:a80f:6dbe:34f6:2afa:66e9]:1500/
Host: fd17:625c:f037:a80f:6dbe:34f6:2afa:66e9
Port: 1500
Path: /
Exception: name (Net Exception) message [Address family not supported]

POCO version

2.0.0

Other relevant information

Related and an enhancement to issue #1475

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions