mirror of
https://github.com/ail-project/ail-framework.git
synced 2025-02-17 06:46:25 +00:00
fix: [Onion] add timeout signal
This commit is contained in:
parent
f4ba21e492
commit
535f44044d
2 changed files with 30 additions and 9 deletions
18
bin/Onion.py
18
bin/Onion.py
|
@ -29,10 +29,18 @@ import os
|
||||||
import base64
|
import base64
|
||||||
import subprocess
|
import subprocess
|
||||||
import redis
|
import redis
|
||||||
|
import signal
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from Helper import Process
|
from Helper import Process
|
||||||
|
|
||||||
|
class TimeoutException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def timeout_handler(signum, frame):
|
||||||
|
raise TimeoutException
|
||||||
|
|
||||||
|
signal.signal(signal.SIGALRM, timeout_handler)
|
||||||
|
|
||||||
def fetch(p, r_cache, urls, domains, path):
|
def fetch(p, r_cache, urls, domains, path):
|
||||||
failed = []
|
failed = []
|
||||||
|
@ -113,6 +121,8 @@ if __name__ == "__main__":
|
||||||
message = p.get_from_set()
|
message = p.get_from_set()
|
||||||
prec_filename = None
|
prec_filename = None
|
||||||
|
|
||||||
|
max_execution_time = p.config.getint("Onion", "max_execution_time")
|
||||||
|
|
||||||
# send to crawler:
|
# send to crawler:
|
||||||
activate_crawler = p.config.get("Crawler", "activate_crawler")
|
activate_crawler = p.config.get("Crawler", "activate_crawler")
|
||||||
if activate_crawler == 'True':
|
if activate_crawler == 'True':
|
||||||
|
@ -140,6 +150,9 @@ if __name__ == "__main__":
|
||||||
urls = []
|
urls = []
|
||||||
PST = Paste.Paste(filename)
|
PST = Paste.Paste(filename)
|
||||||
|
|
||||||
|
# max execution time on regex
|
||||||
|
signal.alarm(max_execution_time)
|
||||||
|
try:
|
||||||
for x in PST.get_regex(url_regex):
|
for x in PST.get_regex(url_regex):
|
||||||
print(x)
|
print(x)
|
||||||
# Extracting url with regex
|
# Extracting url with regex
|
||||||
|
@ -150,6 +163,11 @@ if __name__ == "__main__":
|
||||||
print(url)
|
print(url)
|
||||||
domains_list.append(domain)
|
domains_list.append(domain)
|
||||||
urls.append(url)
|
urls.append(url)
|
||||||
|
except TimeoutException:
|
||||||
|
encoded_list = []
|
||||||
|
p.incr_module_timeout_statistic()
|
||||||
|
print ("{0} processing timeout".format(PST.p_path))
|
||||||
|
continue
|
||||||
|
|
||||||
'''
|
'''
|
||||||
for x in PST.get_regex(i2p_regex):
|
for x in PST.get_regex(i2p_regex):
|
||||||
|
|
|
@ -68,6 +68,9 @@ minTopPassList=5
|
||||||
[Curve]
|
[Curve]
|
||||||
max_execution_time = 90
|
max_execution_time = 90
|
||||||
|
|
||||||
|
[Onion]
|
||||||
|
max_execution_time = 180
|
||||||
|
|
||||||
[Base64]
|
[Base64]
|
||||||
path = Base64/
|
path = Base64/
|
||||||
max_execution_time = 60
|
max_execution_time = 60
|
||||||
|
|
Loading…
Add table
Reference in a new issue