Skip to content

Commit 892d35f

Browse files
author
majestrate
authored
Merge pull request #49 from ianmacd/pr1
Add new config Boolean, http_show_index, for room directory display.
2 parents c3cffb1 + cd30e8a commit 892d35f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

sogs.ini.sample

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
;omq_internal = ipc://./omq.sock
4444

4545

46+
; Whether we should show an index of public rooms on the root URL when visited by a
47+
; browser.
48+
;
49+
;http_show_index = yes
50+
51+
4652
; Whether we should show recent messages for public rooms on the sogs room page when visited by a
4753
; browser.
4854
;

sogs/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
DB_SCHEMA_FILE = 'schema.sql' # Not configurable, just a constant
1515
KEY_FILE = 'key_x25519'
1616
URL_BASE = 'http://example.net'
17+
HTTP_SHOW_INDEX = True
1718
HTTP_SHOW_RECENT = True
1819
OMQ_LISTEN = 'tcp://*:22028'
1920
OMQ_INTERNAL = 'ipc://./omq.sock'
@@ -83,6 +84,7 @@ def load_config():
8384
lambda x: [y for y in x.splitlines() if len(y)],
8485
),
8586
'omq_internal': ('OMQ_INTERNAL', lambda x: re.search('^(?:tcp|ipc)://.', x)),
87+
'http_show_index': bool_opt('HTTP_SHOW_INDEX'),
8688
'http_show_recent': bool_opt('HTTP_SHOW_RECENT'),
8789
},
8890
'files': {

sogs/routes/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def serve_index():
3030
rooms = get_readable_rooms()
3131
if len(rooms) == 0:
3232
return render_template('setup.html')
33+
if not config.HTTP_SHOW_INDEX:
34+
abort(http.FORBIDDEN)
3335
return render_template(
3436
"index.html", url_base=config.URL_BASE, rooms=rooms, pubkey=crypto.server_pubkey_hex
3537
)

0 commit comments

Comments
 (0)