Fixed some silly mistakes with local address handling.

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

@ -108,12 +108,17 @@ public final class Chords extends ListenerAdapter
if (settings.getLocalAddr() != null) if (settings.getLocalAddr() != null)
{ {
final WebSocketFactory webSocketFactory = new WebSocketFactory(); // make local binding socket factory
final LocalBindSocketFactory localBindSocketFactory = new LocalBindSocketFactory(); final LocalBindSocketFactory localBindSocketFactory = new LocalBindSocketFactory();
localBindSocketFactory.setLocalAddress(InetAddress.getByName(settings.getLocalAddr()));
// install local socket factory for HTTP
OkHttpClient.Builder httpBuilder = IOUtil.newHttpClientBuilder(); OkHttpClient.Builder httpBuilder = IOUtil.newHttpClientBuilder();
httpBuilder.socketFactory(localBindSocketFactory); httpBuilder.socketFactory(localBindSocketFactory);
builder.setHttpClientBuilder(httpBuilder);
localBindSocketFactory.setLocalAddress(InetAddress.getByName(settings.getLocalAddr())); // install local socket factory for websockets
final WebSocketFactory webSocketFactory = new WebSocketFactory();
webSocketFactory.setSocketFactory(localBindSocketFactory); webSocketFactory.setSocketFactory(localBindSocketFactory);
builder.setWebsocketFactory(webSocketFactory); builder.setWebsocketFactory(webSocketFactory);
} }

Loading…
Cancel
Save