Compare commits

...

10 Commits

Author SHA1 Message Date
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
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
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
2 changed files with 57 additions and 23 deletions

3
.gitignore vendored
View File

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

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from flask import Flask, abort, escape, make_response, redirect, request, send_from_directory, url_for, Response
@ -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)
@ -341,27 +353,35 @@ def fhost():
if maxsizehalf.is_integer():
maxsizehalf = int(maxsizehalf)
return """<pre>
THE NULL POINTER
================
return """
<html>
<head>
<link rel="stylesheet" href="https://tilde.team/css/hacker.css">
<title>0x0.tilde.team</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>
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,16 +405,27 @@ 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>
</div>
</body>
</html>
""".format(fhost_url(),
maxsize, str(maxsizehalf).rjust(27), str(maxsizenum).rjust(27),
maxsizeunit.rjust(54),