Add option for bridge to create new judge
This commit is contained in:
parent
daee631ef6
commit
1e88e73082
3 changed files with 15 additions and 4 deletions
|
@ -381,6 +381,7 @@ BRIDGED_JUDGE_ADDRESS = [("localhost", 9999)]
|
||||||
BRIDGED_JUDGE_PROXIES = None
|
BRIDGED_JUDGE_PROXIES = None
|
||||||
BRIDGED_DJANGO_ADDRESS = [("localhost", 9998)]
|
BRIDGED_DJANGO_ADDRESS = [("localhost", 9998)]
|
||||||
BRIDGED_DJANGO_CONNECT = None
|
BRIDGED_DJANGO_CONNECT = None
|
||||||
|
BRIDGED_AUTO_CREATE_JUDGE = False
|
||||||
|
|
||||||
# Event Server configuration
|
# Event Server configuration
|
||||||
EVENT_DAEMON_USE = False
|
EVENT_DAEMON_USE = False
|
||||||
|
|
|
@ -123,8 +123,18 @@ class JudgeHandler(ZlibPacketHandler):
|
||||||
|
|
||||||
def _authenticate(self, id, key):
|
def _authenticate(self, id, key):
|
||||||
try:
|
try:
|
||||||
judge = Judge.objects.get(name=id, is_blocked=False)
|
judge = Judge.objects.get(name=id)
|
||||||
except Judge.DoesNotExist:
|
except Judge.DoesNotExist:
|
||||||
|
if settings.BRIDGED_AUTO_CREATE_JUDGE:
|
||||||
|
judge = Judge()
|
||||||
|
judge.name = id
|
||||||
|
judge.auth_key = key
|
||||||
|
judge.save()
|
||||||
|
result = True
|
||||||
|
else:
|
||||||
|
result = False
|
||||||
|
else:
|
||||||
|
if judge.is_blocked:
|
||||||
result = False
|
result = False
|
||||||
else:
|
else:
|
||||||
result = hmac.compare_digest(judge.auth_key, key)
|
result = hmac.compare_digest(judge.auth_key, key)
|
||||||
|
|
|
@ -26,7 +26,7 @@ pyotp
|
||||||
qrcode[pil]
|
qrcode[pil]
|
||||||
jsonfield @ git+https://github.com/DMOJ/jsonfield.git
|
jsonfield @ git+https://github.com/DMOJ/jsonfield.git
|
||||||
pymoss
|
pymoss
|
||||||
packaging<23
|
packaging<22
|
||||||
celery
|
celery
|
||||||
ansi2html @ git+https://github.com/DMOJ/ansi2html.git
|
ansi2html @ git+https://github.com/DMOJ/ansi2html.git
|
||||||
sqlparse
|
sqlparse
|
||||||
|
|
Loading…
Reference in a new issue