2
0
Fork 0
webfinger/main.go

92 lines
4.6 KiB
Go

package main
import (
"fmt"
"net/http"
)
var redirects map[string][]string
func HandleWebfinger(w http.ResponseWriter, req *http.Request) {
olduser := req.URL.Query().Get("resource")[5:]
newuser, ok := redirects[olduser]
if !ok {
w.WriteHeader(404)
return
}
s := `{
"subject": "acct:%[1]s@%[2]s",
"aliases": [
"https://%[2]s/@%[1]s",
"https://%[2]s/users/%[1]s"
],
"links": [
{
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/html",
"href": "https://%[2]s/@%[1]s"
},
{
"rel": "self",
"type": "application/activity+json",
"href": "https://%[2]s/users/%[1]s"
}
]
}`
w.Header().Set("Content-Type", "application/json")
fmt.Fprintln(w, fmt.Sprintf(s, newuser[0], newuser[1]))
}
func main() {
redirects = make(map[string][]string)
redirects["astra@gearheads.social"] = []string{"astra", "ap.zio.sh"}
redirects["ducky@gearheads.social"] = []string{"ducky", "ap.zio.sh"}
redirects["creativeicing@gearheads.social"] = []string{"CreativeIcing", "rubber.social"}
redirects["gearbound@gearheads.social"] = []string{"gearbound", "rubber.social"}
redirects["theducky@gearheads.social"] = []string{"ducky", "zio.sh"}
redirects["TinkerGear@gearheads.social"] = []string{"TinkerGear", "woof.group"}
redirects["gearedrock@gearheads.social"] = []string{"gearedrock", "rubber.social"}
redirects["Jaxon@gearheads.social"] = []string{"Jaxon", "woof.group"}
redirects["PupNirru@gearheads.social"] = []string{"PupNirru", "rubber.social"}
redirects["queerbeetfetischboy@gearheads.social"] = []string{"queerbeetgearhead", "gearheads.social"}
redirects["Vekton@gearheads.social"] = []string{"Vekton", "rubber.social"}
redirects["gearfrk11814@gearheads.social"] = []string{"Gearfreak_OFR", "gearheads.social"}
redirects["gearlicious@gearheads.social"] = []string{"gearlicious", "rubber.social"}
redirects["Duke_Albert@gearheads.social"] = []string{"Duke_Albert", "mastodon.social"}
redirects["rbbrbts@gearheads.social"] = []string{"queer_workwear", "rubber.social"}
redirects["second2742@gearheads.social"] = []string{"shyny_gear", "rubber.social"}
redirects["dabg0@gearheads.social"] = []string{"dabg0", "mastodon.social"}
redirects["gearguin@gearheads.social"] = []string{"Gearguin", "rubber.social"}
redirects["Halipuppeh@gearheads.social"] = []string{"Halipuppeh", "rubber.social"}
redirects["snoopypup@gearheads.social"] = []string{"snoopy", "woof.group"}
redirects["snakebite@gearheads.social"] = []string{"Snakebite", "rubber.social"}
redirects["asciran@gearheads.social"] = []string{"asciran", "woof.group"}
redirects["kometMUC@gearheads.social"] = []string{"kometMUC", "woof.group"}
redirects["pupsparkle@gearheads.social"] = []string{"pupsparkle", "rubber.social"}
redirects["pupkairo@gearheads.social"] = []string{"pupkairo", "woof.group"}
redirects["qsp@gearheads.social"] = []string{"qsp", "rubber.social"}
redirects["twincitypup@gearheads.social"] = []string{"twincitypup", "woof.group"}
redirects["shyny_gear@gearheads.social"] = []string{"shyny_gear", "rubber.social"}
redirects["mute77@gearheads.social"] = []string{"mute77", "rubber.social"}
redirects["Gearweti@gearheads.social"] = []string{"Gearweti", "rubber.social"}
redirects["NeyosBoosts@gearheads.social"] = []string{"NeyosBoosts", "rubber.social"}
redirects["cphFFsub@gearheads.social"] = []string{"cphFFsub", "woof.group"}
redirects["Lthman@gearheads.social"] = []string{"FFmanCPH", "woof.group"}
redirects["RTFM@gearheads.social"] = []string{"RTFM", "rubber.social"}
redirects["bondageflo@gearheads.social"] = []string{"bondageflo", "rubber.social"}
redirects["masterhusband@gearheads.social"] = []string{"masterhusband", "woof.group"}
redirects["rgemaster@gearheads.social"] = []string{"RGEMaster", "rubber.social"}
redirects["GaySlaveHusband@gearheads.social"] = []string{"GaySlaveHusband", "woof.group"}
redirects["arcticopsmx@gearheads.social"] = []string{"arcticopsmx", "woof.group"}
redirects["Red_Fox703@gearheads.social"] = []string{"red_fox703", "woof.group"}
redirects["LeatherAlphaskin@gearheads.social"] = []string{"LeatherAlphaSkin", "woof.group"}
redirects["gregingear@gearheads.social"] = []string{"gregingear", "rubber.social"}
redirects["rumble@gearheads.social"] = []string{"rumble", "rubber.social"}
redirects["uniformgearhead@gearheads.social"] = []string{"uniformgearhead", "gear.pictures"}
redirects["superpsyze@gearheads.social"] = []string{"superpsyze", "rubber.social"}
http.HandleFunc("/.well-known/webfinger", HandleWebfinger)
http.ListenAndServe(":8888", nil)
}