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_DJANGO_ADDRESS = [("localhost", 9998)]
|
||||
BRIDGED_DJANGO_CONNECT = None
|
||||
BRIDGED_AUTO_CREATE_JUDGE = False
|
||||
|
||||
# Event Server configuration
|
||||
EVENT_DAEMON_USE = False
|
||||
|
|
|
@ -123,8 +123,18 @@ class JudgeHandler(ZlibPacketHandler):
|
|||
|
||||
def _authenticate(self, id, key):
|
||||
try:
|
||||
judge = Judge.objects.get(name=id, is_blocked=False)
|
||||
judge = Judge.objects.get(name=id)
|
||||
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
|
||||
else:
|
||||
result = hmac.compare_digest(judge.auth_key, key)
|
||||
|
|
|
@ -26,7 +26,7 @@ pyotp
|
|||
qrcode[pil]
|
||||
jsonfield @ git+https://github.com/DMOJ/jsonfield.git
|
||||
pymoss
|
||||
packaging<23
|
||||
packaging<22
|
||||
celery
|
||||
ansi2html @ git+https://github.com/DMOJ/ansi2html.git
|
||||
sqlparse
|
||||
|
|
Loading…
Reference in a new issue