mirror of https://github.com/zlatinb/muwire
start work on sharing of trust lists
parent
7c8d64b462
commit
3ec9654d3c
|
@ -12,6 +12,8 @@ class MuWireSettings {
|
|||
final boolean isLeaf
|
||||
boolean allowUntrusted
|
||||
boolean allowTrustLists
|
||||
int trustListInterval
|
||||
Set<Persona> 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, "")
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Destination, Long> lastRequestTime = new ConcurrentHashMap<>()
|
||||
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue