summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/nat_port_forward
diff options
context:
space:
mode:
Diffstat (limited to 'kpov_judge/tasks/nat_port_forward')
-rw-r--r--kpov_judge/tasks/nat_port_forward/task.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/kpov_judge/tasks/nat_port_forward/task.py b/kpov_judge/tasks/nat_port_forward/task.py
index a3fc740..0996d97 100644
--- a/kpov_judge/tasks/nat_port_forward/task.py
+++ b/kpov_judge/tasks/nat_port_forward/task.py
@@ -127,13 +127,14 @@ def gen_params(user_id, params_meta):
def task_check(results, params):
import re
import cPickle
- if results is None:
- with open('bla.pickle') as f:
- results = cPickle.load(f)
- else:
- with open('bla.pickle', 'w') as f:
- cPickle.dump(results, f)
+ #if results is None:
+ # with open('bla.pickle') as f:
+ # results = cPickle.load(f)
+ #else:
+ # with open('bla.pickle', 'w') as f:
+ # cPickle.dump(results, f)
score = 0
+ hints = []
local_net = params['NET'][:params['NET'].rfind('.')]
s = "default via ({}\\.[0-9]+)".format(re.escape(local_net))
res = re.search(s, results['route'])
@@ -152,33 +153,33 @@ def task_check(results, params):
if re.search(s, results['traceroute'], re.DOTALL):
score += 1
else:
- print (s, results['traceroute'],)
+ hints += [s + str(results['traceroute'])]
if len(results['post_nc']) == 100:
score += 1
else:
- print (results['post_nc'], len(results['post_nc']))
+ hints += [str(results['post_nc']) + str(len(results['post_nc']))]
if results['nc_ret'] == (results['post_nc'] + '\n').replace('\n', '\r\n'):
score += 1
else:
- print (results['post_nc'], results['nc_ret'],)
+ hints += ['wrong nc']
s = "Connection refused"
res = re.findall(s, results['nc_pre'])
if len(res) >= 2:
score += 3
else:
- print (s, results['nc_pre'],)
+ hints += [s + str(results['nc_pre'])]
s = "\r\n"
if re.search(s, results['nc_post']):
score += 1
else:
- print (s, results['nc_post'],)
+ hints += [s + str(results['nc_post'])]
rejected_count = int(results['pre_nc'])
accepted_count = results['nc_ret'].count('\r\n')
s = ".*verbose output suppressed.*listening on.*dropped by kernel.*"
if re.match(s, results['tcpdump'], re.DOTALL):
score += 1
else:
- print (s, results['tcpdump'],)
+ hints += [s + str(results['tcpdump'])]
res = re.findall("length .*\r\n", results['tcpdump'])
total_len = 0
n_empty = 0
@@ -191,8 +192,8 @@ def task_check(results, params):
if total_len == 101 and rejected_count <= n_empty:
score += 1
else:
- print (s, results['tcpdump'],)
- return score
+ hints += [s + str(results['tcpdump'])]
+ return score, hints
def prepare_disks(templates, params):
# d = templates['simpleArbiterDhcp']