Compare commits

...

20 Commits

Author SHA1 Message Date
jesopo 11af215bc4 pass back file/url/shorten as text/plain 2019-09-18 14:34:48 +01:00
Ben Harris 070e74cd56
make page responsive 2019-09-11 21:35:22 -04:00
tilde services a3b917ee73 add nginx conf and systemd unit 2019-04-29 22:09:03 -04:00
Ben Harris 2b7d0e5b20 use py3 2019-04-13 15:42:12 -04:00
Ben Harris 3e4eb055c7 Merge branch 'master' of aewens/0x0 into master 2018-10-04 12:34:53 -04:00
aewens 99be0c244d Fixed buggy gopher support 2018-10-04 11:34:00 -04:00
aewens 81bf0a5cca Fixed buggy gopher support 2018-10-04 11:32:19 -04:00
Ben Harris fd78aabe07 Merge branch 'master' of aewens/0x0 into master 2018-10-03 19:37:33 -04:00
aewens b3fd8fdbc0 Fixing formatting 2018-10-02 17:32:27 -04:00
aewens be8adb6d7a Added gopher http proxy support 2018-10-02 17:30:44 -04:00
Ben Harris 8486c660eb add source links 2018-09-21 14:44:58 -04:00
Robert Miles e437bfd1ab Fix title so it doesn't start with scheme 2018-08-17 21:17:31 -04:00
Robert Miles a119f53607 Make title of page be hostname of server 2018-08-17 21:13:35 -04:00
Ben Harris ec6344383c Merge branch 'uploader' of aewens/0x0 into master 2018-07-31 17:32:11 -04:00
aewens 67d781bd7c Added uploader 2018-07-31 17:28:53 -04:00
aewens 90a03da496 Added uploader 2018-07-31 17:26:39 -04:00
Ben Harris 42c285a0ff Update 'fhost.py' 2018-07-26 10:51:28 -04:00
Ben Harris 315f1bfe24 Update 'fhost.py' 2018-07-26 10:49:21 -04:00
Ben Harris f2da85e437 Update 'fhost.py' 2018-07-26 10:48:00 -04:00
tilde services 13816f1d80 ~team customizations 2018-07-26 10:39:37 -04:00
4 changed files with 122 additions and 27 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
__pycache__/
.py[cod]
db.sqlite
up/
*.pyc

18
0x0.service Normal file
View File

@ -0,0 +1,18 @@
# /etc/systemd/system/nullpointer.service
[Unit]
Description=null pointer
After=0x0.service
[Service]
Type=simple
WorkingDirectory=/home/services/0x0
ExecStart=/usr/local/bin/uwsgi --socket 127.0.0.1:3031 --wsgi-file fhost.py --callable app --processes 4 --threads 2
User=services
Restart=always
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=default.target

View File

@ -46,7 +46,7 @@ app.config["FHOST_MIME_BLACKLIST"] = [
app.config["FHOST_UPLOAD_BLACKLIST"] = "tornodes.txt"
app.config["NSFW_DETECT"] = True
app.config["NSFW_DETECT"] = False
app.config["NSFW_THRESHOLD"] = 0.608
if app.config["NSFW_DETECT"]:
@ -132,6 +132,12 @@ def is_fhost_url(url):
return url.startswith(fhost_url()) or url.startswith(fhost_url("https"))
def shorten(url):
# handler to convert gopher links to HTTP(S) proxy
gopher = "gopher://"
length = len(gopher)
if url[:length] == gopher:
url = "https://gopher.tilde.team/{}".format(url[length:])
if len(url) > app.config["MAX_URL_LENGTH"]:
abort(414)
@ -233,6 +239,12 @@ def store_file(f, addr):
return sf.geturl()
def store_url(url, addr):
# handler to convert gopher links to HTTP(S) proxy
gopher = "gopher://"
length = len(gopher)
if url[:length] == gopher:
url = "https://gopher.tilde.team/{}".format(url[length:])
if is_fhost_url(url):
return segfault(508)
@ -318,14 +330,17 @@ def dump_urls(start=0):
@app.route("/", methods=["GET", "POST"])
def fhost():
if request.method == "POST":
sf = None
out = None
if "file" in request.files:
return store_file(request.files["file"], request.remote_addr)
out = store_file(request.files["file"], request.remote_addr)
elif "url" in request.form:
return store_url(request.form["url"], request.remote_addr)
out = store_url(request.form["url"], request.remote_addr)
elif "shorten" in request.form:
return shorten(request.form["shorten"])
out = shorten(request.form["shorten"])
if not out == None:
return Response(out, mimetype="text/plain")
abort(400)
else:
@ -341,27 +356,39 @@ def fhost():
if maxsizehalf.is_integer():
maxsizehalf = int(maxsizehalf)
return """<pre>
THE NULL POINTER
================
return """
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://tilde.team/css/hacker.css">
<title>{6}</title>
</head>
<body>
<div class="container">
<h1>THE NULL POINTER</h1>
<hr>
HTTP POST files here:
curl -F'file=@yourfile.png' {0}
<pre>curl -F'file=@yourfile.png' {0}</pre>
You can also POST remote URLs:
curl -F'url=http://example.com/image.jpg' {0}
<pre>curl -F'url=http://example.com/image.jpg' {0}</pre>
Or you can shorten URLs:
curl -F'shorten=http://example.com/some/long/url' {0}
<pre>curl -F'shorten=http://example.com/some/long/url' {0}</pre>
File URLs are valid for at least 30 days and up to a year (see below).
Shortened URLs do not expire.
<p>File URLs are valid for at least 30 days and up to a year (see below).
Shortened URLs do not expire.</p>
Maximum file size: {1}
Not allowed: {5}
<p>Maximum file size: {1}</p>
<p>Not allowed: {5}</p>
<em>if you want a nice wrapper, try <a href="https://tildegit.org/tomasino/pb">~tomasino's pb</a></em>
FILE RETENTION PERIOD
---------------------
<h3>FILE RETENTION PERIOD</h3>
<pre>
retention = min_age + (-max_age + min_age) * pow((file_size / max_size - 1), 3)
days
@ -385,20 +412,34 @@ retention = min_age + (-max_age + min_age) * pow((file_size / max_size - 1), 3)
30 | ....................
0{2}{3}
{4}
ABUSE
-----
If you would like to request permanent deletion, please contact lachs0r via
IRC on Freenode, or send an email to lachs0r@(this domain).
Please allow up to 24 hours for a response.
</pre>
<h3>ABUSE</h3>
<hr>
<p>If you would like to request permanent deletion, please contact ben or khuxkm via
IRC on <a href="https://web.tilde.chat">tilde.chat</a>, or send an email to sudoers@tilde.team.</p>
<p>Please allow up to 24 hours for a response.</p>
<h3>UPLOAD DIRECTLY</h3>
<hr>
<form action="{0}" method="POST" enctype="multipart/form-data">
<label for="file">File:</label>
<input class="form-control" type="file" name="file"><br><br>
<input class="form-control" type="submit" value="Submit">
</form>
<footer class="text-center"><a href="https://tildegit.org/tildeverse/0x0">source here</a></footer>
</div>
</body>
</html>
""".format(fhost_url(),
maxsize, str(maxsizehalf).rjust(27), str(maxsizenum).rjust(27),
maxsizeunit.rjust(54),
", ".join(app.config["FHOST_MIME_BLACKLIST"]))
", ".join(app.config["FHOST_MIME_BLACKLIST"]),fhost_url().split("/",2)[2])
@app.route("/robots.txt")
def robots():

33
nginx.conf Normal file
View File

@ -0,0 +1,33 @@
server {
listen 80;
listen [::]:80;
server_name ttm.sh;
return 307 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name ttm.sh;
# include your certs
ssl_certificate /etc/letsencrypt/live/ttm.sh/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ttm.sh/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
root /home/services/0x0;
location / {
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
# make sure this matches the port you're running uwsgi on
uwsgi_pass 127.0.0.1:3031;
}
location /up {
internal;
}
}