diff --git a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy index c7980b8a..4da24897 100644 --- a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy +++ b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy @@ -12,6 +12,8 @@ class MuWireSettings { final boolean isLeaf boolean allowUntrusted boolean allowTrustLists + int trustListInterval + Set trustSubscriptions int downloadRetryInterval int updateCheckInterval boolean autoDownloadUpdate @@ -33,8 +35,9 @@ class MuWireSettings { MuWireSettings(Properties props) { isLeaf = Boolean.valueOf(props.get("leaf","false")) - allowUntrusted = Boolean.valueOf(props.get("allowUntrusted","true")) - allowTrustLists = Boolean.valueOf(props.get("allowTrustLists","true")) + allowUntrusted = Boolean.valueOf(props.getProperty("allowUntrusted","true")) + allowTrustLists = Boolean.valueOf(props.getProperty("allowTrustLists","true")) + trustListInterval = Integer.valueOf(props.getProperty("trustListInterval","1")) crawlerResponse = CrawlerResponse.valueOf(props.get("crawlerResponse","REGISTERED")) nickname = props.getProperty("nickname","MuWireUser") downloadLocation = new File((String)props.getProperty("downloadLocation", @@ -57,6 +60,12 @@ class MuWireSettings { encoded.each { watchedDirectories << DataUtil.readi18nString(Base64.decode(it)) } } + trustSubscriptions = new HashSet<>() + if (props.containsKey("trustSubscriptions")) { + props.getProperty("trustSubscriptions").split(",").each { + trustSubscriptions.add(new Persona(new ByteArrayInputStream(Base64.decode(it)))) + } + } } void write(OutputStream out) throws IOException { @@ -64,6 +73,7 @@ class MuWireSettings { props.setProperty("leaf", isLeaf.toString()) props.setProperty("allowUntrusted", allowUntrusted.toString()) props.setProperty("allowTrustLists", String.valueOf(allowTrustLists)) + props.setProperty("trustListInterval", String.valueOf(trustListInterval)) props.setProperty("crawlerResponse", crawlerResponse.toString()) props.setProperty("nickname", nickname) props.setProperty("downloadLocation", downloadLocation.getAbsolutePath()) @@ -86,6 +96,13 @@ class MuWireSettings { props.setProperty("watchedDirectories", encoded) } + if (!trustSubscriptions.isEmpty()) { + String encoded = trustSubscriptions.stream(). + map(it.toBase64()). + collect(Collectors.joining(",")) + props.setProperty("trustSubscriptions", encoded) + } + props.store(out, "") } diff --git a/core/src/main/groovy/com/muwire/core/trust/TrustSubscriber.groovy b/core/src/main/groovy/com/muwire/core/trust/TrustSubscriber.groovy new file mode 100644 index 00000000..2ee71361 --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/trust/TrustSubscriber.groovy @@ -0,0 +1,18 @@ +package com.muwire.core.trust + +import java.util.concurrent.ConcurrentHashMap + +import com.muwire.core.EventBus +import com.muwire.core.MuWireSettings +import com.muwire.core.connection.I2PConnector + +import net.i2p.data.Destination + +class TrustSubscriber { + private final EventBus eventBus + private final I2PConnector i2pConnector + private final MuWireSettings settings + + private final Map lastRequestTime = new ConcurrentHashMap<>() + +} diff --git a/core/src/main/groovy/com/muwire/core/trust/TrustSubscriptionEvent.groovy b/core/src/main/groovy/com/muwire/core/trust/TrustSubscriptionEvent.groovy new file mode 100644 index 00000000..42bb67c0 --- /dev/null +++ b/core/src/main/groovy/com/muwire/core/trust/TrustSubscriptionEvent.groovy @@ -0,0 +1,9 @@ +package com.muwire.core.trust + +import com.muwire.core.Event +import com.muwire.core.Persona + +class TrustSubscriptionEvent extends Event { + Persona persona + boolean subscribe +}