forked from I2P_Developers/i2p.i2p
PortMapper: Add convenience methods
This commit is contained in:
@ -114,6 +114,15 @@ public class PortMapper {
|
||||
return _dir.putIfAbsent(service, InetSocketAddress.createUnresolved(host, port)) == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the service registered?
|
||||
*
|
||||
* @since 0.9.34
|
||||
*/
|
||||
public boolean isRegistered(String service) {
|
||||
return _dir.containsKey(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the service
|
||||
*/
|
||||
@ -121,6 +130,18 @@ public class PortMapper {
|
||||
_dir.remove(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the service,
|
||||
* only if it is registered with the supplied port.
|
||||
*
|
||||
* @since 0.9.34
|
||||
*/
|
||||
public void unregister(String service, int port) {
|
||||
// not synched
|
||||
if (getPort(service) == port)
|
||||
_dir.remove(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the registered port for a service
|
||||
* @return -1 if not registered
|
||||
|
Reference in New Issue
Block a user