Пример #1
0
    def update_timer():
        retries = 0
        while retries < CHECK_CONNECTION_MAX_RETRIES and not check_connection():
            sys.stdout.write("[!] can't update because of lack of network connection (waiting..." if not retries else '.')
            sys.stdout.flush()
            time.sleep(10)
            retries += 1

        if retries:
            print(")")

        if retries == CHECK_CONNECTION_MAX_RETRIES:
            print("[x] going to continue without update")
            _ = {}
        else:
            _ = update_trails(server=config.UPDATE_SERVER)

            update_ipcat()

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
Пример #2
0
    def update_timer():
        retries = 0
        while retries < CHECK_CONNECTION_MAX_RETRIES and not check_connection():
            sys.stdout.write("[!] can't update because of lack of network connection (waiting..." if not retries else '.')
            sys.stdout.flush()
            time.sleep(10)
            retries += 1

        if retries:
            print(")")

        if retries == CHECK_CONNECTION_MAX_RETRIES:
            print("[x] going to continue without update")
            _ = {}
        else:
            _ = update_trails(server=config.UPDATE_SERVER)

            update_ipcat()

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
Пример #3
0
    def update_timer():
        retries = 0
        if not config.no_updates:
            while retries < CHECK_CONNECTION_MAX_RETRIES and not check_connection():
                sys.stdout.write("[ERROR]: can't update because of lack of Internet connection (waiting..." if not retries else '.')
                sys.stdout.flush()
                time.sleep(10)
                retries += 1

            if retries:
                sys.stdout.write(")\n")

        if config.no_updates or retries == CHECK_CONNECTION_MAX_RETRIES:
            if retries == CHECK_CONNECTION_MAX_RETRIES:
                logger.error("going to continue without online update")
            _ = update_trails(offline=True)
        else:
            _ = update_trails(server=config.UPDATE_SERVER)
            update_ipcat()

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.start()
Пример #4
0
    def update_timer():
        _ = update(server=config.UPDATE_SERVER)

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
 def update_timer():
     if (time.time() - os.stat(TRAILS_FILE).st_mtime) >= config.UPDATE_PERIOD:
         _ = None
         while True:
             _ = load_trails(True)
             if _:
                 trails.clear()
                 trails.update(_)
                 break
             else:
                 time.sleep(LOAD_TRAILS_RETRY_SLEEP_TIME)
     threading.Timer(config.UPDATE_PERIOD, update_timer).start()
Пример #6
0
    def update_timer():
        _ = update(server=config.UPDATE_SERVER)

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
Пример #7
0
 def update_timer():
     # 查看trail.csv的上一次修改时间,差1天更新,其实这里的trails已经在初始化阶段加入了trail.csv的内容。
     # **只是利用这个函数来读取trail.csv的新内容**
     # 因为只是读,所以没有加锁。所以主线程1天更新一次,多线程采用读来同步trails的状态。
     if (time.time() -
             os.stat(config.TRAILS_FILE).st_mtime) >= config.UPDATE_PERIOD:
         _ = None
         while True:
             _ = load_trails(True)
             if _:
                 trails.clear()
                 trails.update(_)
                 break
             else:
                 time.sleep(LOAD_TRAILS_RETRY_SLEEP_TIME)
     # 1天后再次执行
     threading.Timer(config.UPDATE_PERIOD, update_timer).start()
Пример #8
0
    def update_timer():
        first = True
        while not check_connection():
            sys.stdout.write("[!] can't update because of lack of network connection (waiting..." if first else '.')
            sys.stdout.flush()
            time.sleep(60)
            first = False

        if not first:
            print(")")

        _ = update_trails(server=config.UPDATE_SERVER)

        update_ipcat()

        if _:
            trails.clear()
            trails.update(_)
        elif not trails:
            trails.update(load_trails())

        thread = threading.Timer(config.UPDATE_PERIOD, update_timer)
        thread.daemon = True
        thread.start()
Пример #9
0
from core.settings import trails
import sys
from core.common import load_trails

trails.update(load_trails())
'''
trails contains blacklisted strings: domains and Ips
e.g.
mqbbsagabardinedazyx.com
dgj4gu1xmithip.net
moegestnessbiophysicalohax.com
rhmxancorml.com
115.28.7.221
jjcwgfwdyqje.pw
'''
for line in sys.stdin:
    try:
        line = line.strip()
        data = line.split(',')
        if data[5] in trails or data[9] in trails:
            print str(data[6]) + "," + str(100)
        else:
            print str(data[6]) + "," + str(0)
    except:
        print line
Пример #10
0
from core.settings import trails
import sys
from core.common import load_trails

trails.update(load_trails())
'''
trails contains blacklisted strings: domains and Ips
e.g.
mqbbsagabardinedazyx.com
dgj4gu1xmithip.net
moegestnessbiophysicalohax.com
rhmxancorml.com
115.28.7.221
jjcwgfwdyqje.pw
'''
for line in sys.stdin:
	try:
	  line = line.strip()
	  data = line.split(',')
	  if data[5] in trails or data[9] in trails:
		print str(data[6])+","+str(100)
	  else:
	        print str(data[6])+","+str(0)
	except:
	  print line