make jinetd relocatable
[org.ibex.jinetd.git] / src / org / ibex / jinetd / Port.java
index 2aded0a..f00e0de 100644 (file)
@@ -8,13 +8,13 @@ import java.util.zip.*;
 
 public class Port extends Loader {
 
 
 public class Port extends Loader {
 
-    private final NetworkInterface iface;
+    private final InetAddress bindTo;
     private final int port;
     private final Thread listener;
 
     private final int port;
     private final Thread listener;
 
-    public Port(String path, NetworkInterface iface, int port) {
+    public Port(String path, InetAddress bindTo, int port) {
         super(path);
         super(path);
-        this.iface = iface;
+        this.bindTo = bindTo;
         this.port = port;
         this.listener = new PortThread();
         listener.start();
         this.port = port;
         this.listener = new PortThread();
         listener.start();
@@ -86,8 +86,8 @@ public class Port extends Loader {
     private class PortThread extends Thread {
         public void run() {
             try {
     private class PortThread extends Thread {
         public void run() {
             try {
-                Log.warn(this, "Now listening on interface " + iface + ", port " + port);
-                ServerSocket ss = new ServerSocket(port);
+                Log.warn(this, "Now listening on address " + bindTo + ", port " + port);
+                ServerSocket ss = bindTo == null ? new ServerSocket(port) : new ServerSocket(port, 0, bindTo);
                 for(Socket s = ss.accept(); ; s = ss.accept()) try {
                     Log.warn(this, "accepted connection on port " + port);
                     dispatch(new Connection(s, "megacz.com"));
                 for(Socket s = ss.accept(); ; s = ss.accept()) try {
                     Log.warn(this, "accepted connection on port " + port);
                     dispatch(new Connection(s, "megacz.com"));