FELIX-826 Apply patch by Peter Triller (Thanks)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@739440 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/shell.remote/src/main/java/org/apache/felix/shell/remote/Listener.java b/shell.remote/src/main/java/org/apache/felix/shell/remote/Listener.java
index a278300..a00d638 100644
--- a/shell.remote/src/main/java/org/apache/felix/shell/remote/Listener.java
+++ b/shell.remote/src/main/java/org/apache/felix/shell/remote/Listener.java
@@ -19,6 +19,7 @@
 
 import java.io.IOException;
 import java.io.PrintStream;
+import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketException;
@@ -33,6 +34,7 @@
 {
 
     private int m_Port;
+    private String m_Ip;
     private Thread m_ListenerThread;
     private boolean m_Stop = false;
     private ServerSocket m_ServerSocket;
@@ -46,6 +48,7 @@
     public void activate( BundleContext bundleContext )
     {
         //configure from framework property
+        m_Ip = getProperty( bundleContext, "osgi.shell.telnet.ip", "127.0.0.1" );
         m_Port = getProperty( bundleContext, "osgi.shell.telnet.port", 6666 );
         m_MaxConnections = getProperty( bundleContext, "osgi.shell.telnet.maxconn", 2 );
         m_UseCounter = new AtomicInteger( 0 );
@@ -101,7 +104,7 @@
                     should be handled properly, but denial of service attacks via massive parallel
                     program logins should be prevented with this.
                 */
-                m_ServerSocket = new ServerSocket( m_Port, 1 );
+                m_ServerSocket = new ServerSocket( m_Port, 1, InetAddress.getByName(m_Ip) );
                 do
                 {
                     try
@@ -162,4 +165,15 @@
         return defaultValue;
     }
 
+    private String getProperty( BundleContext bundleContext, String propName, String defaultValue )
+    {
+        String propValue = bundleContext.getProperty( propName );
+        if ( propValue != null )
+        {
+           return propValue;
+        }
+
+        return defaultValue;
+    }
+
 }//class Listener