save changes
This commit is contained in:
parent
5c584680a4
commit
e6a79496e8
1
Makefile
1
Makefile
|
@ -36,3 +36,4 @@ install: $(NAME)
|
|||
install ./$(NAME) /usr/local/bin
|
||||
install ./$(NAME).service /lib/systemd/system
|
||||
systemctl daemon-reload
|
||||
systemctl restart $(NAME)
|
||||
|
|
2
main.go
2
main.go
|
@ -139,7 +139,7 @@ func run(ctx context.Context) error {
|
|||
}
|
||||
|
||||
if env("DISABLE_WKD", "false") == "false" {
|
||||
app, err := app_wkd.New(ctx, env("WKD_PATH", "pub"), env("WKD_DOMAIN", "pub"))
|
||||
app, err := app_wkd.New(ctx, env("WKD_PATH", "pub"), env("WKD_DOMAIN", "sour.is"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ func NewProof(ctx context.Context, uri, fingerprint string) ProofResolver {
|
|||
return &httpResolve{p, url, nil}
|
||||
}
|
||||
|
||||
case strings.Contains(p.URI.Path, "/conv/"), strings.Contains(p.URI.Path, "/twt/"):
|
||||
case strings.Contains(p.URI.Path, "/conv/"):
|
||||
if sp := strings.SplitN(p.URI.Path, "/", 3); len(sp) == 3 {
|
||||
p.Icon = "fas fa-comment-alt"
|
||||
p.Service = "Twtxt"
|
||||
|
@ -217,6 +217,17 @@ func NewProof(ctx context.Context, uri, fingerprint string) ProofResolver {
|
|||
return &twtxtResolve{p, url, sp[2], nil}
|
||||
}
|
||||
|
||||
case strings.Contains(p.URI.Path, "/twt/"):
|
||||
if sp := strings.SplitN(p.URI.Path, "/", 3); len(sp) == 3 {
|
||||
p.Icon = "fas fa-comment-alt"
|
||||
p.Service = "Twtxt"
|
||||
p.Name = fmt.Sprintf("...@%s", p.URI.Host)
|
||||
p.Link = fmt.Sprintf("https://%s", p.URI.Host)
|
||||
|
||||
url := fmt.Sprintf("https://%s/twt/%v", p.URI.Host, sp[2])
|
||||
return &httpResolve{p, url, nil}
|
||||
}
|
||||
|
||||
default:
|
||||
if sp := strings.SplitN(p.URI.Path, "/", 3); len(sp) > 1 {
|
||||
p.Icon = "fas fa-project-diagram"
|
||||
|
|
|
@ -137,7 +137,7 @@ func (app *wkdApp) getRedirect(w http.ResponseWriter, r *http.Request) {
|
|||
log.Debug().Str("hash", hash).Str("domain", domain).Msg("redirect")
|
||||
if host, adv := getWKDDomain(ctx, domain); adv {
|
||||
log.Debug().Str("host", host).Str("domain", domain).Bool("adv", adv).Msg("redirect")
|
||||
http.Redirect(w, r, fmt.Sprintf("https://%s/.well-known/openpgpkey/hu/%s/%s", host, domain, hash), http.StatusTemporaryRedirect)
|
||||
http.Redirect(w, r, fmt.Sprintf("https://%s/.well-known/openpgpkey/%s/hu/%s", host, domain, hash), http.StatusTemporaryRedirect)
|
||||
} else {
|
||||
log.Debug().Str("host", host).Str("domain", domain).Bool("adv", adv).Msg("redirect")
|
||||
http.Redirect(w, r, fmt.Sprintf("https://%s/.well-known/openpgpkey/hu/%s", domain, hash), http.StatusTemporaryRedirect)
|
||||
|
@ -149,18 +149,18 @@ func (app *wkdApp) getRedirect(w http.ResponseWriter, r *http.Request) {
|
|||
writeText(w, http.StatusBadRequest, "Bad Request")
|
||||
}
|
||||
|
||||
func (app *wkdApp) getPolicy(w http.ResponseWriter, r *http.Request) {
|
||||
writeText(w, 200, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (app *wkdApp) get(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
log := log.Ctx(ctx)
|
||||
|
||||
log.Print(r.Host)
|
||||
log.Debug().Msgf("Host: %v %v %v", r.Host, app.domain, "foo")
|
||||
|
||||
hash := chi.URLParam(r, "hash")
|
||||
if hash == "policy" {
|
||||
writeText(w, 200, "")
|
||||
return
|
||||
}
|
||||
|
||||
domain := chi.URLParam(r, "domain")
|
||||
if domain == "" {
|
||||
domain = app.domain
|
||||
|
@ -192,6 +192,8 @@ func (app *wkdApp) Routes(r *chi.Mux) {
|
|||
r.MethodFunc("POST", "/pks/add", app.postKey)
|
||||
r.MethodFunc("GET", "/.well-known/openpgpkey/hu/{hash}", app.get)
|
||||
r.MethodFunc("GET", "/.well-known/openpgpkey/{domain}/hu/{hash}", app.get)
|
||||
r.MethodFunc("GET", "/.well-known/openpgpkey/policy", app.getPolicy)
|
||||
r.MethodFunc("GET", "/.well-known/openpgpkey/{domain}/policy", app.getPolicy)
|
||||
}
|
||||
|
||||
func (app *wkdApp) createLinks(kind, name string) error {
|
||||
|
|
Loading…
Reference in New Issue
Block a user