mirror of https://github.com/zlatinb/muwire
options to disable messages or allow only trusted messages
parent
7ad5e12aee
commit
2be248dc0d
|
@ -50,10 +50,15 @@ class MuWireSettings {
|
||||||
|
|
||||||
int responderCacheSize
|
int responderCacheSize
|
||||||
|
|
||||||
|
|
||||||
boolean startChatServer
|
boolean startChatServer
|
||||||
int maxChatConnections
|
int maxChatConnections
|
||||||
boolean advertiseChat
|
boolean advertiseChat
|
||||||
File chatWelcomeFile
|
File chatWelcomeFile
|
||||||
|
|
||||||
|
boolean allowMessages
|
||||||
|
boolean allowOnlyTrustedMessages
|
||||||
|
|
||||||
Set<String> watchedDirectories
|
Set<String> watchedDirectories
|
||||||
float downloadSequentialRatio
|
float downloadSequentialRatio
|
||||||
int hostClearInterval, hostHopelessInterval, hostRejectInterval, hostHopelessPurgeInterval
|
int hostClearInterval, hostHopelessInterval, hostRejectInterval, hostHopelessPurgeInterval
|
||||||
|
@ -136,13 +141,19 @@ class MuWireSettings {
|
||||||
speedSmoothSeconds = Integer.valueOf(props.getProperty("speedSmoothSeconds","10"))
|
speedSmoothSeconds = Integer.valueOf(props.getProperty("speedSmoothSeconds","10"))
|
||||||
totalUploadSlots = Integer.valueOf(props.getProperty("totalUploadSlots","-1"))
|
totalUploadSlots = Integer.valueOf(props.getProperty("totalUploadSlots","-1"))
|
||||||
uploadSlotsPerUser = Integer.valueOf(props.getProperty("uploadSlotsPerUser","-1"))
|
uploadSlotsPerUser = Integer.valueOf(props.getProperty("uploadSlotsPerUser","-1"))
|
||||||
|
|
||||||
|
// chat settings
|
||||||
startChatServer = Boolean.valueOf(props.getProperty("startChatServer","false"))
|
startChatServer = Boolean.valueOf(props.getProperty("startChatServer","false"))
|
||||||
maxChatConnections = Integer.valueOf(props.get("maxChatConnections", "-1"))
|
maxChatConnections = Integer.valueOf(props.getProperty("maxChatConnections", "-1"))
|
||||||
advertiseChat = Boolean.valueOf(props.getProperty("advertiseChat","true"))
|
advertiseChat = Boolean.valueOf(props.getProperty("advertiseChat","true"))
|
||||||
String chatWelcomeProp = props.getProperty("chatWelcomeFile")
|
String chatWelcomeProp = props.getProperty("chatWelcomeFile")
|
||||||
if (chatWelcomeProp != null)
|
if (chatWelcomeProp != null)
|
||||||
chatWelcomeFile = new File(chatWelcomeProp)
|
chatWelcomeFile = new File(chatWelcomeProp)
|
||||||
|
|
||||||
|
// messaging settings
|
||||||
|
allowMessages = Boolean.valueOf(props.getProperty("allowMessages","true"))
|
||||||
|
allowOnlyTrustedMessages = Boolean.valueOf(props.getProperty("allowOnlyTrustedMessages","false"))
|
||||||
|
|
||||||
watchedDirectories = DataUtil.readEncodedSet(props, "watchedDirectories")
|
watchedDirectories = DataUtil.readEncodedSet(props, "watchedDirectories")
|
||||||
watchedKeywords = DataUtil.readEncodedSet(props, "watchedKeywords")
|
watchedKeywords = DataUtil.readEncodedSet(props, "watchedKeywords")
|
||||||
watchedRegexes = DataUtil.readEncodedSet(props, "watchedRegexes")
|
watchedRegexes = DataUtil.readEncodedSet(props, "watchedRegexes")
|
||||||
|
@ -221,12 +232,19 @@ class MuWireSettings {
|
||||||
props.setProperty("speedSmoothSeconds", String.valueOf(speedSmoothSeconds))
|
props.setProperty("speedSmoothSeconds", String.valueOf(speedSmoothSeconds))
|
||||||
props.setProperty("totalUploadSlots", String.valueOf(totalUploadSlots))
|
props.setProperty("totalUploadSlots", String.valueOf(totalUploadSlots))
|
||||||
props.setProperty("uploadSlotsPerUser", String.valueOf(uploadSlotsPerUser))
|
props.setProperty("uploadSlotsPerUser", String.valueOf(uploadSlotsPerUser))
|
||||||
|
|
||||||
|
// chat settings
|
||||||
props.setProperty("startChatServer", String.valueOf(startChatServer))
|
props.setProperty("startChatServer", String.valueOf(startChatServer))
|
||||||
props.setProperty("maxChatConnectios", String.valueOf(maxChatConnections))
|
props.setProperty("maxChatConnectios", String.valueOf(maxChatConnections))
|
||||||
props.setProperty("advertiseChat", String.valueOf(advertiseChat))
|
props.setProperty("advertiseChat", String.valueOf(advertiseChat))
|
||||||
if (chatWelcomeFile != null)
|
if (chatWelcomeFile != null)
|
||||||
props.setProperty("chatWelcomeFile", chatWelcomeFile.getAbsolutePath())
|
props.setProperty("chatWelcomeFile", chatWelcomeFile.getAbsolutePath())
|
||||||
|
|
||||||
|
// messaging settings
|
||||||
|
props.setProperty("allowMessages", String.valueOf(allowMessages))
|
||||||
|
props.setProperty("allowOnlyTrustedMessages", String.valueOf(allowOnlyTrustedMessages))
|
||||||
|
|
||||||
|
|
||||||
DataUtil.writeEncodedSet(watchedDirectories, "watchedDirectories", props)
|
DataUtil.writeEncodedSet(watchedDirectories, "watchedDirectories", props)
|
||||||
DataUtil.writeEncodedSet(watchedKeywords, "watchedKeywords", props)
|
DataUtil.writeEncodedSet(watchedKeywords, "watchedKeywords", props)
|
||||||
DataUtil.writeEncodedSet(watchedRegexes, "watchedRegexes", props)
|
DataUtil.writeEncodedSet(watchedRegexes, "watchedRegexes", props)
|
||||||
|
|
|
@ -685,6 +685,16 @@ class ConnectionAcceptor {
|
||||||
byte [] ETTER = "ETTER\r\n".getBytes(StandardCharsets.US_ASCII)
|
byte [] ETTER = "ETTER\r\n".getBytes(StandardCharsets.US_ASCII)
|
||||||
byte [] read = new byte[ETTER.length]
|
byte [] read = new byte[ETTER.length]
|
||||||
|
|
||||||
|
if (!settings.allowMessages) {
|
||||||
|
e.close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.allowOnlyTrustedMessages && trustService.getLevel(e.destination) != TrustLevel.TRUSTED) {
|
||||||
|
e.close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
DataInputStream dis = new DataInputStream(e.getInputStream())
|
DataInputStream dis = new DataInputStream(e.getInputStream())
|
||||||
try {
|
try {
|
||||||
dis.readFully(read)
|
dis.readFully(read)
|
||||||
|
|
Loading…
Reference in New Issue