--- /dev/null
+server {
+ listen [::]:80;
+ listen 0.0.0.0:80;
+
+ server_name wtfismyip.dn *.wtfismyip.dn;
+
+ location / {
+ include uwsgi_params;
+ uwsgi_pass unix:/run/uwsgi/app/wtfismyip/socket;
+ more_set_headers 'Access-Control-Allow-Origin: *';
+ }
+
+ location /style.css {
+ alias /srv/www/wtfismyip.dn/templates/style.css;
+ }
+}
--- /dev/null
+#!/usr/bin/python3
+
+from flask import request, render_template
+from socket import gethostbyaddr
+from flask import Flask
+
+import json
+import binascii
+import os
+import sqlite3
+
+app = Flask(__name__)
+
+@app.route("/")
+def index():
+ remote_addr = request.remote_addr
+ hostname = remote_addr
+ try:
+ hostname = gethostbyaddr(remote_addr)[0]
+ except:
+ pass
+
+ token=os.urandom(16)
+ token='tok' + binascii.hexlify(token).decode()
+
+ return render_template("index.html", remote_addr=remote_addr, hostname=hostname, token=token)
+
+@app.route("/api")
+def api():
+ remote_addr = request.remote_addr
+ hostname = remote_addr
+ try:
+ hostname = gethostbyaddr(remote_addr)[0]
+ except:
+ pass
+
+ data = {
+ 'ipaddress' : remote_addr,
+ 'hostname' : hostname
+ }
+ return json.dumps(data)
+
+@app.route("/named/<token>")
+def named(token):
+ sqlite = sqlite3.connect("tokens.sqlite")
+ response = []
+ with sqlite:
+ cur = sqlite.cursor()
+ cur.execute("SELECT DISTINCT ip FROM token WHERE token = ?", (token, ))
+ for row in cur:
+ hostname = row[0]
+ try:
+ hostname = gethostbyaddr(hostname)[0]
+ except:
+ pass
+
+ response.append((row[0], hostname))
+
+ print(response)
+ return json.dumps(response)
+
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>WTF IS MY DARKNET IP?</title>
+ <link rel="stylesheet" type="text/css" href="/style.css" />
+ <script src="http://js.cdn.dn/jquery/jquery.min.js"></script>
+ <script>
+ $( document ).ready( function () {
+ $.getJSON("http://v4.wtfismyip.dn/api", function (data) {
+ $("#v4ip").html(data["ipaddress"]);
+ $("#v4host").html(data["hostname"]);
+ });
+ $.getJSON("http://v6.wtfismyip.dn/api", function(data) {
+ $("#v6ip").html(data["ipaddress"]);
+ $("#v6host").html(data["hostname"]);
+ });
+ $.getJSON("/named/{{token}}", function(data) {
+ data.forEach(function (value) {
+ $("#nameservers").append("<tr><td>" + value[0] + "</td><td>" + value[1] + "</td></tr>");
+ });
+ });
+ });
+ </script>
+ </head>
+ <body>
+ <div class="document">
+ <h1>WTF IS MY DARKNET IP?</h1>
+ <img src="//{{token}}.ns4.wtfismyip.dn/" width="1px" height="1px" />
+ <img src="//{{token}}.ns6.wtfismyip.dn/" width="1px" height="1px" />
+ <p>
+ For automated checks use our fancy shiny new <a href="//wtfismyip.dn/api">API</a>!
+ </p>
+ <table>
+ <tr>
+ <td>Preferred</td><td>{{remote_addr}}</td><td>{{hostname}}</td>
+ </tr>
+ <tr>
+ <td>IPv4</td><td id="v4ip">No connectivity</td><td id="v4host"></td>
+ </tr>
+ <tr>
+ <td>IPv6</td><td id="v6ip">No connectivity</td><td id="v6host"></td>
+ </tr>
+ </table>
+
+ <h2>WTF are my DNS Servers?</h2>
+ <table id="nameservers">
+
+ </table>
+ </div>
+ </body>
+</html>
--- /dev/null
+@font-face {
+ font-family: Concourse;
+ src: url('https://static.siccegge.de/WOFF/OTF/Concourse T3 Regular.woff');
+}
+@font-face {
+ font-family: Equity;
+ src: url('https://static.siccegge.de/WOFF/OTF/Equity Text A Regular.woff');
+}
+@font-face {
+ font-family: SourceCodePro;
+ src: url('https://static.siccegge.de/WOFF/OTF/SourceCodePro-Regular.otf.woff');
+}
+* {
+ font-family: Equity;
+ text-rendering: optimizeLegibility;
+ font-variant-ligatures: common-ligatures;
+ font-kerning: normal;
+ line-height: 1.3;
+ margin: 0;
+ padding:0;
+}
+h1, h2, h3, h4, h5, h6, h7 {
+ font-family: Concourse;
+ padding-bottom: .5em;
+}
+ul {
+ margin-left: 2em;
+}
+p {
+ margin-bottom: 1em;
+}
+td {
+ padding: .5em;
+}
+.document {
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 1em;
+ margin-bottom: 1em;
+ width: 90%;
+ max-width: 50em;
+}
+@media (max-width: 45em) {
+ .document {
+ border: none;
+ width: 100%;
+ margin: 0px;
+ }
+}
+.align-left {
+ float:left;
+ padding-right: 1em;
+ padding-bottom: 1em;
+}
+.section {
+ margin-bottom: 1em;
+ float:left;
+ clear:both;
+ min-width: 26em;
+}
+.code {
+ padding-left: 1em;
+ font-family: SourceCodePro;
+}
--- /dev/null
+[uwsgi]
+plugins = python3
+uid = www-data
+gid = www-data
+processes = 2
+threads = 4
+pythonpath = /srv/www/wtfismyip.dn
+module = server:app
+chdir = /srv/www/wtfismyip.dn