Fixed some silly mistakes with local address handling.

This commit is contained in:
Nekojimi 2023-03-03 23:34:19 +00:00
parent 7c4ea13e3c
commit 6ef49c9e51
1 changed files with 7 additions and 2 deletions

View File

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