Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Source Address and Port to be specified when creating a client #2742

Open
2 tasks
jmulcock-rbbn opened this issue Aug 19, 2022 · 2 comments
Open
2 tasks
Labels
feature-request This issue requests a feature. p3 This is a minor priority issue

Comments

@jmulcock-rbbn
Copy link

Describe the feature

We should be able to set the source IP address and source port when creating the client using an optional parameter, in the same manner as urllib3.

E.g.

  • session.create_client('ec2', source_address=None)) # Default value for parameter, allow random port and default IP address
  • session.create_client('ec2', source_address=('10.10.10.10', 0)) # Use address 10.10.10.10, allow randomly selected port
  • session.create_client('ec2', source_address=('', 1234)) # Use default address, set source port as 1234
  • session.create_client('ec2', source_address=('10.10.10.10', 1234)) # Use address 10.10.10.10, set source port as 1234

Use Case

As the endpoint IP address for requests is not static, local firewall rules on the machine need to allow traffic from port 443 to make requests. For some business use cases this unacceptable. Allowing to set source address and port allows greater granularity to the firewall rules.

Proposed Solution

The source_address parameter should be set in pool_manager_kwargs in URLLib3Session, for it to work with urllib3

Add the optional parameter into to Session.create_client() with default set as None (which will continue current behavior). Pass that value all the way through until create the URLLib3Session and it gets added to pool_manager_kwargs,

e.g.

def _get_pool_manager_kwargs(self, **extra_kwargs):
    pool_manager_kwargs = {
        'strict': True,
        'timeout': self._timeout,
        'maxsize': self._max_pool_connections,
        'ssl_context': self._get_ssl_context(),
        'socket_options': self._socket_options,
        'cert_file': self._cert_file,
        'key_file': self._key_file,
        **'source_address': self._source_address,**
    }
    pool_manager_kwargs.update(**extra_kwargs)
    return pool_manager_kwargs

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

SDK version used

1.20.0

Environment details (OS name and version, etc.)

Debian 10

@jmulcock-rbbn jmulcock-rbbn added feature-request This issue requests a feature. needs-triage This issue or PR still needs to be triaged. labels Aug 19, 2022
@tim-finnigan
Copy link
Contributor

Hi @jmulcock-rbbn thanks for the feature request. I brought this up for discussion with the team and it’s something that may be considered at a future date. We suggest others who are also interested in this feature to 👍 the issue or leave additional feedback in the comments. And if there’s anything else you want to expand on or clarify regarding your use case please let us know.

@tim-finnigan tim-finnigan removed the needs-triage This issue or PR still needs to be triaged. label Aug 19, 2022
@RyanFitzSimmonsAK RyanFitzSimmonsAK added the p3 This is a minor priority issue label Nov 3, 2022
@nveloso
Copy link

nveloso commented Sep 24, 2024

Hi @tim-finnigan @jmulcock-rbbn, I've opened up a PR that adds support to specify the source IP address and source port. Please check #3256. Feel free to add any comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request This issue requests a feature. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

4 participants