forked from I2P_Developers/i2p.i2p
Make recognition of a hidden router consistent,
whether specified in the caps or the cert
This commit is contained in:
@ -29,6 +29,11 @@ public class RouterIdentity extends KeysAndCert {
|
||||
* nor queried for the netDb, and that disclosure of their contact information
|
||||
* should be limited.
|
||||
*
|
||||
* This is ONLY if the certificate is a hidden type.
|
||||
* Hidden mode may also be specified with a capability in the RouterInfo.
|
||||
*
|
||||
* Not recommended for direct use.
|
||||
* Use of RouterInfo.isHidden() (which calls this) is preferred.
|
||||
*/
|
||||
public boolean isHidden() {
|
||||
return (_certificate != null) && (_certificate.getCertificateType() == Certificate.CERTIFICATE_TYPE_HIDDEN);
|
||||
|
@ -382,9 +382,12 @@ public class RouterInfo extends DatabaseEntry {
|
||||
|
||||
/**
|
||||
* Is this a hidden node?
|
||||
*
|
||||
* @return true if either 'H' is in the capbilities, or router indentity contains a hidden cert.
|
||||
*/
|
||||
public boolean isHidden() {
|
||||
return (getCapabilities().indexOf(CAPABILITY_HIDDEN) != -1);
|
||||
return (getCapabilities().indexOf(CAPABILITY_HIDDEN) >= 0) ||
|
||||
(_identity != null && _identity.isHidden());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,19 +154,11 @@ public class HandleDatabaseLookupMessageJob extends JobImpl {
|
||||
lookupType != DatabaseLookupMessage.Type.LS) {
|
||||
RouterInfo info = (RouterInfo) dbe;
|
||||
if (info.isCurrent(EXPIRE_DELAY)) {
|
||||
if ( (info.getIdentity().isHidden()) || (isUnreachable(info) && !publishUnreachable()) ) {
|
||||
if ( (info.isHidden()) || (isUnreachable(info) && !publishUnreachable()) ) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Not answering a query for a netDb peer who isn't reachable");
|
||||
Set<Hash> us = Collections.singleton(getContext().routerHash());
|
||||
sendClosest(_message.getSearchKey(), us, fromKey, _message.getReplyTunnel());
|
||||
//} else if (info.isHidden()) {
|
||||
// // Don't return hidden nodes
|
||||
// ERR: we don't want to explicitly reject lookups for hidden nodes, since they
|
||||
// may have just sent the hidden mode to only us and bundled a lookup with
|
||||
// a payload targetting some hidden destination (and if we refused to answer,
|
||||
// yet answered the bundled data message [e.g. HTTP GET], they'd know that
|
||||
// *we* were hosting that destination). To operate safely,
|
||||
// perhaps we should refuse to honor lookups bundled down client tunnels?
|
||||
} else {
|
||||
// send that routerInfo to the _message.getFromHash peer
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
|
@ -131,7 +131,7 @@ class PeerSelector {
|
||||
RouterInfo info = _context.netDb().lookupRouterInfoLocally(entry);
|
||||
if (info == null)
|
||||
return;
|
||||
if (info.getIdentity().isHidden())
|
||||
if (info.isHidden())
|
||||
return;
|
||||
|
||||
BigInteger diff = HashDistance.getDistance(_key, entry);
|
||||
|
@ -1355,7 +1355,7 @@ public class ProfileOrganizer {
|
||||
|
||||
RouterInfo info = _context.netDb().lookupRouterInfoLocally(peer);
|
||||
if (null != info) {
|
||||
if (info.getIdentity().isHidden()) {
|
||||
if (info.isHidden()) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Peer " + peer.toBase64() + " is marked as hidden, disallowing its use");
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user