mirror of https://github.com/zlatinb/muwire
settings to disable or not advertise file feed
parent
d60d57ee43
commit
9f3942c1c7
|
@ -31,6 +31,8 @@ class MuWireSettings {
|
||||||
boolean shareHiddenFiles
|
boolean shareHiddenFiles
|
||||||
boolean searchComments
|
boolean searchComments
|
||||||
boolean browseFiles
|
boolean browseFiles
|
||||||
|
boolean fileFeed
|
||||||
|
boolean advertiseFeed
|
||||||
boolean startChatServer
|
boolean startChatServer
|
||||||
int maxChatConnections
|
int maxChatConnections
|
||||||
boolean advertiseChat
|
boolean advertiseChat
|
||||||
|
@ -82,6 +84,8 @@ class MuWireSettings {
|
||||||
outBw = Integer.valueOf(props.getProperty("outBw","128"))
|
outBw = Integer.valueOf(props.getProperty("outBw","128"))
|
||||||
searchComments = Boolean.valueOf(props.getProperty("searchComments","true"))
|
searchComments = Boolean.valueOf(props.getProperty("searchComments","true"))
|
||||||
browseFiles = Boolean.valueOf(props.getProperty("browseFiles","true"))
|
browseFiles = Boolean.valueOf(props.getProperty("browseFiles","true"))
|
||||||
|
fileFeed = Boolean.valueOf(props.getProperty("fileFeed","true"))
|
||||||
|
advertiseFeed = Boolean.valueOf(props.getProperty("advertiseFeed","true"))
|
||||||
speedSmoothSeconds = Integer.valueOf(props.getProperty("speedSmoothSeconds","60"))
|
speedSmoothSeconds = Integer.valueOf(props.getProperty("speedSmoothSeconds","60"))
|
||||||
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"))
|
||||||
|
@ -137,6 +141,8 @@ class MuWireSettings {
|
||||||
props.setProperty("outBw", String.valueOf(outBw))
|
props.setProperty("outBw", String.valueOf(outBw))
|
||||||
props.setProperty("searchComments", String.valueOf(searchComments))
|
props.setProperty("searchComments", String.valueOf(searchComments))
|
||||||
props.setProperty("browseFiles", String.valueOf(browseFiles))
|
props.setProperty("browseFiles", String.valueOf(browseFiles))
|
||||||
|
props.setProperty("fileFeed", String.valueOf(fileFeed))
|
||||||
|
props.setProperty("advertiseFeed", String.valueOf(advertiseFeed))
|
||||||
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))
|
||||||
|
|
|
@ -379,6 +379,9 @@ class ConnectionAcceptor {
|
||||||
boolean chat = chatServer.running.get() && settings.advertiseChat
|
boolean chat = chatServer.running.get() && settings.advertiseChat
|
||||||
os.write("Chat: ${chat}\r\n".getBytes(StandardCharsets.US_ASCII))
|
os.write("Chat: ${chat}\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
|
|
||||||
|
boolean feed = settings.fileFeed && settings.advertiseFeed
|
||||||
|
os.write("Feed: ${feed}\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
|
|
||||||
os.write("\r\n".getBytes(StandardCharsets.US_ASCII))
|
os.write("\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
|
|
||||||
DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(os))
|
DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(os))
|
||||||
|
@ -538,6 +541,7 @@ class ConnectionAcceptor {
|
||||||
if (EED != "EED\r\n".getBytes(StandardCharsets.US_ASCII))
|
if (EED != "EED\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
throw new Exception("Invalid FEED connection")
|
throw new Exception("Invalid FEED connection")
|
||||||
|
|
||||||
|
OutputStream os = e.getOutputStream()
|
||||||
|
|
||||||
Map<String, String> headers = DataUtil.readAllHeaders(dis)
|
Map<String, String> headers = DataUtil.readAllHeaders(dis)
|
||||||
if (!headers.containsKey("Persona"))
|
if (!headers.containsKey("Persona"))
|
||||||
|
@ -546,7 +550,12 @@ class ConnectionAcceptor {
|
||||||
if (requestor.destination != e.destination)
|
if (requestor.destination != e.destination)
|
||||||
throw new Exception("Requestor persona mismatch")
|
throw new Exception("Requestor persona mismatch")
|
||||||
|
|
||||||
// TODO: check settings if feed is permitted at all
|
if (!settings.fileFeed) {
|
||||||
|
os.write("403 Not Allowed\r\n\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
|
os.flush()
|
||||||
|
e.close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
long timestamp = 0
|
long timestamp = 0
|
||||||
if (headers.containsKey("Timestamp")) {
|
if (headers.containsKey("Timestamp")) {
|
||||||
|
@ -555,7 +564,6 @@ class ConnectionAcceptor {
|
||||||
|
|
||||||
List<SharedFile> published = fileManager.getPublishedSince(timestamp)
|
List<SharedFile> published = fileManager.getPublishedSince(timestamp)
|
||||||
|
|
||||||
OutputStream os = e.getOutputStream()
|
|
||||||
os.write("200 OK\r\n".getBytes(StandardCharsets.US_ASCII))
|
os.write("200 OK\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
os.write("Count: ${published.size()}\r\n".getBytes(StandardCharsets.US_ASCII));
|
os.write("Count: ${published.size()}\r\n".getBytes(StandardCharsets.US_ASCII));
|
||||||
os.write("\r\n".getBytes(StandardCharsets.US_ASCII))
|
os.write("\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
|
|
|
@ -138,6 +138,8 @@ class ResultsSender {
|
||||||
os.write("Count: $results.length\r\n".getBytes(StandardCharsets.US_ASCII))
|
os.write("Count: $results.length\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
boolean chat = chatServer.running.get() && settings.advertiseChat
|
boolean chat = chatServer.running.get() && settings.advertiseChat
|
||||||
os.write("Chat: $chat\r\n".getBytes(StandardCharsets.US_ASCII))
|
os.write("Chat: $chat\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
|
boolean feed = settings.fileFeed && settings.advertiseFeed
|
||||||
|
os.write("Feed: $feed\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
os.write("\r\n".getBytes(StandardCharsets.US_ASCII))
|
os.write("\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||||
DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(os))
|
DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(os))
|
||||||
results.each {
|
results.each {
|
||||||
|
|
Loading…
Reference in New Issue