Controlla la rotazione con il keep-alive e un client per sessione
Un Transport mantiene aperte le connessioni e le riusa, e un tunnel riusato mantiene il suo IP di uscita. Per un IP nuovo a ogni richiesta con un nome utente a rotazione, imposta DisableKeepAlives: true. Per il lavoro sticky, dai a ogni sessione un proprio Transport e client e lascia attivo il keep-alive per la velocità.
// rotating: new connection, new IP per request
rotating := &http.Client{Transport: &http.Transport{
Proxy: http.ProxyURL(proxyFor("nl", "", "", 0)),
DisableKeepAlives: true,
}}
// sticky: one client per worker, each with its own session
for w := 0; w < 4; w++ {
go func(w int) {
c := &http.Client{Transport: &http.Transport{
Proxy: http.ProxyURL(proxyFor("nl", "", fmt.Sprintf("w%d", w), 20)),
}}
_ = c // use c for every request of this worker
}(w)
}
_ = rotating