Ignore:
Timestamp:
2015-05-06T20:05:57+02:00 (9 years ago)
Author:
stoecker
Message:

remotecontrol listens on IPv4 and IPv6 separately, fix #11409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java

    r7834 r8337  
    44import java.io.File;
    55import java.net.InetAddress;
     6import java.net.Inet4Address;
     7import java.net.Inet6Address;
    68import java.net.UnknownHostException;
    79
     
    8385     * @since 7800
    8486     */
     87    @Deprecated
    8588    public static InetAddress getInetAddress() throws UnknownHostException {
    8689        // Return an address to the loopback interface by default
    8790        return InetAddress.getByName(Main.pref.get("remote.control.host", null));
    8891    }
     92
     93    /**
     94     * Returns the IPv6 address used for remote control.
     95     * @return the IPv6 address used for remote control
     96     * @throws UnknownHostException if the local host name could not be resolved into an address.
     97     * @since 8337
     98     */
     99    public static InetAddress getInet6Address() throws UnknownHostException {
     100        for(InetAddress a : InetAddress.getAllByName(Main.pref.get("remote.control.host", "localhost"))) {
     101            if(a instanceof Inet6Address) {
     102                return a;
     103            }
     104        };
     105        throw new UnknownHostException();
     106    }
     107
     108    /**
     109     * Returns the IPv4 address used for remote control.
     110     * @return the IPv4 address used for remote control
     111     * @throws UnknownHostException if the local host name could not be resolved into an address.
     112     * @since 8337
     113     */
     114    public static InetAddress getInet4Address() throws UnknownHostException {
     115        // Return an address to the loopback interface by default
     116        for(InetAddress a : InetAddress.getAllByName(Main.pref.get("remote.control.host", "localhost"))) {
     117            if(a instanceof Inet4Address) {
     118                return a;
     119            }
     120        };
     121        throw new UnknownHostException();
     122    }
    89123}
Note: See TracChangeset for help on using the changeset viewer.