nokia / restful

A powerful RESTful framework for Go.
BSD 3-Clause "New" or "Revised" License
17 stars 14 forks source link

Client: Use specific network interface #20

Closed Som-Som-CC closed 5 months ago

Som-Som-CC commented 2 years ago

In some setups it is preferable to use a specific interface for communication.

ListenAndServe has an address parameter where it is possible to set IP address to listen on. Client, however, does not have such direct support.

See:

For HTTP(S) v1 probably a bit easier is to code like this:

&Transport{DialContext: (&net.Dialer{LocalAddr: addr}).DialContext}

For h2c and h2 probably 2 DialTLS function sets are needed, with the option of Dialer with and without LocalAddr. Note that in http2 package DialContext is not available at the time of writing.

Som-Som-CC commented 1 year ago

On K8s with Multus the default route can be configured to use a different network attachment. One can keep having the single eth0 interface only. That may be a more flexible solution than this enhancement proposal.

See https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/docs/how-to-use.md

Som-Som-CC commented 5 months ago

See https://github.com/nokia/restful/pull/64

Som-Som-CC commented 5 months ago

Merged to main