Change local address handling to also apply to JDA's HTTPClient.

jda-v5
Nekojimi 2 years ago
parent 7cd118985a
commit 7c4ea13e3c
  1. 5
      src/main/java/moe/nekojimi/chords/Chords.java

@ -34,6 +34,8 @@ import net.dv8tion.jda.api.managers.AudioManager;
import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.Compression; import net.dv8tion.jda.api.utils.Compression;
import net.dv8tion.jda.api.utils.cache.CacheFlag; import net.dv8tion.jda.api.utils.cache.CacheFlag;
import net.dv8tion.jda.internal.utils.IOUtil;
import okhttp3.OkHttpClient;
/** /**
* The Chords music Discord bot. * The Chords music Discord bot.
@ -108,6 +110,9 @@ public final class Chords extends ListenerAdapter
{ {
final WebSocketFactory webSocketFactory = new WebSocketFactory(); final WebSocketFactory webSocketFactory = new WebSocketFactory();
final LocalBindSocketFactory localBindSocketFactory = new LocalBindSocketFactory(); final LocalBindSocketFactory localBindSocketFactory = new LocalBindSocketFactory();
OkHttpClient.Builder httpBuilder = IOUtil.newHttpClientBuilder();
httpBuilder.socketFactory(localBindSocketFactory);
localBindSocketFactory.setLocalAddress(InetAddress.getByName(settings.getLocalAddr())); localBindSocketFactory.setLocalAddress(InetAddress.getByName(settings.getLocalAddr()));
webSocketFactory.setSocketFactory(localBindSocketFactory); webSocketFactory.setSocketFactory(localBindSocketFactory);
builder.setWebsocketFactory(webSocketFactory); builder.setWebsocketFactory(webSocketFactory);

Loading…
Cancel
Save