-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathsendcommand.py
43 lines (38 loc) · 1.04 KB
/
sendcommand.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import models
import config
import time
from hashlib import md5
import json
import serverinfo
from google.appengine.ext import webapp
"""
{
"info": {
"name": "<name>",
"start_utc": <long>
},
"command": {
"command": "<command name>",
"<arg0 name>": "<arg0 value>",
"<arg1 name>": "<arg1 value>"
// etc
}
}
"""
class SendCommand(webapp.RequestHandler):
def post(self):
hash = self.request.body[:32]
j = self.request.body[32:]
m = md5(j + config.SENDCOMMAND_SECRET)
if m.hexdigest() == hash:
c = json.loads(j)
serverinfo.ServerInfo.send_command(c['info'],
json.dumps(c['command']))
if config.is_debug():
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('ok')
else:
if config.is_debug():
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('not ok')