Implement localAddress in Agent
Originally posted by @RemoQuality in https://github.com/nodejs/undici/discussions/1577:
I was trying to use undici request with option to select which IP address should be used to request but without any success.
Example how I am doing it with AXIOS:
await axios(url, { httpsAgent: new https.Agent({ localAddress: "XXX.XXX.XXX.XXX", keepAlive: true, keepAliveMsecs: 30000 }) }) .then(res => {})any possibilities of that with undici?
This will be a good feature to add!
@mcollina I would love to work on this, any suggestions as to where I should start looking to implement this?
My guess is, inside agent.js the Agent expects a factory that either returns a Client or a Pool
https://github.com/nodejs/undici/blob/main/lib/agent.js#L49
And inside the client.js this is where the IP resolution happens i guess? https://github.com/nodejs/undici/blob/03cfc4be563e19fb55ec33177dcf45c45fee828c/lib/client.js#L997
Or am I just digging the wrong part of the codebase :smile:
I think this should be in client.js.
Can be closed with #1659?