Just shroomp it!
You want to redirect from your domain to a specific URL but all you have is a DNS? Just shroomp it.
Shroomp is a fungi powered URL forwarding service in few lines of Bash thanks to HTTP.SH.
Made by j-g00da, running on fungus.
_shroomp.yourdomain.com. IN TXT "to=https://example.com/anywhere/you/want"
You can even redirect from a specific URL! Just change slashes to underscore and glue this to the subdomain of the TXT record, e.g.:
_shroomp_some_path.yourdomain.com. IN TXT "to=https://example.com/anywhere/you/want"
This will result in a redirect from http://yourdomain.com/some/path to https://example.com/anywhere/you/want.
More config options in the future.
yourdomain.com. IN A 46.224.123.219
yourdomain.com. IN AAAA 2a01:4f8:1c1a:4dce::
Alternatively, if you want to make a redirect from a subdomain, you can just create a CNAME record:
sub.yourdomain.com. IN CNAME shroomp.kamiokan.de.
Of course these redirects only work from http as I'm not capable of issuing a wildcard certificate for the whole Internet (yet).
#!/bin/bash
extract_txt_val() {
local key="$1"
local record="$2"
# this is absolutely crazy, don't touch it
echo "$record" \
| sed -n "s/.*\(^\|;\)${key}=\([^;]*\).*/\2/p" \
| head -n1
}
# The TXT record subdomain is _shroomp for source domains with no path, e.g.
# example.com -> _shroomp.example.com
# For URLs with paths, e.g. example.com/some/path we normalize the URL and glue it to _shroomp, e.g.:
# example.com/some/path -> _shroomp_some_path.example.com
# This way we can define not only domain -> URL redirects
# But also URL -> URL redirects :D
get_txt_domain() {
local domain="$1"
local path="$2"
local normalized_path
normalized_path=$(echo "${path}" | sed 's/\//_/g; s/_//')
if [[ "${normalized_path}" != "" ]]; then
echo "_shroomp_${normalized_path}.${domain}"
else
echo "_shroomp.${domain}"
fi
}
shroomp_domain="${cfg[domain]}"
shroomp_ipv4="${cfg[ipv4]}"
shroomp_ipv6="${cfg[ipv6]}"
source_domain="${r[host]}"
if [[ "$source_domain" == "$shroomp_domain" ]]; then
src=$(cat app/webroot/index.shs | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g')
echo '
<head>
<meta name="color-scheme" content="light dark">
<!-- Literally copied from bettermotherfuckingwebsite.com -->
<style type="text/css">body{margin:40px auto;max-width:900px;line-height:1.6;font-size:16px;padding:0 10px}h1,h2,h3{line-height:1.2}</style>
</head>
<body>
<h1>
🍄
<img
alt="blob cat wobbling aggressively"
src="https://github.com/DuckOfDisorder/BlobCats/blob/main/GIFs%20and%20APNGs/GIFs/A_BlobCat_Wobble.gif?raw=true" height="41px"/>
Just shroomp it!
</h1>
<p>You want to redirect from your domain to a specific URL but all you have is a DNS? Just shroomp it.</p>
<p>Shroomp is a fungi powered URL forwarding service in few lines of Bash thanks to <a href="https://git.sakamoto.pl/domi/http.sh">HTTP.SH</a>.</p>
<p>Made by <a href="https://jslazak.com/">j-g00da</a>, running on fungus.</p>
<br>
<h2> But how do I shroomp it?</h2>
<h3>First, create a TXT record for your domain with the following format:</h3>
<mark><code>
_shroomp.yourdomain.com. IN TXT "to=https://example.com/anywhere/you/want"
</code></mark>
<p>You can even redirect from a specific URL! Just change slashes to underscore and glue this to the subdomain of the TXT record, e.g.:</p>
<mark><code>
_shroomp_some_path.yourdomain.com. IN TXT "to=https://example.com/anywhere/you/want"
</code></mark>
<p>This will result in a redirect from <code>http://yourdomain.com/some/path</code> to <code>https://example.com/anywhere/you/want</code>.</p>
<b>Amazing! You wouldn'"'"'t believe a mushroom can do this!</b>
<p>More config options in the future.</p>
<br>
<h3>You will also need to point your domain to the shroomp service IP:</h3>
<pre><code>
yourdomain.com. IN A '"${shroomp_ipv4}"'
yourdomain.com. IN AAAA '"${shroomp_ipv6}"'
</code></pre>
<p>Alternatively, if you want to make a redirect from a subdomain, you can just create a CNAME record:</p>
<pre><code>
sub.yourdomain.com. IN CNAME '"${shroomp_domain}"'.
</code></pre>
<p>Of course these redirects only work from http as I'"'"'m not capable of issuing a wildcard certificate for the whole Internet (yet).</p>
<br>
<h2>Source code available on.. wait... literally here:</h2>
<details>
<summary>app/webroot/index.shs</summary>
<pre><code>
'"${src}"'
</code></pre>
</details>
<p>Licensed under BSD3.</p>
<a href="https://servfail.network">
<img src="https://beta.servfail.network/servfail-88_31.png" alt="SERVFAIL DNS written on a 14 segment display. Next to it is a pentagram made out of burning servers.">
</a>
<p>This spore uses SERVFAIL DNS to DNS its FAILS.</p>
<marquee>I don'"'"'t need no CSS! ...ok maybe just a little</marquee>
<q>straight up shroomping it</q>
~ <em><a href="https://sdomi.pl/">domi</a></em>
</body>
'
else
# THE ACTUAL REDIRECT LOGIC STARTS HERE LOL
txt_domain=$(get_txt_domain "${source_domain}" "${r[url]}")
txt=$(dig +short TXT "${txt_domain}." | tr -d '"')
target_url=$(extract_txt_val to "$txt")
# More options in the future, e.g.:
#code=$(extract_txt_val code "$txt")
header "Location: ${target_url}"
fi
Licensed under BSD3.
This spore uses SERVFAIL DNS to DNS its FAILS.
straight up shroomping it~ domi