[erlang-patches] jinterface patch - connect to epmd using the loopback address

Artur Matos arturmatos78@REDACTED
Sat Jan 12 14:53:55 CET 2008


Hi,

In the current jinterface implementation, OtpEpmd.publishPort(node)  
connects to the local epmd using the
host's current IP address instead of the loopback  address (127.0.0.1).

If the host is connected to the internet with a static IP address,  
this will make
the connection to epmd go through the host's firewall, at least in  
Mac OS X. Besides being
a waste of resources, this forces the user to have the  epmd port  
open (creating an unnecessary security risk),
and seems inconsistent with Erlang semantics. For example, in my  
machine, If I invoke
"erl -sname blah" in my shell, Erlang connects to epmd without  
requiring its port to be open (but I have only started
using Erlang quite recently, so please correct me if I am wrong).

Anyway, the following patch fixes this problem.
The patched version works perfectly in Mac OS X, and should behave  
the same in other platforms, but I didn't test it with any other OS:

--- OtpEpmd.java.orig       2000-08-22 21:01:24.000000000 +0900
+++ OtpEpmd.java  2008-01-12 21:51:30.000000000 +0900
@@ -137,7 +137,7 @@
      Socket s = null;

      try {
-      s = new Socket(InetAddress.getLocalHost(),epmdPort);
+      s = new Socket(InetAddress.getByName("localhost"),epmdPort);
        OtpOutputStream obuf = new OtpOutputStream();
        obuf.write2BE(node.alive().length() + 1);
        obuf.write1(stopReq);
@@ -289,7 +289,7 @@

      try {
        OtpOutputStream obuf = new OtpOutputStream();
-      s = new Socket(InetAddress.getLocalHost(),epmdPort);
+      s = new Socket(InetAddress.getByName("localhost"),epmdPort);

        obuf.write2BE(node.alive().length() + 3);

@@ -349,7 +349,7 @@

      try {
        OtpOutputStream obuf = new OtpOutputStream();
-      s = new Socket(InetAddress.getLocalHost(),epmdPort);
+      s = new Socket(InetAddress.getByName("localhost"),epmdPort);

        obuf.write2BE(node.alive().length() + 13);




Artur




More information about the erlang-patches mailing list