- Timestamp:
- 2014-12-12T20:08:22+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io/remotecontrol
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java
r7702 r7800 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.io.remotecontrol; 3 4 import java.net.InetAddress; 5 import java.net.UnknownHostException; 3 6 4 7 import org.openstreetmap.josm.Main; … … 34 37 static final int protocolMajorVersion = 1; 35 38 static final int protocolMinorVersion = 7; 39 40 private static final String LOCALHOST = "localhost"; 36 41 37 42 /** … … 71 76 return Main.pref.getPreferencesDir() + "remotecontrol/"; 72 77 } 78 79 /** 80 * Returns the inet address used for remote control. 81 * @return the inet address used for remote control 82 * @throws UnknownHostException if the local host name could not be resolved into an address. 83 * @since 7800 84 */ 85 public static InetAddress getInetAddress() throws UnknownHostException { 86 String hostname = Main.pref.get("remote.control.host", LOCALHOST); 87 InetAddress result = InetAddress.getByName(hostname); 88 // Sometimes localhost resolution does not work as expected, see #10833 89 if (LOCALHOST.equalsIgnoreCase(hostname) && !LOCALHOST.equalsIgnoreCase(result.getHostName())) { 90 InetAddress localhostAddr = InetAddress.getLocalHost(); 91 // Use this result if it's better. Not sure if it's a Java bug or not 92 if (LOCALHOST.equalsIgnoreCase(localhostAddr.getHostName())) { 93 result = localhostAddr; 94 } 95 } 96 return result; 97 } 73 98 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpServer.java
r7034 r7800 6 6 import java.io.IOException; 7 7 import java.net.BindException; 8 import java.net.InetAddress;9 8 import java.net.ServerSocket; 10 9 import java.net.Socket; … … 68 67 this.setDaemon(true); 69 68 // Start the server socket with only 1 connection. 70 // Also make sure we only listen 71 // on the local interface so nobody from the outside can connect! 69 // Also make sure we only listen on the local interface so nobody from the outside can connect! 72 70 // NOTE: On a dual stack machine with old Windows OS this may not listen on both interfaces! 73 this.server = new ServerSocket(port, 1, 74 InetAddress.getByName(Main.pref.get("remote.control.host", "localhost"))); 71 this.server = new ServerSocket(port, 1, RemoteControl.getInetAddress()); 75 72 } 76 73 … … 80 77 @Override 81 78 public void run() { 82 Main.info(marktr("RemoteControl::Accepting connections on port {0}"),83 Integer.toString(server.getLocalPort()));79 Main.info(marktr("RemoteControl::Accepting connections on {0}:{1}"), 80 server.getInetAddress(), Integer.toString(server.getLocalPort())); 84 81 while (true) { 85 82 try { -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpsServer.java
r7402 r7800 9 9 import java.math.BigInteger; 10 10 import java.net.BindException; 11 import java.net.InetAddress;12 11 import java.net.ServerSocket; 13 12 import java.net.Socket; … … 380 379 381 380 // Start the server socket with only 1 connection. 382 // Also make sure we only listen 383 // on the local interface so nobody from the outside can connect! 381 // Also make sure we only listen on the local interface so nobody from the outside can connect! 384 382 // NOTE: On a dual stack machine with old Windows OS this may not listen on both interfaces! 385 this.server = factory.createServerSocket(port, 1, 386 InetAddress.getByName(Main.pref.get("remote.control.host", "localhost"))); 383 this.server = factory.createServerSocket(port, 1, RemoteControl.getInetAddress()); 387 384 388 385 if (Main.isTraceEnabled() && server instanceof SSLServerSocket) { … … 402 399 @Override 403 400 public void run() { 404 Main.info(marktr("RemoteControl::Accepting secure connections on port {0}"),405 Integer.toString(server.getLocalPort()));401 Main.info(marktr("RemoteControl::Accepting secure connections on {0}:{1}"), 402 server.getInetAddress(), Integer.toString(server.getLocalPort())); 406 403 while (true) { 407 404 try {
Note:
See TracChangeset
for help on using the changeset viewer.