Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b352ca6

Browse files
committed
minor fixes, improve docs
1 parent 0752b94 commit b352ca6

11 files changed

Lines changed: 42 additions & 23 deletions

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ It is recommended to use [r8-example](https://github.com/mhils/r8-example) as a
107107
and place challenges in a new separate repository. See `r8.builtin_challenges` and `r8_example`
108108
for challenge examples.
109109

110-
# Architecture
110+
## Architecture
111111

112112
r8 consists of the following parts:
113113
1. The core **`r8` application** written in Python, which manages the currently active challenges.
@@ -123,3 +123,11 @@ r8 consists of the following parts:
123123

124124
To speed up development, the server can be automatically reloaded on changes using [modd](https://github.com/cortesi/modd).
125125

126+
## Deployment
127+
128+
For production use, it is recommended to place it behind a TLS-terminating reverse
129+
proxy such as nginx. A couple of auxiliary examples are provided in the [./misc](./misc) folder:
130+
131+
- `crontab`: crontab example to make daily backups.
132+
- `nginx.conf`: nginx configuration example for a HTTPS-only deployment.
133+
- `r8.service`: systemd service file example.

docs/build.py

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
13
import os
24
import shutil
35

docs/index.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,21 @@ <h3>Challenge Description Helpers<a class="headerlink" href="#challenge-descript
216216
<dl class="function">
217217
<dt id="r8.util.media">
218218
<code class="descclassname">r8.util.</code><code class="descname">media</code><span class="sig-paren">(</span><em>src</em>, <em>desc</em>, <em>visible: bool = True</em><span class="sig-paren">)</span><a class="headerlink" href="#r8.util.media" title="Permalink to this definition"></a></dt>
219-
<dd><p>HTML boilerplate for a bootstrap media element. Commonly used to display challenge icons.</p>
219+
<dd><blockquote>
220+
<div>HTML boilerplate for a bootstrap media element. Commonly used to display challenge icons.</div></blockquote>
221+
<table class="docutils field-list" frame="void" rules="none">
222+
<col class="field-name" />
223+
<col class="field-body" />
224+
<tbody valign="top">
225+
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
226+
<li><strong>src</strong> – Path to image.</li>
227+
<li><strong>desc</strong> – Media body.</li>
228+
<li><strong>visible</strong> – If <cite>False</cite>, a generic challenge icon will be shown instead.</li>
229+
</ul>
230+
</td>
231+
</tr>
232+
</tbody>
233+
</table>
220234
</dd></dl>
221235

222236
<dl class="function">
@@ -269,7 +283,7 @@ <h3>TCP Server Challenge Helpers<a class="headerlink" href="#tcp-server-challeng
269283
<dl class="function">
270284
<dt id="r8.util.format_address">
271285
<code class="descclassname">r8.util.</code><code class="descname">format_address</code><span class="sig-paren">(</span><em>address: Tuple[str, int]</em><span class="sig-paren">)</span> &#x2192; str<a class="headerlink" href="#r8.util.format_address" title="Permalink to this definition"></a></dt>
272-
<dd><p>Format an (ip, port) address tuple.</p>
286+
<dd><p>Format an <cite>(ip, port)</cite> address tuple.</p>
273287
</dd></dl>
274288

275289
</div>

misc/crontab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# m h dom mon dow command
2-
0 * * * * cd /root && /usr/local/bin/r8 sql stmt SELECT 1 >> /var/log/r8-backup.log 2>&1
2+
0 0 * * * cd /root && /usr/local/bin/r8 sql stmt --backup SELECT 1 >> /var/log/r8-backup.log 2>&1
File renamed without changes.

misc/r8.service

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
[Unit]
2-
Description=r8 autograding system
2+
Description=r8 ctf system
33

44
[Service]
55
Type=simple
6-
ExecStart=/usr/local/bin/r8 run
6+
ExecStart=/usr/local/bin/pipenv run r8 run
77
WorkingDirectory=/root/r8
8-
EnvironmentFile=/root/.r8_secret
98
Restart=always
109

1110
[Install]

misc/status

100644100755
File mode changed.

r8/cli/sql.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ def sql_init(origin, static_dir, listen_address, database) -> None:
102102
@util.database_rows
103103
@click.argument("query", nargs=-1, required=True)
104104
def sql_stmt(rows, query):
105-
"""
106-
Run a single SQL query on the database.
107-
There are no safeguards in place here:
108-
If you drop the table, the table is dropped.
109-
"""
105+
"""Run a single SQL query on the database."""
110106
util.run_sql(" ".join(query), rows=rows)
111107

112108

@@ -121,7 +117,6 @@ def sql_stmt(rows, query):
121117
def sql_file(input, debug):
122118
"""
123119
Run a SQL file on the database.
124-
There are no safeguards in place here: If you drop the table, the table is dropped.
125120
Foreign key constraints are deferred until transactions are commited, i.e. the database
126121
can be in an inconsistent state in between.
127122
"""

r8/static/challenge.png

-49 KB
Binary file not shown.
Lines changed: 1 addition & 5 deletions
Loading

0 commit comments

Comments
 (0)