summaryrefslogtreecommitdiff
path: root/server.py
diff options
context:
space:
mode:
Diffstat (limited to 'server.py')
-rwxr-xr-xserver.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/server.py b/server.py
index 4b72f83..32f022a 100755
--- a/server.py
+++ b/server.py
@@ -6,6 +6,7 @@ import argparse
import functions
import logging
from http.server import BaseHTTPRequestHandler, HTTPServer
+from socketserver import ThreadingMixIn
logging.basicConfig(level=logging.INFO)
@@ -21,6 +22,10 @@ def send_token(conf, username, orig_uri):
functions.send_message(conf.jid, conf.password, username, message)
+class ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
+ pass
+
+
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
global LAST_REQUEST_TIME, CACHE
@@ -38,6 +43,7 @@ class RequestHandler(BaseHTTPRequestHandler):
LAST_REQUEST_TIME = time.time()
send_token(conf, username, self.headers['X-Original-URI'])
self.send_response(401, "Token sent, retry")
+ self.send_header("WWW-Authenticate", "Basic realm=\"xmppmessage auth\"")
else:
self.send_response(429, 'Too Many Requests')
else:
@@ -47,7 +53,7 @@ class RequestHandler(BaseHTTPRequestHandler):
self.send_response(200, "OK go forward")
else:
logging.info("Denied %s", username)
- self.send_response(401, "Authentication failed, username or password wrong")
+ self.send_response(403, "Authentication failed, username or password wrong")
else:
self.send_response(401)
self.send_header("WWW-Authenticate", "Basic realm=\"xmppmessage auth\"")