You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GoLang Library for Multiplexing HTTP Clients based on Source IP
IPMux is an open-source GoLang library that provides a simple and efficient way to multiplex HTTP clients based on source IP addresses. This library is designed to handle scenarios where you need to make HTTP requests from specific network interfaces based on the source IP.
This library could be useful to bypass rate limit errors which operate on source IPs.
Features
Multiplex HTTP clients based on source IP addresses.
Customizable options for creating HTTP clients.
Easy-to-use interface for seamless integration.
Enabling DNS cache with a refresh interval.
Getting Started
Installation
go get github.com/optimus-hft/go-ipmux
Usage
package main
import (
"fmt""io""time""github.com/optimus-hft/go-ipmux"
)
funcmain() {
// both ips should be attached to your device for IPMux to operate properlyips:= []string{"192.168.0.1", "192.168.0.2"}
ipMux, err:=ipmux.New(ips, ipmux.WithTimeout(10*time.Second))
iferr!=nil {
fmt.Println(err)
return
}
client:=ipMux.Client()
response, err:=client.Get("https://google.com")
iferr!=nil {
panic(err)
}
deferresponse.Body.Close()
fmt.Println(io.ReadAll(response.Body))
}
ips: List of IP addresses to create HTTP clients for.
options: Optional parameters to customize client creation.
Returns a new IPMux instance.
func (i *IPMux) Client() *http.Client
Returns an HTTP client associated with one of the IPs provided in the New function. Returns http.DefaultClient if no clients are available.
func (i *IPMux) Clients() []*http.Client
Returns a list of all clients created for the list of IPs given in New. Returns a list containing one client (http.DefaultClient) when there are no available clients.
Options
WithBaseClient(baseClient *http.Client) Option
Change the base client used to create clients for IPMux.
WithTimeout(timeout time.Duration) Option
Set timeout on both client and dialer of the clients.