Skip to content

Commit

Permalink
Removed memory limit
Browse files Browse the repository at this point in the history
  • Loading branch information
elceef committed Jan 16, 2024
1 parent 4b9fd9d commit 435429f
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions webapp/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,15 @@
import time
import threading
from flask import Flask, request, jsonify, send_from_directory
import resource
import dnstwist


def human_to_bytes(size):
units = {'b': 1, 'k': 2**10, 'm': 2**20, 'g': 2**30}
u = size[-1].lower()
if u.isdigit():
return int(size)
return int(size[:-1]) * units.get(u, 1)

PORT = int(os.environ.get('PORT', 8000))
HOST= os.environ.get('HOST', '127.0.0.1')
THREADS = int(os.environ.get('THREADS', dnstwist.THREAD_COUNT_DEFAULT))
NAMESERVERS = os.environ.get('NAMESERVERS') or os.environ.get('NAMESERVER')
SESSION_TTL = int(os.environ.get('SESSION_TTL', 3600))
SESSION_MAX = int(os.environ.get('SESSION_MAX', 10)) # max concurrent sessions
MEMORY_LIMIT = human_to_bytes(os.environ.get('MEMORY_LIMIT', '0'))
DOMAIN_MAXLEN = int(os.environ.get('DOMAIN_MAXLEN', 15))
WEBAPP_HTML = os.environ.get('WEBAPP_HTML', 'webapp.html')
WEBAPP_DIR = os.environ.get('WEBAPP_DIR', os.path.dirname(os.path.abspath(__file__)))
Expand All @@ -65,10 +56,6 @@ def janitor(sessions):
if (s.timestamp + SESSION_TTL) < time.time():
sessions.remove(s)
continue
if MEMORY_LIMIT:
maxrss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss * 1024
if not s.threads and maxrss > MEMORY_LIMIT:
sessions.remove(s)

class Session():
def __init__(self, url, nameservers=None, thread_count=THREADS):
Expand Down

0 comments on commit 435429f

Please sign in to comment.