/** * Get the actual host for a service. * Will return "127.0.0.1" if the service was registered without a host. * If the service was registered with the host "0.0.0.0", "::", or "0:0:0:0:0:0:0:0", * it will return a public IP if we have one, * else a local IP if we have one, else def. * If it was not registered with a wildcard address, it will return the registered host. * * @param def default * @return def if not registered * @since 0.9.24 */ public String getActualHost(String service, String def) { InetSocketAddress ia = _dir.get(service); if (ia == null) return def; return convertWildcard(ia.getHostName(), def); }
/** * For debugging only * @since 0.9.20 */ public void renderStatusHTML(Writer out) throws IOException { List<String> services = new ArrayList<String>(_dir.keySet()); out.write("<h2 id=\"debug_portmapper\">Port Mapper</h2><table id=\"portmapper\"><tr><th>Service<th>Host<th>Port\n"); Collections.sort(services, Collator.getInstance()); for (String s : services) { InetSocketAddress ia = _dir.get(s); if (ia == null) continue; out.write("<tr><td>" + s + "<td>" + convertWildcard(ia.getHostName(), DEFAULT_HOST) + "<td>" + ia.getPort() + '\n'); } out.write("</table>\n"); } }