Push code
This commit is contained in:
parent
661a3820cb
commit
4babb07e94
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,6 +5,8 @@ __pycache__/
|
||||||
# C extensions
|
# C extensions
|
||||||
*.so
|
*.so
|
||||||
|
|
||||||
|
/db/
|
||||||
|
|
||||||
# Distribution / packaging
|
# Distribution / packaging
|
||||||
.Python
|
.Python
|
||||||
env/
|
env/
|
||||||
|
|
3
blacklist.txt
Normal file
3
blacklist.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
www
|
||||||
|
jabber
|
||||||
|
hamburg
|
31
build.py
Executable file
31
build.py
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
from glob import glob
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
DOMAIN = 'ff-hh.net'
|
||||||
|
OUT = '/etc/nginx/v6helper.d/'
|
||||||
|
|
||||||
|
template = '''
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
|
||||||
|
server_name %%s.%s;
|
||||||
|
|
||||||
|
access_log off;
|
||||||
|
error_log /dev/null crit;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://[%%s];
|
||||||
|
include /etc/nginx/proxy_params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
''' % DOMAIN
|
||||||
|
|
||||||
|
for path in glob('db/*'):
|
||||||
|
with open(path) as f:
|
||||||
|
x = json.load(f)
|
||||||
|
with open(os.path.join(OUT, x['name']), 'w') as f:
|
||||||
|
pass
|
||||||
|
f.write(template % (x['name'], x['ipv6']))
|
0
db/.gitkeep
Normal file
0
db/.gitkeep
Normal file
56
server.py
Executable file
56
server.py
Executable file
|
@ -0,0 +1,56 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
from flask import Flask, render_template, request, redirect
|
||||||
|
import socket
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
DOMAIN = 'ff-hh.net'
|
||||||
|
ABUSE = 'rm-pls@hamburg.freifunk.net'
|
||||||
|
DB = 'db/'
|
||||||
|
|
||||||
|
kwargs = dict(domain=DOMAIN, abuse=ABUSE)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
return render_template('index.html', **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/add', methods=['POST'])
|
||||||
|
def add():
|
||||||
|
name = request.form['name']
|
||||||
|
ipv6 = request.form['ipv6']
|
||||||
|
|
||||||
|
if not re.match('^[a-z0-9]+$', name):
|
||||||
|
return 'name rejected'
|
||||||
|
|
||||||
|
with open('blacklist.txt') as f:
|
||||||
|
blacklist = [x.strip() for x in f if x.strip()]
|
||||||
|
|
||||||
|
if name in blacklist:
|
||||||
|
return 'name is blacklisted'
|
||||||
|
|
||||||
|
if os.path.exists(os.path.join(DB, name)):
|
||||||
|
return 'name exists'
|
||||||
|
|
||||||
|
try:
|
||||||
|
socket.inet_pton(socket.AF_INET6, ipv6)
|
||||||
|
except socket.error:
|
||||||
|
return 'invalid ipv6'
|
||||||
|
else:
|
||||||
|
with open(os.path.join(DB, name), 'w') as f:
|
||||||
|
json.dump({'name': name, 'ipv6': ipv6}, f)
|
||||||
|
|
||||||
|
return redirect('/done')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/done')
|
||||||
|
def done():
|
||||||
|
return render_template('done.html', **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.debug = True
|
||||||
|
app.run(port=5001)
|
8
static/bootstrap.min.css
vendored
Normal file
8
static/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
3
static/style.css
Normal file
3
static/style.css
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
.container {
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
1
templates/done.html
Normal file
1
templates/done.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
yey
|
53
templates/index.html
Normal file
53
templates/index.html
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>{{ domain }}</title>
|
||||||
|
<link rel="stylesheet" href="/static/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1>{{ domain }}</h1>
|
||||||
|
<form method="post" action="/add">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Name</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<input class="form-control" id="name" name="name" placeholder="yourname">
|
||||||
|
<div class="input-group-addon">.{{ domain }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">IPv6</label>
|
||||||
|
<input class="form-control" id="ipv6" name="ipv6" placeholder="2a03:2267::dead:beef">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-right">
|
||||||
|
<input class="btn btn-primary" type="submit" value="Hinzufügen">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h3>Name</h3>
|
||||||
|
<p>Der Name unter dem deine Seite erreichbar sein soll. Wenn du den Namen foo eingibst, ist sie danach unter foo.mesh.hamburg erreichbar.</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h3>IPv6</h3>
|
||||||
|
<p>Die IPv6 Adresse von deinem Gerät, dass du öffentlich erreichbar machen möchtest.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h3>Gentle*man Agreement</h3>
|
||||||
|
<p>Kein Missbrauch pls.</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h3>Missbrauch melden</h3>
|
||||||
|
<p>Wenn du eine Seite findest die dir nicht gefällt, schreibe uns doch einfach eine Email an <<a href="mailto:{{ abuse }}">{{ abuse }}</a>> und wir kümmern uns drum.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue