[mirror of https://git.0x0.st/mia/0x0] No-bullshit file hosting and URL shortening service https://0x0.st
1
2
3 ################################################################################
4 # This is a configuration file for 0x0 / The Null Pointer #
5 # #
6 # The default values here are set to generally reasonable defaults, but a #
7 # couple of things need your attention. Specifically, make sure you set #
8 # SQLALCHEMY_DATABASE_URI. You'll also probably want to configure #
9 # FHOST_USE_X_SENDFILE and FHOST_USE_X_ACCEL_REDIRECT to match your webserver. #
10 # #
11 # Need help, or find anything confusing? Try opening up an issue! #
12 # https://git.0x0.st/mia/0x0/issues/new #
13 ################################################################################
14
15
16
17# The database URL for the database 0x0 should use
18#
19# See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls
20# for help configuring these for your database.
21#
22# For small and medium servers, it's plenty sufficient to just use an sqlite
23# database. In this case, the database URI you want to use is just
24#
25# sqlite:/// + /path/to/your/database.db
26#
27# Until https://git.0x0.st/mia/0x0/issues/70 is resolved, it's recommended that
28# any sqlite databases use an absolute path, as relative paths aren't consistently
29# resolved.
30SQLALCHEMY_DATABASE_URI = 'sqlite:///' + '/path/to/database.sqlite'
31
32
33# The maximum allowable upload size, in bytes
34#
35# Keep in mind that this affects the expiration of files as well! The closer a
36# file is to the max content length, the less time it will last before being
37# deleted.
38MAX_CONTENT_LENGTH = 256 * 1024 * 1024 # Default: 256MiB
39
40
41# The maximum length of URLs we'll shorten, in characters
42#
43# If a user tries to submit a URL longer than this, we'll reject their request
44# with a 414 REQUEST URI TOO LONG.
45MAX_URL_LENGTH = 4096
46
47
48# The minimum and maximum amount of time we'll retain a file for
49#
50# Small files (nearing zero bytes) are stored for the longest possible expiration date,
51# while larger files (nearing MAX_CONTENT_LENGTH bytes) are stored for the shortest amount
52# of time. Values between these two extremes are interpolated with an exponential curve,
53# like the one shown on the index page.
54#
55# All times are in milliseconds. If you want all files to be stored for the same amount
56# of time, set these to the same value.
57FHOST_MIN_EXPIRATION = 30 * 24 * 60 * 60 * 1000
58FHOST_MAX_EXPIRATION = 365 * 24 * 60 * 60 * 1000
59
60
61# This should be detected automatically when running behind a reverse proxy, but needs
62# to be set for URL resolution to work in e.g. the moderation UI.
63# SERVER_NAME = "example.com"
64
65
66# Specifies which graphics protocol to use for the media previews in the moderation UI.
67# Requires pympv with libmpv >= 0.36.0 and terminal support.
68# Available choices are "sixel" and "kitty".
69# MOD_PREVIEW_PROTO = "sixel"
70
71
72# Use the X-SENDFILE header to speed up serving files w/ compatible webservers
73#
74# Some webservers can be configured use the X-Sendfile header to handle sending
75# large files on behalf of the application. If your server is setup to do
76# this, set this variable to True
77USE_X_SENDFILE = False
78
79
80# Use X-Accel-Redirect to speed up serving files w/ compatible webservers
81#
82# Other webservers, like nginx and Caddy, use the X-Accel-Redirect header to
83# accomplish a very similar thing to X-Sendfile (above). If your webserver is
84# configured to do this, set this variable to True
85#
86# Note: It's recommended that you use either X-Sendfile or X-Accel-Redirect
87# when you deploy in production.
88FHOST_USE_X_ACCEL_REDIRECT = True # expect nginx by default
89
90
91# The directory that 0x0 should store uploaded files in
92#
93# Whenever a file is uploaded to 0x0, we store it here! Relative paths are
94# resolved relative to the working directory that 0x0 is being run from.
95FHOST_STORAGE_PATH = "up"
96
97
98# The maximum acceptable user-specified file extension
99#
100# When a user uploads a file, in most cases, we keep the file extension they
101# provide. But! If the specified file extension is longer than
102# FHOST_MAX_EXT_LENGTH, we truncate it. So if a user tries to upload the file
103# "myfile.withareallongext", but FHOST_MAX_EXT_LENGTH is set to 9, then the
104# extension that we keep is ".withareal"
105FHOST_MAX_EXT_LENGTH = 9
106
107
108# The number of bytes used for "secret" URLs
109#
110# When a user uploads a file with the "secret" option, 0x0 generates a string
111# from this many bytes of random data. It is base64-encoded, so on average
112# each byte results in approximately 1.3 characters.
113FHOST_SECRET_BYTES = 16
114
115# A list of filetypes to use when the uploader doesn't specify one
116#
117# When a user uploads a file with no file extension, we try to find an extension that
118# works for that file. This configuration option is the first thing that we check. If
119# the type of a file without an extension is in this dict, then it'll be used as the file
120# extension for that file. Otherwise, we try to pick something sensible from libmagic's
121# database.
122#
123# For example, if the user uploads "myfile" with no extension, and the file is a jpeg
124# image, the file will get a URL like "eAa.jpg"
125#
126# For a list of MIME types you can use in this list, check
127# https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
128FHOST_EXT_OVERRIDE = {
129 "audio/flac" : ".flac",
130 "image/gif" : ".gif",
131 "image/jpeg" : ".jpg",
132 "image/png" : ".png",
133 "image/svg+xml" : ".svg",
134 "video/webm" : ".webm",
135 "video/x-matroska" : ".mkv",
136 "application/octet-stream" : ".bin",
137 "text/plain" : ".log",
138 "text/plain" : ".txt",
139 "text/x-diff" : ".diff",
140}
141
142# Enables support for detecting NSFW images
143#
144# Consult README.md for additional dependencies before setting to True
145NSFW_DETECT = False
146
147
148# The cutoff for when an image is considered NFSW
149#
150# When the NSFW detection algorithm generates an output higher than this
151# number, an image is considered to be NSFW. NSFW images aren't declined, but
152# are marked as NSFW.
153#
154# If NSFW_DETECT is set to False, then this has no effect.
155NSFW_THRESHOLD = 0.92
156
157
158# If you want to scan files for viruses using ClamAV, specify the socket used
159# for connections here. You will need the clamd module.
160# Since this can take a very long time on larger files, it is not done
161# immediately but every time you run the vscan command. It is recommended to
162# configure a systemd timer or cronjob to do this periodically.
163# Remember to adjust your size limits in clamd.conf, including StreamMaxLength!
164#
165# Example:
166# from clamd import ClamdUnixSocket
167# VSCAN_SOCKET = ClamdUnixSocket("/run/clamav/clamd-socket")
168
169# This is the directory that files flagged as malicious are moved to.
170# Relative paths are resolved relative to the working directory
171# of the 0x0 process.
172VSCAN_QUARANTINE_PATH = "quarantine"
173
174# Since updated virus definitions might catch some files that were previously
175# reported as clean, you may want to rescan old files periodically.
176# Set this to a datetime.timedelta to specify the frequency, or None to
177# disable rescanning.
178from datetime import timedelta
179VSCAN_INTERVAL = timedelta(days=7)
180
181# Some files flagged by ClamAV are usually not malicious, especially if the
182# DetectPUA option is enabled in clamd.conf. This is a list of signatures
183# that will be ignored.
184VSCAN_IGNORE = [
185 "Eicar-Test-Signature",
186 "PUA.Win.Packer.XmMusicFile",
187]
188
189# A list of all characters which can appear in a URL
190#
191# If this list is too short, then URLs can very quickly become long.
192# Generally, the default value for this should work for basically all usecases.
193URL_ALPHABET = "DEQhd2uFteibPwq0SWBInTpA_jcZL5GKz3YCR14Ulk87Jors9vNHgfaOmMXy6Vx-"
194
195
196 #################################################################################
197 # CONGRATULATIONS! You made it all the way through! #
198 # If you want to go even further to customize your instance, try checking out #
199 # the templates in the templates/ directory to customize your landing page, 404 #
200 # page, and other error pages. #
201 #################################################################################
202