Skip to content

Commit

Permalink
many improvements everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
randomairborne committed Mar 3, 2024
1 parent 349fa55 commit 6454432
Show file tree
Hide file tree
Showing 9 changed files with 936 additions and 182 deletions.
689 changes: 689 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ axum = { version = "0.7", features = ["tokio", "http1", "http2"], default-featur
tokio = { version = "1", features = ["rt-multi-thread", "signal", "macros", "net"] }
thiserror = "1"
vss = "0.1"
tera = "1"

[profile.release]
lto = "fat"
81 changes: 39 additions & 42 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,48 @@ kill_signal = "SIGINT"
kill_timeout = "5s"

[experimental]
auto_rollback = true
auto_rollback = true

[env]
CLIENT_IP_HEADER = "Fly-Client-IP"
CLIENT_IP_HEADER = "Fly-Client-IP"
ROOT_DNS_NAME = "giveip.io"

[build]
image = "ghcr.io/randomairborne/giveip:latest"

[metrics]
port = 9090
path = "/metrics"
image = "ghcr.io/randomairborne/giveip:latest"

[[services]]
protocol = "tcp"
internal_port = 8080
processes = ["app"]

[[services.ports]]
port = 80
handlers = ["http"]

[[services.ports]]
port = 443
handlers = ["tls", "http"]

[services.concurrency]
type = "connections"
hard_limit = 25
soft_limit = 20

[[services.http_checks]]
interval = 10000
grace_period = "5s"
path = "/"
protocol = "http"
timeout = 2000
[services.http_checks.headers]
accept = "text/html"
Fly-Client-IP = "1.1.1.1"

[[services.http_checks]]
interval = 10000
grace_period = "5s"
path = "/raw"
protocol = "http"
timeout = 2000
[services.http_checks.headers]
Fly-Client-IP = "1.1.1.1"
protocol = "tcp"
internal_port = 8080
processes = ["app"]

[[services.ports]]
port = 80
handlers = ["http"]

[[services.ports]]
port = 443
handlers = ["tls", "http"]

[services.concurrency]
type = "connections"
hard_limit = 2500
soft_limit = 2000

[[services.http_checks]]
interval = 10000
grace_period = "5s"
path = "/"
protocol = "http"
timeout = 2000
[services.http_checks.headers]
accept = "text/html"
Fly-Client-IP = "1.1.1.1"

[[services.http_checks]]
interval = 10000
grace_period = "5s"
path = "/raw"
protocol = "http"
timeout = 2000
[services.http_checks.headers]
Fly-Client-IP = "1.1.1.1"
13 changes: 13 additions & 0 deletions src/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex" />
<link rel="stylesheet" href="/main.css" />
<title>404 not found</title>
</head>

<body>
<div class="stack">404 not found</div>
</body>
</html>
62 changes: 62 additions & 0 deletions src/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="root-dns-name"
id="root-dns-name"
data-dns-name="{{root_dns_name}}"
/>
<link rel="stylesheet" href="/main.css" />
<meta
name="description"
content="A simple, fast website to return your IPv4 and IPv6 addresses. No logs are kept. Free and open to all."
/>
<meta property="og:title" content="GiveIP" />
<meta property="og:url" content="https://{{root_dns_name}}/" />
<meta
property="og:description"
content="A simple, fast website to return your IPv4 and IPv6 addresses. No logs are kept. Free and open to all."
/>
<link rel="canonical" href="https://{{root_dns_name}}/" />
<noscript>
<meta http-equiv="refresh" content="0; url='/raw'" />
</noscript>
{% if ipv4 %}
<title id="title">Your public IP is {{ipv4}}</title>
{% else %}
<title id="title">What's my IP?</title>
{% endif %}
</head>

<body>
<div class="stack">
{% if ipv4 %}
<div id="ip4txt">
Your public IPv4 is:&nbsp;<code id="ip4">{{ipv4}}</code>
</div>
{% else %}
<div id="ip4txt" hidden>
Your public IPv4 is:&nbsp;<code id="ip4">(none)</code>
</div>
{% endif %} {% if ipv6 %}
<div id="ip6txt">
Your public IPv6 is:&nbsp;<code id="ip6">{{ipv6}}</code>
</div>
{% else %}
<div id="ip6txt" hidden>
Your public IPv6 is:&nbsp;<code id="ip6">(none)</code>
</div>
{% endif %}
</div>

<script src="/main.js"></script>
<!-- Cloudflare Web Analytics -->
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon='{"token": "872609be4c924b219e5de38a6e0b26a0"}'
></script>
<!-- End Cloudflare Web Analytics -->
</body>
</html>
95 changes: 0 additions & 95 deletions src/index.html

This file was deleted.

13 changes: 13 additions & 0 deletions src/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
html,
body {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}

.stack {
display: inline;
font-size: max(5vh, 3vw);
font-family: Arial, Verdana, Helvetica, sans-serif;
}
30 changes: 30 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const root_dns_name = document.getElementById("root-dns-name").dataset.dnsName;
const v4_endpoint = `https://v4.${root_dns_name}/raw`;
const v6_endpoint = `https://v6.${root_dns_name}/raw`;
const ip4 = document.getElementById("ip4");
const ip6 = document.getElementById("ip6");
const ip4txt = document.getElementById("ip4txt");
const ip6txt = document.getElementById("ip6txt");
if (ip4txt.hidden) {
fetch(v4_endpoint)
.then((req) => req.text())
.then((resp) => {
ip4.innerText = resp;
ip4txt.hidden = false;
document.getElementById("title").innerText = `Your IP is ${resp}`;
})
.catch((failed) => {
console.log("Request failed:" + failed);
});
}
if (ip6txt.hidden) {
fetch(v6_endpoint)
.then((req) => req.text())
.then((resp) => {
ip6.innerText = resp;
ip6txt.hidden = false;
})
.catch((failed) => {
console.log("Request failed:" + failed);
});
}
Loading

0 comments on commit 6454432

Please sign in to comment.