10
10
import io .netty .handler .logging .LogLevel ;
11
11
import io .netty .handler .logging .LoggingHandler ;
12
12
import io .netty .util .concurrent .*;
13
+ import java .net .InetAddress ;
13
14
import java .net .InetSocketAddress ;
14
15
import java .net .SocketAddress ;
15
16
import java .util .concurrent .CompletableFuture ;
@@ -23,16 +24,18 @@ class NettyHomekitHttpService {
23
24
24
25
private static final Logger logger = LoggerFactory .getLogger (NettyHomekitHttpService .class );
25
26
private final ChannelGroup allChannels = new DefaultChannelGroup (GlobalEventExecutor .INSTANCE );
27
+ private final InetAddress localAddress ;
26
28
private final int port ;
27
29
private final int nThreads ;
28
30
29
- public static NettyHomekitHttpService create (int port , int nThreads ) {
30
- return new NettyHomekitHttpService (port , nThreads );
31
+ public static NettyHomekitHttpService create (InetAddress localAddress , int port , int nThreads ) {
32
+ return new NettyHomekitHttpService (localAddress , port , nThreads );
31
33
}
32
34
33
- private NettyHomekitHttpService (int port , int nThreads ) {
35
+ private NettyHomekitHttpService (InetAddress localAddress , int port , int nThreads ) {
34
36
bossGroup = new NioEventLoopGroup ();
35
37
workerGroup = new NioEventLoopGroup ();
38
+ this .localAddress = localAddress ;
36
39
this .port = port ;
37
40
this .nThreads = nThreads ;
38
41
}
@@ -46,7 +49,7 @@ public CompletableFuture<Integer> create(HomekitClientConnectionFactory connecti
46
49
.childHandler (new ServerInitializer (connectionFactory , allChannels , nThreads ))
47
50
.option (ChannelOption .SO_BACKLOG , 128 )
48
51
.childOption (ChannelOption .SO_KEEPALIVE , true );
49
- final ChannelFuture bindFuture = b .bind (port );
52
+ final ChannelFuture bindFuture = b .bind (localAddress , port );
50
53
bindFuture .addListener (
51
54
new GenericFutureListener <Future <? super Void >>() {
52
55
0 commit comments