Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
8feb86948e | |||
|
8ccdd9e013 | ||
|
e6a79496e8 | ||
|
5c584680a4 | ||
|
ea0289c2ac |
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,3 +17,4 @@
|
|||||||
sour.is-keyproofs
|
sour.is-keyproofs
|
||||||
.env
|
.env
|
||||||
/pub
|
/pub
|
||||||
|
local.mk
|
||||||
|
7
Makefile
7
Makefile
@ -3,7 +3,8 @@ BUMP?=current
|
|||||||
DATE:=$(shell date -u +%FT%TZ)
|
DATE:=$(shell date -u +%FT%TZ)
|
||||||
HASH:=$(shell git rev-parse HEAD 2> /dev/null)
|
HASH:=$(shell git rev-parse HEAD 2> /dev/null)
|
||||||
VERSION:=$(shell BUMP=$(BUMP) ./version.sh)
|
VERSION:=$(shell BUMP=$(BUMP) ./version.sh)
|
||||||
|
-include local.mk
|
||||||
|
DISABLE_VCARD=true
|
||||||
|
|
||||||
build: $(NAME)
|
build: $(NAME)
|
||||||
|
|
||||||
@ -12,11 +13,14 @@ clean:
|
|||||||
|
|
||||||
version:
|
version:
|
||||||
@echo $(VERSION)
|
@echo $(VERSION)
|
||||||
|
|
||||||
tag:
|
tag:
|
||||||
git tag -a v$(VERSION) -m "Version: $(VERSION)"
|
git tag -a v$(VERSION) -m "Version: $(VERSION)"
|
||||||
git push --follow-tags
|
git push --follow-tags
|
||||||
|
|
||||||
release:
|
release:
|
||||||
@make tag BUMP=patch
|
@make tag BUMP=patch
|
||||||
|
|
||||||
run:
|
run:
|
||||||
go run -v \
|
go run -v \
|
||||||
-ldflags "\
|
-ldflags "\
|
||||||
@ -36,3 +40,4 @@ install: $(NAME)
|
|||||||
install ./$(NAME) /usr/local/bin
|
install ./$(NAME) /usr/local/bin
|
||||||
install ./$(NAME).service /lib/systemd/system
|
install ./$(NAME).service /lib/systemd/system
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
systemctl restart $(NAME)
|
||||||
|
1
go.mod
1
go.mod
@ -22,6 +22,7 @@ require (
|
|||||||
go.uber.org/ratelimit v0.1.0
|
go.uber.org/ratelimit v0.1.0
|
||||||
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9
|
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9
|
||||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
|
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
|
golang.org/x/text v0.3.4 // indirect
|
||||||
gosrc.io/xmpp v0.5.1
|
gosrc.io/xmpp v0.5.1
|
||||||
)
|
)
|
||||||
|
2
go.sum
2
go.sum
@ -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-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 h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
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/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.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
2
main.go
2
main.go
@ -139,7 +139,7 @@ func run(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if env("DISABLE_WKD", "false") == "false" {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ func NewProof(ctx context.Context, uri, fingerprint string) ProofResolver {
|
|||||||
return &httpResolve{p, url, nil}
|
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 {
|
if sp := strings.SplitN(p.URI.Path, "/", 3); len(sp) == 3 {
|
||||||
p.Icon = "fas fa-comment-alt"
|
p.Icon = "fas fa-comment-alt"
|
||||||
p.Service = "Twtxt"
|
p.Service = "Twtxt"
|
||||||
@ -217,6 +217,17 @@ func NewProof(ctx context.Context, uri, fingerprint string) ProofResolver {
|
|||||||
return &twtxtResolve{p, url, sp[2], nil}
|
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:
|
default:
|
||||||
if sp := strings.SplitN(p.URI.Path, "/", 3); len(sp) > 1 {
|
if sp := strings.SplitN(p.URI.Path, "/", 3); len(sp) > 1 {
|
||||||
p.Icon = "fas fa-project-diagram"
|
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")
|
log.Debug().Str("hash", hash).Str("domain", domain).Msg("redirect")
|
||||||
if host, adv := getWKDDomain(ctx, domain); adv {
|
if host, adv := getWKDDomain(ctx, domain); adv {
|
||||||
log.Debug().Str("host", host).Str("domain", domain).Bool("adv", adv).Msg("redirect")
|
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 {
|
} else {
|
||||||
log.Debug().Str("host", host).Str("domain", domain).Bool("adv", adv).Msg("redirect")
|
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)
|
http.Redirect(w, r, fmt.Sprintf("https://%s/.well-known/openpgpkey/hu/%s", domain, hash), http.StatusTemporaryRedirect)
|
||||||
@ -149,11 +149,16 @@ func (app *wkdApp) getRedirect(w http.ResponseWriter, r *http.Request) {
|
|||||||
writeText(w, http.StatusBadRequest, "Bad 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) {
|
func (app *wkdApp) get(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
log := log.Ctx(ctx)
|
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")
|
hash := chi.URLParam(r, "hash")
|
||||||
domain := chi.URLParam(r, "domain")
|
domain := chi.URLParam(r, "domain")
|
||||||
@ -186,7 +191,9 @@ func (app *wkdApp) Routes(r *chi.Mux) {
|
|||||||
r.MethodFunc("GET", "/key/{hash}", app.get)
|
r.MethodFunc("GET", "/key/{hash}", app.get)
|
||||||
r.MethodFunc("POST", "/pks/add", app.postKey)
|
r.MethodFunc("POST", "/pks/add", app.postKey)
|
||||||
r.MethodFunc("GET", "/.well-known/openpgpkey/hu/{hash}", app.get)
|
r.MethodFunc("GET", "/.well-known/openpgpkey/hu/{hash}", app.get)
|
||||||
r.MethodFunc("GET", "/.well-known/openpgpkey/hu/{domain}/{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 {
|
func (app *wkdApp) createLinks(kind, name string) error {
|
||||||
@ -197,7 +204,7 @@ func (app *wkdApp) createLinks(kind, name string) error {
|
|||||||
src := filepath.Join("..", kind, name)
|
src := filepath.Join("..", kind, name)
|
||||||
name = strings.ToLower(name)
|
name = strings.ToLower(name)
|
||||||
|
|
||||||
hash, domain := hashHuman(name)
|
hash, _ := hashHuman(name)
|
||||||
link := filepath.Join(app.path, ".links", strings.Join([]string{kind, hash}, "-"))
|
link := filepath.Join(app.path, ".links", strings.Join([]string{kind, hash}, "-"))
|
||||||
err := app.replaceLink(src, link)
|
err := app.replaceLink(src, link)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -221,7 +228,7 @@ func (app *wkdApp) removeLinks(kind, name string) error {
|
|||||||
}
|
}
|
||||||
name = strings.ToLower(name)
|
name = strings.ToLower(name)
|
||||||
|
|
||||||
hash, domain := hashHuman(name)
|
hash, _ := hashHuman(name)
|
||||||
link := filepath.Join(app.path, ".links", strings.Join([]string{kind, hash}, "-"))
|
link := filepath.Join(app.path, ".links", strings.Join([]string{kind, hash}, "-"))
|
||||||
err := os.Remove(link)
|
err := os.Remove(link)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
18
version.sh
18
version.sh
@ -1,8 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Increment a version string using Semantic Versioning (SemVer) terminology.
|
# Increment a version string using Semantic Versioning (SemVer) terminology.
|
||||||
|
|
||||||
# Parse command line options.
|
# Parse command line options.
|
||||||
|
BUMP="${BUMP:="$1"}"
|
||||||
|
|
||||||
case $BUMP in
|
case $BUMP in
|
||||||
current ) ;;
|
current ) ;;
|
||||||
@ -11,43 +11,43 @@ case $BUMP in
|
|||||||
patch ) patch=true;;
|
patch ) patch=true;;
|
||||||
esac
|
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.
|
# 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 version string is missing or has the wrong number of members, show usage message.
|
||||||
|
|
||||||
if [ ${#a[@]} -ne 3 ]
|
if [ ${#a[@]} -ne 3 ]
|
||||||
then
|
then
|
||||||
version=0.0.0
|
version=0.0.0
|
||||||
a=( ${version//./ } )
|
IFS="." read -r -a a <<< "$version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increment version numbers as requested.
|
# Increment version numbers as requested.
|
||||||
|
|
||||||
if [ ! -z $major ]
|
if [ -n "$major" ]
|
||||||
then
|
then
|
||||||
((a[0]++))
|
((a[0]++))
|
||||||
a[1]=0
|
a[1]=0
|
||||||
a[2]=0
|
a[2]=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z $minor ]
|
if [ -n "$minor" ]
|
||||||
then
|
then
|
||||||
((a[1]++))
|
((a[1]++))
|
||||||
a[2]=0
|
a[2]=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z $patch ]
|
if [ -n "$patch" ]
|
||||||
then
|
then
|
||||||
((a[2]++))
|
((a[2]++))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if git status --porcelain >/dev/null
|
if git status --porcelain >/dev/null
|
||||||
then
|
then
|
||||||
echo "${a[0]}.${a[1]}.${a[2]}"
|
echo "v${a[0]}.${a[1]}.${a[2]}"
|
||||||
else
|
else
|
||||||
echo "${a[0]}.${a[1]}.${a[2]}-dirty"
|
echo "v${a[0]}.${a[1]}.${a[2]}-dirty"
|
||||||
fi
|
fi
|
Loading…
x
Reference in New Issue
Block a user