Add ungleichapi
This commit is contained in:
parent
e5acec4ba2
commit
de768b2ae7
6 changed files with 123 additions and 2 deletions
63
game-etcd.py
Normal file
63
game-etcd.py
Normal file
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
USERLENGTH = 50
|
||||
|
||||
import ipaddress
|
||||
import random
|
||||
import sys
|
||||
import etcd
|
||||
|
||||
from flask import Flask
|
||||
from flask_restful import Resource, Api
|
||||
from flask_restful import reqparse
|
||||
|
||||
app = Flask(__name__)
|
||||
api = Api(app)
|
||||
|
||||
class Level(Resource):
|
||||
points = 0
|
||||
|
||||
def test(self):
|
||||
pass
|
||||
|
||||
class Ping6(Level):
|
||||
points = 10
|
||||
|
||||
def test(self):
|
||||
|
||||
"""
|
||||
ping6 -c3
|
||||
"""
|
||||
|
||||
class Game(Resource):
|
||||
def get(self):
|
||||
return {'hello': 'list of levels'}
|
||||
|
||||
|
||||
|
||||
|
||||
api.add_resource(Game, '/game')
|
||||
|
||||
@app.route("/")
|
||||
def high_score():
|
||||
return "High score!"
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
net_base = "2a0a:e5c1:{:x}::/64"
|
||||
net_offset = random.randrange(0xffff)
|
||||
net = ipaddress.IPv6Network(net_base.format(net_offset))
|
||||
name = 'nico{}'.format(net_offset)
|
||||
|
||||
print(net)
|
||||
|
||||
print(n)
|
||||
|
||||
addr_offset = random.randrange(0, 2**64)
|
||||
addr = net[0] + addr_offset
|
||||
a = Address('nico{}'.format(net_offset), str(addr))
|
||||
print(a)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
app.run(port='5002')
|
27
game.org
Normal file
27
game.org
Normal file
|
@ -0,0 +1,27 @@
|
|||
* DONE Framework: use flask for trying
|
||||
** Django
|
||||
*** Known
|
||||
*** DRF?
|
||||
** Flask
|
||||
*** SQL?
|
||||
*** Light?
|
||||
** Quart
|
||||
** vue.js
|
||||
* Websites
|
||||
** TODO landing page with intro, high score and link to login/register
|
||||
*** highscore: requests list from server, server side calculated, GET /highscore
|
||||
** TODO "account details" ?
|
||||
*** Setup the /64
|
||||
** TODO login
|
||||
*** via username/password => passed on to account.ungleich.ch, retrieves seed
|
||||
*** passes seed back to client
|
||||
** TODO List of challenges (sortabale?)
|
||||
*** With URL for posting w/ ungleich-otp?
|
||||
* Challenges
|
||||
** Prove that you have a /64 configured
|
||||
*** Input: /64
|
||||
*** Output: random /64 address
|
||||
*** Test: is /64 ping6able?
|
||||
* Features
|
||||
** TODO ungleich-otp support
|
||||
**
|
|
@ -10,8 +10,8 @@ some_vm['network']['ipv6'].append("2a0a:e5c0:4::42/64")
|
|||
some_vm['network']['ipv6'].append("2a0a:e5c0:1::42/64")
|
||||
|
||||
|
||||
for node in range(20000):
|
||||
client.delete('/nodes/n{}'.format(node), j)
|
||||
#for node in range(20000):
|
||||
# client.delete('/nodes/n{}'.format(node))
|
||||
|
||||
|
||||
for node in range(200):
|
||||
|
|
23
ungleich.py
Normal file
23
ungleich.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
|
||||
VERSION="0.0.1"
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = {}
|
||||
|
||||
parser['main'] = argparse.ArgumentParser(
|
||||
description="ungleich cli {}".format(VERSION) )
|
||||
parser['main'].add_argument(
|
||||
'-V', '--version', help='Show version.', action='version',
|
||||
version='%(prog)s ' + VERSION)
|
||||
parser['sub'] = parser['main'].add_subparsers(
|
||||
title="Commands", dest="command")
|
||||
|
||||
parser['register'] = parser['sub'].add_parser(
|
||||
'register')
|
||||
|
||||
parser_args = parser['main'].parse_args(sys.argv[1:])
|
8
ungleichapi.py
Normal file
8
ungleichapi.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
ungleich_api = {}
|
||||
|
||||
|
||||
class ungleichAPI(object):
|
||||
def __init__(self, version='v1'):
|
||||
pass
|
Loading…
Reference in a new issue