mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-28 09:19:40 -05:00
Push for proxy test pt 3!
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok.http;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.data.settings.LiveClientSettings;
|
||||
import io.github.jwdeveloper.tiktok.data.settings.*;
|
||||
|
||||
public class HttpClientFactory {
|
||||
private final LiveClientSettings liveClientSettings;
|
||||
@@ -37,6 +37,9 @@ public class HttpClientFactory {
|
||||
|
||||
//Does not contains default httpClientSettings, Params, headers, etd
|
||||
public HttpClientBuilder clientEmpty(String url) {
|
||||
return new HttpClientBuilder(url);
|
||||
|
||||
var settings = new HttpClientSettings();
|
||||
settings.setProxyClientSettings(liveClientSettings.getHttpSettings().getProxyClientSettings());
|
||||
return new HttpClientBuilder(url,settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,8 +92,10 @@ public class HttpProxyClient extends HttpClient
|
||||
|
||||
while (proxySettings.hasNext()) {
|
||||
try {
|
||||
Proxy proxy = new Proxy(Proxy.Type.SOCKS, proxySettings.next().toSocketAddress());
|
||||
var proxyData = proxySettings.next();
|
||||
Proxy proxy = new Proxy(Proxy.Type.SOCKS, proxyData.toSocketAddress());
|
||||
|
||||
System.err.println("Attempting connection to "+ url +" with proxy: "+proxyData);
|
||||
HttpsURLConnection socksConnection = (HttpsURLConnection) url.openConnection(proxy);
|
||||
socksConnection.setSSLSocketFactory(sc.getSocketFactory());
|
||||
socksConnection.setConnectTimeout(httpClientSettings.getTimeout().toMillisPart());
|
||||
@@ -113,6 +115,7 @@ public class HttpProxyClient extends HttpClient
|
||||
|
||||
return Optional.of(response);
|
||||
} catch (SocketException | SocketTimeoutException e) {
|
||||
e.printStackTrace();
|
||||
if (proxySettings.isAutoDiscard())
|
||||
proxySettings.remove();
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user