Compare commits

...

3 Commits

Author SHA1 Message Date
xuu
8feb86948e
fix: imports 2023-05-29 13:31:54 -06:00
Jon Lundy
8ccdd9e013
fix: version generate 2023-01-06 13:30:33 -07:00
Jon Lundy
e6a79496e8 save changes 2021-12-12 06:34:58 -07:00
8 changed files with 42 additions and 20 deletions

3
.gitignore vendored
View File

@ -16,4 +16,5 @@
sour.is-keyproofs
.env
/pub
/pub
local.mk

View File

@ -3,7 +3,8 @@ BUMP?=current
DATE:=$(shell date -u +%FT%TZ)
HASH:=$(shell git rev-parse HEAD 2> /dev/null)
VERSION:=$(shell BUMP=$(BUMP) ./version.sh)
-include local.mk
DISABLE_VCARD=true
build: $(NAME)
@ -12,11 +13,14 @@ clean:
version:
@echo $(VERSION)
tag:
git tag -a v$(VERSION) -m "Version: $(VERSION)"
git push --follow-tags
release:
@make tag BUMP=patch
run:
go run -v \
-ldflags "\
@ -36,3 +40,4 @@ install: $(NAME)
install ./$(NAME) /usr/local/bin
install ./$(NAME).service /lib/systemd/system
systemctl daemon-reload
systemctl restart $(NAME)

1
go.mod
View File

@ -22,6 +22,7 @@ require (
go.uber.org/ratelimit v0.1.0
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.3.4 // indirect
gosrc.io/xmpp v0.5.1
)

2
go.sum
View File

@ -145,6 +145,8 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

View File

@ -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
}

View File

@ -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"

View File

@ -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 {

View File

@ -1,8 +1,8 @@
#!/bin/bash
# Increment a version string using Semantic Versioning (SemVer) terminology.
# Parse command line options.
BUMP="${BUMP:="$1"}"
case $BUMP in
current ) ;;
@ -11,43 +11,43 @@ case $BUMP in
patch ) patch=true;;
esac
version=$(git describe --tags `git rev-list --tags --max-count=1 2> /dev/null` 2> /dev/null|cut -b2-)
version=$(git describe --tags "$(git rev-list --tags --max-count=1 2> /dev/null)" 2> /dev/null|cut -b2-)
# Build array from version string.
a=( ${version//./ } )
IFS="." read -r -a a <<< "$version"
# If version string is missing or has the wrong number of members, show usage message.
if [ ${#a[@]} -ne 3 ]
then
version=0.0.0
a=( ${version//./ } )
IFS="." read -r -a a <<< "$version"
fi
# Increment version numbers as requested.
if [ ! -z $major ]
if [ -n "$major" ]
then
((a[0]++))
a[1]=0
a[2]=0
fi
if [ ! -z $minor ]
if [ -n "$minor" ]
then
((a[1]++))
a[2]=0
fi
if [ ! -z $patch ]
if [ -n "$patch" ]
then
((a[2]++))
fi
if git status --porcelain >/dev/null
then
echo "${a[0]}.${a[1]}.${a[2]}"
echo "v${a[0]}.${a[1]}.${a[2]}"
else
echo "${a[0]}.${a[1]}.${a[2]}-dirty"
echo "v${a[0]}.${a[1]}.${a[2]}-dirty"
fi