Dropped HTTP reply support (not working)
This commit is contained in:
parent
36d2b432b9
commit
0b5b8811b4
@ -177,8 +177,6 @@ en = {
|
|||||||
"server-motd-argument": "path to file from which motd will be fetched",
|
"server-motd-argument": "path to file from which motd will be fetched",
|
||||||
"server-messed-up-motd-unescaped-placeholders": "Message of the Day has unescaped placeholders. All $ signs should be doubled ($$).",
|
"server-messed-up-motd-unescaped-placeholders": "Message of the Day has unescaped placeholders. All $ signs should be doubled ($$).",
|
||||||
"server-messed-up-motd-too-long": "Message of the Day is too long - maximum of {} chars, {} given.",
|
"server-messed-up-motd-too-long": "Message of the Day is too long - maximum of {} chars, {} given.",
|
||||||
"server-http-reply-argument": "path to file from which http reply will be fetched",
|
|
||||||
"server-default-http-reply": "This server should not be requested with your browser, but with Syncplay software available from http://syncplay.pl",
|
|
||||||
"server-irc-verbose": "Should server actively report changes in rooms",
|
"server-irc-verbose": "Should server actively report changes in rooms",
|
||||||
"server-irc-config": "Path to irc bot config files",
|
"server-irc-config": "Path to irc bot config files",
|
||||||
|
|
||||||
|
|||||||
@ -32,11 +32,7 @@ class JSONCommandProtocol(LineReceiver):
|
|||||||
try:
|
try:
|
||||||
messages = json.loads(line)
|
messages = json.loads(line)
|
||||||
except:
|
except:
|
||||||
if ("GET / HTTP/1." in line):
|
self.dropWithError(getMessage("en", "not-json-server-error").format(line))
|
||||||
self.handleHttpRequest(line)
|
|
||||||
self.drop()
|
|
||||||
else:
|
|
||||||
self.dropWithError(getMessage("en", "not-json-server-error").format(line))
|
|
||||||
return
|
return
|
||||||
self.handleMessages(messages)
|
self.handleMessages(messages)
|
||||||
|
|
||||||
@ -190,9 +186,6 @@ class SyncClientProtocol(JSONCommandProtocol):
|
|||||||
position, paused, doSeek, stateChange = self._client.getLocalState()
|
position, paused, doSeek, stateChange = self._client.getLocalState()
|
||||||
self.sendState(position, paused, doSeek, latencyCalculation, stateChange)
|
self.sendState(position, paused, doSeek, latencyCalculation, stateChange)
|
||||||
|
|
||||||
def handleHttpRequest(self, request):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def sendState(self, position, paused, doSeek, latencyCalculation, stateChange=False):
|
def sendState(self, position, paused, doSeek, latencyCalculation, stateChange=False):
|
||||||
state = {}
|
state = {}
|
||||||
positionAndPausedIsSet = position is not None and paused is not None
|
positionAndPausedIsSet = position is not None and paused is not None
|
||||||
@ -413,9 +406,6 @@ class SyncServerProtocol(JSONCommandProtocol):
|
|||||||
if(self.serverIgnoringOnTheFly == 0):
|
if(self.serverIgnoringOnTheFly == 0):
|
||||||
self._factory.updateWatcherState(self, position, paused, doSeek, self._pingService.getLastForwardDelay())
|
self._factory.updateWatcherState(self, position, paused, doSeek, self._pingService.getLastForwardDelay())
|
||||||
|
|
||||||
def handleHttpRequest(self, request):
|
|
||||||
self.sendLine(self._factory.gethttpRequestReply())
|
|
||||||
|
|
||||||
def handleError(self, error):
|
def handleError(self, error):
|
||||||
self.dropWithError(error["message"]) # TODO: more processing and fallbacking
|
self.dropWithError(error["message"]) # TODO: more processing and fallbacking
|
||||||
|
|
||||||
@ -443,9 +433,9 @@ class PingService(object):
|
|||||||
self._avrRtt = self._rtt
|
self._avrRtt = self._rtt
|
||||||
self._avrRtt = self._avrRtt * PING_MOVING_AVERAGE_WEIGHT + self._rtt * (1 - PING_MOVING_AVERAGE_WEIGHT)
|
self._avrRtt = self._avrRtt * PING_MOVING_AVERAGE_WEIGHT + self._rtt * (1 - PING_MOVING_AVERAGE_WEIGHT)
|
||||||
if(senderRtt < self._rtt):
|
if(senderRtt < self._rtt):
|
||||||
self._fd = self._avrRtt/2 + (self._rtt - senderRtt)
|
self._fd = self._avrRtt / 2 + (self._rtt - senderRtt)
|
||||||
else:
|
else:
|
||||||
self._fd = self._avrRtt/2
|
self._fd = self._avrRtt / 2
|
||||||
|
|
||||||
def getLastForwardDelay(self):
|
def getLastForwardDelay(self):
|
||||||
return self._fd
|
return self._fd
|
||||||
|
|||||||
@ -14,13 +14,12 @@ from string import Template
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
class SyncFactory(Factory):
|
class SyncFactory(Factory):
|
||||||
def __init__(self, password='', motdFilePath=None, httpReplyFilePath=None):
|
def __init__(self, password='', motdFilePath=None):
|
||||||
print getMessage("en", "welcome-server-notification").format(syncplay.version)
|
print getMessage("en", "welcome-server-notification").format(syncplay.version)
|
||||||
if(password):
|
if(password):
|
||||||
password = hashlib.md5(password).hexdigest()
|
password = hashlib.md5(password).hexdigest()
|
||||||
self.password = password
|
self.password = password
|
||||||
self._motdFilePath = motdFilePath
|
self._motdFilePath = motdFilePath
|
||||||
self._httpReplyFilePath = httpReplyFilePath
|
|
||||||
self._rooms = {}
|
self._rooms = {}
|
||||||
self._roomStates = {}
|
self._roomStates = {}
|
||||||
self._roomUpdate = threading.RLock()
|
self._roomUpdate = threading.RLock()
|
||||||
@ -108,13 +107,6 @@ class SyncFactory(Factory):
|
|||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def gethttpRequestReply(self):
|
|
||||||
if(self._httpReplyFilePath and os.path.isfile(self._httpReplyFilePath)):
|
|
||||||
tmpl = codecs.open(self._httpReplyFilePath, "r", "utf-8-sig").read()
|
|
||||||
return tmpl.encode('utf-8')
|
|
||||||
else:
|
|
||||||
return getMessage("en", "server-default-http-reply")
|
|
||||||
|
|
||||||
def sendState(self, watcherProtocol, doSeek=False, forcedUpdate=False):
|
def sendState(self, watcherProtocol, doSeek=False, forcedUpdate=False):
|
||||||
watcher = self.getWatcher(watcherProtocol)
|
watcher = self.getWatcher(watcherProtocol)
|
||||||
if(not watcher):
|
if(not watcher):
|
||||||
@ -296,4 +288,3 @@ class ConfigurationGetter(object):
|
|||||||
self._argparser.add_argument('--password', metavar='password', type=str, nargs='?', help=getMessage("en", "server-password-argument"))
|
self._argparser.add_argument('--password', metavar='password', type=str, nargs='?', help=getMessage("en", "server-password-argument"))
|
||||||
self._argparser.add_argument('--isolate-rooms', action='store_true', help=getMessage("en", "server-isolate-room-argument"))
|
self._argparser.add_argument('--isolate-rooms', action='store_true', help=getMessage("en", "server-isolate-room-argument"))
|
||||||
self._argparser.add_argument('--motd-file', metavar='file', type=str, nargs='?', help=getMessage("en", "server-motd-argument"))
|
self._argparser.add_argument('--motd-file', metavar='file', type=str, nargs='?', help=getMessage("en", "server-motd-argument"))
|
||||||
self._argparser.add_argument('--http-reply-file', metavar='file', type=str, nargs='?', help=getMessage("en", "server-http-reply-argument"))
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ argsGetter = ConfigurationGetter()
|
|||||||
args = argsGetter.getConfiguration()
|
args = argsGetter.getConfiguration()
|
||||||
|
|
||||||
if(not args.isolate_rooms):
|
if(not args.isolate_rooms):
|
||||||
reactor.listenTCP(int(args.port), SyncFactory(args.password, args.motd_file, args.http_reply_file))
|
reactor.listenTCP(int(args.port), SyncFactory(args.password, args.motd_file))
|
||||||
else:
|
else:
|
||||||
reactor.listenTCP(int(args.port), SyncIsolatedFactory(args.password, args.motd_file, args.http_reply_file))
|
reactor.listenTCP(int(args.port), SyncIsolatedFactory(args.password, args.motd_file))
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user