config.py 2.47 KB
Newer Older
1
import logging
2 3 4
import os
import threading

5 6
from peewee import MySQLDatabase

Edvard Rejthar's avatar
Edvard Rejthar committed
7 8 9 10
logger = logging.getLogger("mdmaug")


class Pref:
11 12
    safebrowsing = False  # True
    pdns = False  # True
Edvard Rejthar's avatar
Edvard Rejthar committed
13
    geoip = False
14 15
    autoprune = True
    creation_spree = False
Edvard Rejthar's avatar
Edvard Rejthar committed
16
    cache = "oldcache"
Edvard Rejthar's avatar
Edvard Rejthar committed
17 18 19 20 21

    @classmethod
    def val2html(cls, param):
        return "1" if getattr(cls, param) in [True, "true", "1"] else "0"

22

23
class Config:
24
    profile_count = 21  # number of Firefox profiles. Its name is just a number – 0,1...
25
    browser = 'firefox'  # iceweasel, firefox. What browser gets launched.
Edvard Rejthar's avatar
Edvard Rejthar committed
26
    config_file = '/opt/mdmaug/.cache/mdmaug-scans/_tmp/queue.cache'  # RAM disk was too small: '/tmp/mdm/queue.cache'
27 28 29
    APP_PORT = 8000
    APP_IP = "217.31.202.41" # "127.0.0.1"  # CHANGE HERE IF NOT RUN ON LOCALHOST
    APP_HOST = f'https://{APP_IP}:{APP_PORT}'  # YOU MAY NEED TO CHANGE **https**
30 31
    LOG_DIR = "/opt/mdmaug/.cache/mdmaug-scans/_tmp/"
    CACHE_DIR = "/opt/mdmaug/.cache/mdmaug-scans/"
32 33 34
    ALLOWED_DESTINATION = {"mdm.nic.cz": "https://mdm.nic.cz",
                           # "hostname": "scheme://hostname(:port)"; allowed destinations for iframe-postMessage communication between MDMaug and MDM host
                           APP_IP: APP_HOST}  # in every case we allow MDMaug to communicate with itself
35
    DIR = os.path.dirname(os.path.realpath(__file__)) + "/../"
36 37
    db: MySQLDatabase = None
    lock = threading.RLock()
38
    THUMBNAIL_SIZE = 640, 640
39
    MAX_WHOIS_DOMAIN_THREADS = 10  # spusti maximalne 10 threadu doraz, jednou mi to totiz preteklo (kazda domena spusti jeste tolik threadu, kolik ma IP, ale tech byva jen par)
40
    MAX_BROWSER_RUN_TIME = 45  # maximum time for a browser to run
41
    MAX_BROWSER_EXPIRATION = 15  # seconds that we wait before killing the browser (waiting for the files to be written)
42 43
    EXPORT_NOTBLOCK_TLD = ".cz"  # lowercase; this TLD is ignored in the export
    CRAWL_FILE = "analysis.json"
44
    SCREENSHOT_FILE = "screenshot.base64"
45

Edvard Rejthar's avatar
Edvard Rejthar committed
46
    @staticmethod
47 48 49
    def connect():
        # XX resim problem peewee.OperationalError: (2006, "MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))") po 7 hodinach timeoutu
        # XX kupodivu pripojeni nemuze byt v dbp DBModel.connect. Prestoze type je pak spravne (MySQLDatabase), nic udelat nejde a pokusy o select konci NoneType.
Edvard Rejthar's avatar
Edvard Rejthar committed
50
        logger.debug("Connecting to DB.")
51 52
        # XX dal jsem pryc: , threadlocals=False
        Config.db = MySQLDatabase("mdmaug", host='localhost', port=3306, user="mdmaug", passwd="fidFDSs676")