Skip to content

Commit

Permalink
Merge pull request #3 from benediktarnold/bindaddress
Browse files Browse the repository at this point in the history
Add bindaddress option (thanks benediktarnold)
  • Loading branch information
owagner committed May 29, 2015
2 parents 2d7f2f3 + a944ccb commit 48d445c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.iml
.idea/
.gradle/
build/
hm2mqtt.devcache
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ Examples:
Local address used when sending init (callback) requests to the XML-RPC server. Default is
the result of getHostAddress(). Set this when hm2mqtt has trouble determining your local host's
address automatically.

- hm.bindaddress

Local address and port used to listen for callback requests. If not specified hm2mqtt will pick a valid local address
and a random port

Example: Listen on all local adresses on port 3333: 0.0.0.0:3333

- hm.disableReGa

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/tellerulam/hm2mqtt/XMLRPCServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ public static String init() throws IOException
{
ss=new ServerSocket();
ss.setReuseAddress(true);
ss.bind(null);
String bindaddress=System.getProperty("hm2mqtt.hm.bindaddress");
if(bindaddress == null)
ss.bind(null);
else{
String[] parts = bindaddress.split(":");
ss.bind(new InetSocketAddress(parts[0], Integer.parseInt(parts[1])));
}
new XMLRPCAcceptor().start();
String localhost=System.getProperty("hm2mqtt.hm.localhost");
if(localhost==null)
Expand Down

0 comments on commit 48d445c

Please sign in to comment.