Skip to content

Commit dfed0a6

Browse files
committed
introduced instance_config_override for instance customization with easy default to instance_config in repository
1 parent 0cf0bc1 commit dfed0a6

3 files changed

Lines changed: 102 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
config.py
2+
instance_config_override.py
23
run.py
34
migrations/
45

flowapp/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ def create_app(config_object=None):
3030
if config_object:
3131
app.config.from_object(config_object)
3232

33+
# Allow override of instance config from external file
34+
try:
35+
app.config.from_pyfile("../instance_config_override.py", silent=False)
36+
except FileNotFoundError:
37+
pass # No override file, use defaults
38+
3339
app.config.setdefault("VERSION", __version__)
3440

3541
# SSO configuration
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Example instance config override
2+
# Copy this to instance_config_override.py and customize
3+
4+
5+
# column names for tables
6+
RTBH_COLUMNS = (
7+
("ipv4", "IP address (v4 or v6)"),
8+
("community_id", "Community"),
9+
("expires", "Expires"),
10+
("user_id", "User"),
11+
)
12+
13+
WHITELIST_COLUMNS = (
14+
("address", "IP address / network (v4 or v6)"),
15+
("expires", "Expires"),
16+
("user_id", "User"),
17+
)
18+
19+
20+
RULES_COLUMNS_V4 = (
21+
("source", "Source addr."),
22+
("source_port", "S port"),
23+
("dest", "Dest. addr."),
24+
("dest_port", "D port"),
25+
("protocol", "Proto"),
26+
("packet_len", "Packet len"),
27+
("expires", "Expires"),
28+
("action_id", "Action"),
29+
("flags", "Flags"),
30+
("user_id", "User"),
31+
)
32+
33+
RULES_COLUMNS_V6 = (
34+
("source", "Source addr."),
35+
("source_port", "S port"),
36+
("dest", "Dest. addr."),
37+
("dest_port", "D port"),
38+
("next_header", "Next header"),
39+
("packet_len", "Packet len"),
40+
("expires", "Expires"),
41+
("action_id", "Action"),
42+
("flags", "Flags"),
43+
("user_id", "User"),
44+
)
45+
46+
47+
# Customize main menu
48+
MAIN_MENU = {
49+
"edit": [
50+
{"name": "Add RTBH", "url": "rules.rtbh_rule"},
51+
{"name": "Add Whitelist", "url": "whitelist.add"},
52+
{"name": "API Key", "url": "api_keys.all"},
53+
],
54+
"admin": [
55+
{"name": "Commands Log", "url": "admin.log"},
56+
{"name": "Machine keys", "url": "admin.machine_keys"},
57+
{
58+
"name": "Users",
59+
"url": "admin.users",
60+
"divide_before": True,
61+
},
62+
{"name": "Add User", "url": "admin.user"},
63+
{"name": "Add Multiple Users", "url": "admin.bulk_import_users"},
64+
{"name": "Organizations", "url": "admin.organizations"},
65+
{"name": "Add Org.", "url": "admin.organization"},
66+
{
67+
"name": "Action",
68+
"url": "admin.actions",
69+
"divide_before": True,
70+
},
71+
{"name": "Add action", "url": "admin.action"},
72+
{"name": "RTBH Communities", "url": "admin.communities"},
73+
{"name": "Add RTBH Comm.", "url": "admin.community"},
74+
],
75+
}
76+
77+
# Customize dashboard - only include what you need
78+
DASHBOARD = {
79+
"rtbh": {
80+
"name": "RTBH",
81+
"macro_file": "macros.html",
82+
"macro_tbody": "build_rtbh_tbody",
83+
"macro_thead": "build_rules_thead",
84+
"table_colspan": 5,
85+
"table_columns": RTBH_COLUMNS,
86+
},
87+
"whitelist": {
88+
"name": "Whitelist",
89+
"macro_file": "macros.html",
90+
"macro_tbody": "build_whitelist_tbody",
91+
"macro_thead": "build_rules_thead",
92+
"table_colspan": 4,
93+
"table_columns": WHITELIST_COLUMNS,
94+
},
95+
}

0 commit comments

Comments
 (0)