From de768b2ae7e437a34e9f61bbd16391f8503d7d24 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 25 May 2019 22:45:44 +0200 Subject: [PATCH] Add ungleichapi --- game-etcd.py | 63 +++++++++++++++++++++++++++++++ game-server-new.py => game-sql.py | 0 game.org | 27 +++++++++++++ test-etcd.py | 4 +- ungleich.py | 23 +++++++++++ ungleichapi.py | 8 ++++ 6 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 game-etcd.py rename game-server-new.py => game-sql.py (100%) create mode 100644 game.org create mode 100644 ungleich.py create mode 100644 ungleichapi.py diff --git a/game-etcd.py b/game-etcd.py new file mode 100644 index 0000000..87ed09a --- /dev/null +++ b/game-etcd.py @@ -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') diff --git a/game-server-new.py b/game-sql.py similarity index 100% rename from game-server-new.py rename to game-sql.py diff --git a/game.org b/game.org new file mode 100644 index 0000000..800b4a4 --- /dev/null +++ b/game.org @@ -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 +** diff --git a/test-etcd.py b/test-etcd.py index 4912cd4..8c6515a 100644 --- a/test-etcd.py +++ b/test-etcd.py @@ -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): diff --git a/ungleich.py b/ungleich.py new file mode 100644 index 0000000..74e1af1 --- /dev/null +++ b/ungleich.py @@ -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:]) diff --git a/ungleichapi.py b/ungleichapi.py new file mode 100644 index 0000000..7bcec2a --- /dev/null +++ b/ungleichapi.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +ungleich_api = {} + + +class ungleichAPI(object): + def __init__(self, version='v1'): + pass