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
|
||||
|
||||
|
||||
boolean startChatServer
|
||||
int maxChatConnections
|
||||
boolean advertiseChat
|
||||
File chatWelcomeFile
|
||||
|
||||
boolean allowMessages
|
||||
boolean allowOnlyTrustedMessages
|
||||
|
||||
Set<String> watchedDirectories
|
||||
float downloadSequentialRatio
|
||||
int hostClearInterval, hostHopelessInterval, hostRejectInterval, hostHopelessPurgeInterval
|
||||
|
@ -136,12 +141,18 @@ class MuWireSettings {
|
|||
speedSmoothSeconds = Integer.valueOf(props.getProperty("speedSmoothSeconds","10"))
|
||||
totalUploadSlots = Integer.valueOf(props.getProperty("totalUploadSlots","-1"))
|
||||
uploadSlotsPerUser = Integer.valueOf(props.getProperty("uploadSlotsPerUser","-1"))
|
||||
|
||||
// chat settings
|
||||
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"))
|
||||
String chatWelcomeProp = props.getProperty("chatWelcomeFile")
|
||||
if (chatWelcomeProp != null)
|
||||
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")
|
||||
watchedKeywords = DataUtil.readEncodedSet(props, "watchedKeywords")
|
||||
|
@ -221,11 +232,18 @@ class MuWireSettings {
|
|||
props.setProperty("speedSmoothSeconds", String.valueOf(speedSmoothSeconds))
|
||||
props.setProperty("totalUploadSlots", String.valueOf(totalUploadSlots))
|
||||
props.setProperty("uploadSlotsPerUser", String.valueOf(uploadSlotsPerUser))
|
||||
|
||||
// chat settings
|
||||
props.setProperty("startChatServer", String.valueOf(startChatServer))
|
||||
props.setProperty("maxChatConnectios", String.valueOf(maxChatConnections))
|
||||
props.setProperty("advertiseChat", String.valueOf(advertiseChat))
|
||||
if (chatWelcomeFile != null)
|
||||
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(watchedKeywords, "watchedKeywords", props)
|
||||
|
|
|
@ -685,6 +685,16 @@ class ConnectionAcceptor {
|
|||
byte [] ETTER = "ETTER\r\n".getBytes(StandardCharsets.US_ASCII)
|
||||
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())
|
||||
try {
|
||||
dis.readFully(read)
|
||||
|
|
Loading…
Reference in New Issue