Commit ae6b9ab1 authored by Hiro's avatar Hiro 🏄
Browse files

Merge branch 'bridge-contact-info' into 'master'

Add contact field to bridges

See merge request !16
parents 778feb39 d687f05e
Pipeline #37992 passed with stage
in 2 minutes and 41 seconds
......@@ -124,6 +124,17 @@ class NodeIndex {
return relaysByContact;
}
private Map<String, Set<String>> bridgesByContact = null;
public void setBridgesByContact(
Map<String, Set<String>> bridgesByContact) {
this.bridgesByContact = bridgesByContact;
}
public Map<String, Set<String>> getBridgesByContact() {
return bridgesByContact;
}
private Map<String, Set<String>> relaysByFamily = null;
public void setRelaysByFamily(Map<String, Set<String>> relaysByFamily) {
......
......@@ -155,6 +155,7 @@ public class NodeIndexer implements ServletContextListener, Runnable {
Map<String, Set<String>> newRelaysByFlag = new HashMap<>();
Map<String, Set<String>> newBridgesByFlag = new HashMap<>();
Map<String, Set<String>> newRelaysByContact = new HashMap<>();
Map<String, Set<String>> newBridgesByContact = new HashMap<>();
Map<String, Set<String>> newRelaysByFamily = new HashMap<>();
Map<TorVersion, Set<String>> newRelaysByVersion = new HashMap<>();
Map<TorVersion, Set<String>> newBridgesByVersion = new HashMap<>();
......@@ -341,6 +342,10 @@ public class NodeIndexer implements ServletContextListener, Runnable {
newBridgesByFlag.get(flagLowerCase).add(
hashedHashedFingerprint);
}
String contact = entry.getContact();
newBridgesByContact.putIfAbsent(contact, new HashSet<>());
newBridgesByContact.get(contact).add(hashedFingerprint);
newBridgesByContact.get(contact).add(hashedHashedFingerprint);
int daysSinceFirstSeen = (int) ((
(specialTime < 0 ? System.currentTimeMillis() : specialTime)
- entry.getFirstSeenMillis()) / ONE_DAY);
......@@ -399,6 +404,7 @@ public class NodeIndexer implements ServletContextListener, Runnable {
newNodeIndex.setRelaysByFlag(newRelaysByFlag);
newNodeIndex.setBridgesByFlag(newBridgesByFlag);
newNodeIndex.setRelaysByContact(newRelaysByContact);
newNodeIndex.setBridgesByContact(newBridgesByContact);
newNodeIndex.setRelaysByFamily(newRelaysByFamily);
newNodeIndex.setRelaysByFirstSeenDays(newRelaysByFirstSeenDays);
newNodeIndex.setRelaysByLastSeenDays(newRelaysByLastSeenDays);
......
......@@ -554,7 +554,21 @@ public class RequestHandler {
for (String fingerprint : removeRelays) {
this.filteredRelays.remove(fingerprint);
}
this.filteredBridges.clear();
Set<String> removeBridges = new HashSet<>();
for (Map.Entry<String, Set<String>> e :
this.nodeIndex.getBridgesByContact().entrySet()) {
String contact = e.getKey();
for (String contactPart : this.contact) {
if (contact == null
|| !contact.contains(contactPart.toLowerCase())) {
removeBridges.addAll(e.getValue());
break;
}
}
}
for (String fingerprint : removeBridges) {
this.filteredBridges.remove(fingerprint);
}
}
private void filterByFamily() {
......
......@@ -351,6 +351,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
detailsStatus.setAdvertisedBandwidth(advertisedBandwidth);
long overloadGeneralTimestamp = descriptor.getOverloadGeneralTimestamp();
detailsStatus.setOverloadGeneralTimestamp(overloadGeneralTimestamp);
detailsStatus.setContact(descriptor.getContact());
detailsStatus.setPlatform(descriptor.getPlatform());
this.documentStore.store(detailsStatus, fingerprint);
}
......
......@@ -215,6 +215,7 @@ public class DetailsDocumentWriter implements DocumentWriter {
} else {
detailsDocument.setOverloadGeneralTimestamp(null);
}
detailsDocument.setContact(detailsStatus.getContact());
detailsDocument.setPlatform(detailsStatus.getPlatform());
detailsDocument.setTransports(detailsStatus.getTransports());
detailsDocument.setVersion(detailsStatus.getVersion());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment