mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 08:49:40 -05:00
Push for proxy test pt 3!
This commit is contained in:
@@ -46,6 +46,7 @@ public class HttpClientSettings {
|
||||
final Map<String, String> cookies;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
ProxyClientSettings proxyClientSettings;
|
||||
|
||||
@Getter
|
||||
@@ -104,7 +105,7 @@ public class HttpClientSettings {
|
||||
newSettings.getHeaders().putAll(new TreeMap<>(this.headers));
|
||||
newSettings.getCookies().putAll(new TreeMap<>(this.cookies));
|
||||
newSettings.getParams().putAll(new TreeMap<>(this.params));
|
||||
newSettings.proxyClientSettings = this.proxyClientSettings.clone();
|
||||
newSettings.proxyClientSettings = this.proxyClientSettings;
|
||||
|
||||
return newSettings;
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ public class ProxyClientSettings implements Iterator<ProxyData>
|
||||
private int index = 0;
|
||||
private boolean autoDiscard = true;
|
||||
private Proxy.Type type = Proxy.Type.DIRECT;
|
||||
private Consumer<ProxyData> onProxyUpdated = (x)->{};
|
||||
|
||||
private Consumer<ProxyData> onProxyUpdated = x -> {};
|
||||
|
||||
public boolean addProxy(String addressPort) {
|
||||
return proxyList.add(ProxyData.map(addressPort));
|
||||
@@ -66,19 +65,17 @@ public class ProxyClientSettings implements Iterator<ProxyData>
|
||||
@Override
|
||||
public ProxyData next()
|
||||
{
|
||||
var nextProxy = switch (rotation)
|
||||
var nextProxy = switch (rotation)
|
||||
{
|
||||
case CONSECUTIVE -> {
|
||||
index = (index+1) % proxyList.size();
|
||||
yield proxyList.get(index).clone();
|
||||
yield proxyList.get(index).clone();
|
||||
}
|
||||
case RANDOM -> {
|
||||
index = new Random().nextInt(proxyList.size());
|
||||
yield proxyList.get(index).clone();
|
||||
}
|
||||
default -> {
|
||||
yield proxyList.get(index).clone();
|
||||
}
|
||||
case NONE -> proxyList.get(index).clone();
|
||||
};
|
||||
onProxyUpdated.accept(nextProxy);
|
||||
return nextProxy;
|
||||
@@ -98,13 +95,14 @@ public class ProxyClientSettings implements Iterator<ProxyData>
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
public ProxyClientSettings clone() {
|
||||
public ProxyClientSettings clone()
|
||||
{
|
||||
ProxyClientSettings settings = new ProxyClientSettings();
|
||||
settings.setEnabled(enabled);
|
||||
settings.setRotation(rotation);
|
||||
settings.setIndex(index);
|
||||
settings.setType(type);
|
||||
settings.setOnProxyUpdated(onProxyUpdated);
|
||||
proxyList.forEach(proxyData -> settings.addProxy(proxyData.getAddress(), proxyData.getPort()));
|
||||
return settings;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user