Squid url redirector

Diff
anonymous

Diff

Differences From Artifact [1d253fe455]:

To Artifact [15ab41beb3]:


60
61
62
63
64
65
66

67
68
69
70
71







72
73
74
75
76
77
78
60
61
62
63
64
65
66
67





68
69
70
71
72
73
74
75
76
77
78
79
80
81







+
-
-
-
-
-
+
+
+
+
+
+
+







		result = self._db.check(site, ip_address)
		#reply = '{}://{}/{}'.format(req[4], req[1], req[3])
		reply = '-'
		for row in result:
			if row != None and row[0] != None:
				if row[1] != None:
					self._log.info('trying regexp "{}" versus "{}"\n'.format(row[1], url_path))
					try:
					if re.compile(row[1]).match(url_path):
						reply = '302:' + row[0]
						break
					else:
						continue
						if re.compile(row[1]).match(url_path):
							reply = '302:' + row[0]
							break
						else:
							continue
					except:
						self._log.info("can't compile regexp")
				else:
					reply = '302:' + row[0]
					break
		self.writeline('{} {}\n'.format(id, reply))

	def check(self, line):
		request = re.compile('^([0-9]+)\ (http|ftp):\/\/([-\w.:]+)\/([^ ]*)\ ([0-9.]+)\/(-|[\w\.]+)\ (-|\w+)\ (-|GET|HEAD|POST).*$').match(line)