Skip to content

Commit 53d1236

Browse files
committed
new: [onion-lookup] skeleton added
0 parents  commit 53d1236

13 files changed

+214
-0
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# onion-lookup
2+
3+
Software back-end and services for checking the existence of Tor hidden services and retrieving their associated metadata. onion-lookup relies on an AIL instance to obtain the metadata.
4+
5+
# License
6+
7+
This software is licensed under GNU Affero General Public License version 3.
8+
9+
- Copyright (C) 2024 CIRCL - Computer Incident Response Center Luxembourg
10+
- Copyright (C) 2024 Alexandre Dulaunoy
11+
- Copyright (C) 2024 AIL Project

app.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
from starlette.applications import Starlette
2+
from starlette.exceptions import HTTPException
3+
from starlette.requests import Request
4+
from starlette.staticfiles import StaticFiles
5+
from starlette.routing import Route, Mount
6+
from starlette.templating import Jinja2Templates
7+
import uvicorn
8+
9+
10+
templates = Jinja2Templates(directory='templates')
11+
12+
13+
async def homepage(request):
14+
template = "index.html"
15+
context = {"request": request}
16+
if 'lookup' in request.query_params:
17+
print(request.query_params['lookup'])
18+
return templates.TemplateResponse(template, context)
19+
20+
21+
async def error(request):
22+
"""
23+
Generic catch-call error
24+
"""
25+
raise RuntimeError("Oh no")
26+
27+
28+
async def not_found(request: Request, exc: HTTPException):
29+
"""
30+
Return an HTTP 404 page.
31+
"""
32+
template = "404.html"
33+
context = {"request": request}
34+
return templates.TemplateResponse(template, context, status_code=404)
35+
36+
37+
async def server_error(request: Request, exc: HTTPException):
38+
"""
39+
Return an HTTP 500 page.
40+
"""
41+
template = "500.html"
42+
context = {"request": request}
43+
return templates.TemplateResponse(template, context, status_code=500)
44+
45+
routes = [
46+
Route('/', homepage),
47+
Route('/error', error),
48+
Mount('/static', app=StaticFiles(directory='statics'), name='static')
49+
]
50+
51+
exception_handlers = {
52+
404: not_found,
53+
500: server_error
54+
}
55+
56+
app = Starlette(debug=True, routes=routes, exception_handlers=exception_handlers)
57+
58+
59+
if __name__ == "__main__":
60+
uvicorn.run(app, host='0.0.0.0', port=8000)
61+

requirements.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
aiofiles
2+
jinja2
3+
starlette
4+
uvicorn
5+
valkey

scripts/install

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
python3 -m venv .venv
4+
source .venv/bin/activate
5+
pip3 install -r requirements.txt

scripts/run

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
.venv/bin/python app.py

statics/css/bootstrap.min.css

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

statics/js/bootstrap.min.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

statics/js/jquery-3.7.1.slim.min.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

statics/js/popper.min.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/404.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% extends "base.html" %}
2+
3+
{% block content %}
4+
<main role="main">
5+
6+
<!-- Main jumbotron for a primary marketing message or call to action -->
7+
<div class="jumbotron">
8+
<div class="container">
9+
<h1 class="display-3">404</h1>
10+
<p>Page not found.</p>
11+
</div>
12+
</div>
13+
14+
</main>
15+
{% endblock %}
16+

templates/500.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% extends "base.html" %}
2+
3+
{% block content %}
4+
<main role="main">
5+
6+
<!-- Main jumbotron for a primary marketing message or call to action -->
7+
<div class="jumbotron">
8+
<div class="container">
9+
<h1 class="display-3">500</h1>
10+
<p>Server error.</p>
11+
</div>
12+
</div>
13+
14+
</main>
15+
{% endblock %}
16+

templates/base.html

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6+
<meta name="description" content="">
7+
<meta name="author" content="">
8+
9+
<title>onion-lookup - checking the metadata of a Tor hidden service</title>
10+
11+
<!-- Bootstrap core CSS -->
12+
<link href="{{ url_for('static', path='/css/bootstrap.min.css') }}" rel="stylesheet">
13+
14+
<!-- Custom styles for this template -->
15+
<link href="{{ url_for('static', path='/css/jumbotron.css') }}" rel="stylesheet">
16+
</head>
17+
18+
<body>
19+
20+
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
21+
<a class="navbar-brand" href="#">onion-lookup, everything all always wanted about a Tor hidden service</a>
22+
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
23+
<span class="navbar-toggler-icon"></span>
24+
</button>
25+
26+
</nav>
27+
28+
{% block content %}{% endblock %}
29+
30+
<footer class="container">
31+
<p>onion-lookup is an open project part of the <a href="https://www.ail-project.org/">AIL Project</a>.</p>
32+
</footer>
33+
34+
<!-- Bootstrap core JavaScript
35+
================================================== -->
36+
<!-- Placed at the end of the document so the pages load faster -->
37+
<script src="{{ url_for('static', path='/js/jquery-3.7.1.slim.min.js’') }}"></script>
38+
<script src="{{ url_for('static', path='/js/popper.min.js') }}"></script>
39+
<script src="{{ url_for('static', path='/js/bootstrap.min.js') }}"></script>
40+
</body>
41+
</html>
42+

templates/index.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{% extends "base.html" %}
2+
3+
{% block content %}
4+
<main role="main">
5+
6+
<div class="jumbotron">
7+
<div class="container">
8+
<h1 class="display-3">onion-lookup</h1>
9+
<p>onion-lookup is a service for checking the existence of Tor hidden services and retrieving their associated metadata. onion-lookup relies on an private <a href="https://www.ail-project.org/">AIL</a> instance to obtain the metadata.</p>
10+
<form class="form-inline my-2 my-lg-0">
11+
<input class="form-control mr-sm-2" name="lookup" type="text" placeholder="Lookup" aria-label="Lookup">
12+
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Lookup</button>
13+
</form>
14+
15+
</div>
16+
</div>
17+
18+
<div class="container">
19+
<div class="row">
20+
<div class="col-md-4">
21+
<h2>API</h2>
22+
<p>An OpenAPI is also available to query onion-lookup.</p>
23+
<p><a class="btn btn-secondary" href="#" role="button">View details &raquo;</a></p>
24+
</div>
25+
</div>
26+
27+
<hr>
28+
29+
</div> <!-- /container -->
30+
31+
</main>
32+
{% endblock %}
33+

0 commit comments

Comments
 (0)