diff --git a/.gitignore b/.gitignore index 2418788..7da19a1 100644 --- a/.gitignore +++ b/.gitignore @@ -122,4 +122,7 @@ website/web/static/d3*.js # Same got bootstrap-select website/web/static/bootstrap-select* +# Session key +website/secret_key + *.swp diff --git a/README.md b/README.md index 9b1ece3..a5d3ed2 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ New version of BGP Ranking, complete rewrite in python3.6+ and an ARDB backend ```bash git clone https://github.com/antirez/redis.git cd redis -git checkout 4.0 +git checkout 5.0 make make test cd .. @@ -23,11 +23,11 @@ cd .. ```bash git clone https://github.com/yinqiwen/ardb.git cd ardb -make +DISABLE_WARNING_AS_ERROR=1 make # ardb (more precisely rocksdb) doesn't compile on ubuntu 18.04 unless you disable warning as error cd .. ``` -## Install BGP Ranking +## Install & run BGP Ranking ```bash git clone https://github.com/D4-project/BGP-Ranking.git @@ -41,6 +41,12 @@ start.py start_website.py ``` +## Shutdown BGP Ranking + +```bash +stop.py +``` + # Directory structure *Config files*: `bgpranking / config / *.json` diff --git a/website/web/__init__.py b/website/web/__init__.py index d21f5c4..2c83b92 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -7,6 +7,8 @@ try: except ImportError: import json +import os + import requests from flask import Flask, render_template, request, session, Response, redirect, url_for @@ -14,14 +16,21 @@ from flask_bootstrap import Bootstrap from bgpranking.querying import Querying from bgpranking.libs.exceptions import MissingConfigEntry -from bgpranking.libs.helpers import load_general_config +from bgpranking.libs.helpers import load_general_config, get_homedir from datetime import date, timedelta import pycountry from collections import defaultdict app = Flask(__name__) -app.secret_key = '\xeb\xfd\x1b\xee\xed<\xa5~\xd5H\x85\x00\xa5r\xae\x80t5@\xa2&>\x03S' +secret_file_path = get_homedir() / 'website' / 'secret_key' + +if not secret_file_path.exists() or secret_file_path.stat().st_size < 64: + with open(secret_file_path, 'wb') as f: + f.write(os.urandom(64)) + +with open(secret_file_path, 'rb') as f: + app.config['SECRET_KEY'] = f.read() Bootstrap(app) app.config['BOOTSTRAP_SERVE_LOCAL'] = True