Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
8feb86948e | |||
|
8ccdd9e013 | ||
|
e6a79496e8 | ||
|
5c584680a4 | ||
|
ea0289c2ac | ||
|
e6fe68a548 | ||
|
cefa2d7874 | ||
|
eefe823632 | ||
|
50a3399718 | ||
|
c00d091ed2 |
36
.github/workflows/go.yml
vendored
Normal file
36
.github/workflows/go.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
name: Go
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Set up Go 1.x
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ^1.13
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get dependencies
|
||||
run: |
|
||||
go get -v -t -d ./...
|
||||
if [ -f Gopkg.toml ]; then
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
dep ensure
|
||||
fi
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
|
||||
- name: Test
|
||||
run: go test -v ./...
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -16,4 +16,5 @@
|
||||
|
||||
sour.is-keyproofs
|
||||
.env
|
||||
/pub
|
||||
/pub
|
||||
local.mk
|
||||
|
7
Makefile
7
Makefile
@ -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)
|
||||
|
3
go.mod
3
go.mod
@ -20,8 +20,9 @@ require (
|
||||
github.com/tv42/zbase32 v0.0.0-20190604154422-aacc64a8f915
|
||||
go.uber.org/multierr v1.6.0
|
||||
go.uber.org/ratelimit v0.1.0
|
||||
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392
|
||||
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
|
||||
)
|
||||
|
13
go.sum
13
go.sum
@ -23,13 +23,12 @@ github.com/go-interpreter/wagon v0.6.0/go.mod h1:5+b/MBYkclRZngKF5s6qrgWxSLgE9F5
|
||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
|
||||
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
|
||||
github.com/gokyle/readpass v0.0.0-20150812192153-d7e39d2c89f5/go.mod h1:a1ng7o2dg1Q/Pn7zUkAZ8cxv+XDkjWcddLVxlmWjTVc=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
@ -71,6 +70,8 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prologic/cryptutils v0.0.0-20201213145959-45b3763e425c h1:RzknJtk6Iojvy4S2itL1ZA1kV1vP3WhgkUXnVSD4PCs=
|
||||
github.com/prologic/cryptutils v0.0.0-20201213145959-45b3763e425c/go.mod h1:7YqkDf/i+MfquGe1Cs7KO7jCQDUBTv7w1ggtbn5cH6Y=
|
||||
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
@ -112,10 +113,10 @@ go.uber.org/ratelimit v0.1.0/go.mod h1:2X8KaoNd1J0lZV+PxJk/5+DGbO/tpwLR1m++a7FnB
|
||||
golang.org/x/crypto v0.0.0-20180426230345-b49d69b5da94/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 h1:phUcVbl53swtrUN8kQEXFhUxPlIlWyBfKmidCu7P95o=
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 h1:xYJJ3S178yv++9zXV/hnr29plCAGO9vAFG9dorqaFQc=
|
||||
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604=
|
||||
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
@ -125,8 +126,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@ -146,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=
|
||||
|
142
main.go
142
main.go
@ -15,16 +15,24 @@ import (
|
||||
"github.com/rs/cors"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"gosrc.io/xmpp"
|
||||
|
||||
"github.com/sour-is/keyproofs/pkg/cache"
|
||||
"github.com/sour-is/keyproofs/pkg/config"
|
||||
"github.com/sour-is/keyproofs/pkg/graceful"
|
||||
"github.com/sour-is/keyproofs/pkg/keyproofs"
|
||||
"github.com/sour-is/keyproofs/pkg/httpsrv"
|
||||
|
||||
app_avatar "github.com/sour-is/keyproofs/pkg/app/avatar"
|
||||
app_dns "github.com/sour-is/keyproofs/pkg/app/dns"
|
||||
app_keyproofs "github.com/sour-is/keyproofs/pkg/app/keyproofs"
|
||||
app_vcard "github.com/sour-is/keyproofs/pkg/app/vcard"
|
||||
app_wkd "github.com/sour-is/keyproofs/pkg/app/wkd"
|
||||
)
|
||||
|
||||
var (
|
||||
// AppName Application Name
|
||||
AppName string = "KeyProofs"
|
||||
|
||||
// AppVersion Application Version Number
|
||||
AppVersion string
|
||||
|
||||
@ -48,14 +56,21 @@ func main() {
|
||||
ctx, _ = graceful.WithWaitGroup(ctx)
|
||||
|
||||
cfg := config.New()
|
||||
cfg.Set("app-name", "KeyProofs")
|
||||
cfg.Set("app-name", AppName)
|
||||
cfg.Set("app-version", AppVersion)
|
||||
cfg.Set("build-hash", BuildHash)
|
||||
cfg.Set("build-date", BuildDate)
|
||||
ctx = cfg.Apply(ctx)
|
||||
|
||||
log.Info().
|
||||
Str("app", AppName).
|
||||
Str("version", AppVersion).
|
||||
Str("build-hash", BuildHash).
|
||||
Str("build-date", BuildDate).
|
||||
Msg("startup...")
|
||||
|
||||
if err := run(ctx); err != nil {
|
||||
log.Error().Stack().Err(err).Msg("Application Failed")
|
||||
log.Error().Err(err).Msg("Application Failed")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@ -63,6 +78,7 @@ func main() {
|
||||
func run(ctx context.Context) error {
|
||||
log := log.Ctx(ctx)
|
||||
wg := graceful.WaitGroup(ctx)
|
||||
cfg := config.FromContext(ctx)
|
||||
|
||||
// derive baseURL from listener options
|
||||
listen := env("HTTP_LISTEN", ":9061")
|
||||
@ -72,89 +88,83 @@ func run(ctx context.Context) error {
|
||||
}
|
||||
baseURL := fmt.Sprintf("http://%s", host)
|
||||
|
||||
// Set config values
|
||||
cfg := config.FromContext(ctx)
|
||||
cfg.Set("base-url", env("BASE_URL", baseURL))
|
||||
cfg.Set("dns-url", env("DNS_URL", baseURL))
|
||||
cfg.Set("xmpp-url", env("XMPP_URL", baseURL))
|
||||
|
||||
cfg.Set("reddit.api-key", os.Getenv("REDDIT_APIKEY"))
|
||||
cfg.Set("reddit.secret", os.Getenv("REDDIT_SECRET"))
|
||||
|
||||
cfg.Set("xmpp-config", &xmpp.Config{
|
||||
Jid: os.Getenv("XMPP_USERNAME"),
|
||||
Credential: xmpp.Password(os.Getenv("XMPP_PASSWORD")),
|
||||
// Setup router
|
||||
cors := cors.New(cors.Options{
|
||||
AllowCredentials: true,
|
||||
AllowedMethods: strings.Fields(env("CORS_METHODS", "GET")),
|
||||
AllowedOrigins: strings.Fields(env("CORS_ORIGIN", "*")),
|
||||
})
|
||||
|
||||
logFmt := &middleware.DefaultLogFormatter{Logger: accessLog(log.Info)}
|
||||
|
||||
mux := chi.NewRouter()
|
||||
mux.Use(
|
||||
cfg.ApplyHTTP,
|
||||
func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
r = r.WithContext(log.WithContext(r.Context()))
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
},
|
||||
secHeaders,
|
||||
cors.New(cors.Options{
|
||||
AllowCredentials: true,
|
||||
AllowedMethods: strings.Fields(env("CORS_METHODS", "GET")),
|
||||
AllowedOrigins: strings.Fields(env("CORS_ORIGIN", "*")),
|
||||
}).Handler,
|
||||
middleware.RequestID,
|
||||
middleware.RealIP,
|
||||
middleware.RequestLogger(&middleware.DefaultLogFormatter{Logger: accessLog(log.Info)}),
|
||||
middleware.Recoverer,
|
||||
middleware.RequestLogger(logFmt),
|
||||
secHeaders,
|
||||
cors.Handler,
|
||||
addLogger(log),
|
||||
cfg.ApplyHTTP,
|
||||
)
|
||||
|
||||
if env("DISABLE_KEYPROOF", "false") == "false" {
|
||||
// Set config values
|
||||
cfg.Set("base-url", env("BASE_URL", baseURL))
|
||||
cfg.Set("dns-url", env("DNS_URL", baseURL))
|
||||
cfg.Set("xmpp-url", env("XMPP_URL", baseURL))
|
||||
|
||||
cfg.Set("reddit.api-key", os.Getenv("REDDIT_APIKEY"))
|
||||
cfg.Set("reddit.secret", os.Getenv("REDDIT_SECRET"))
|
||||
cfg.Set("github.secret", os.Getenv("GITHUB_SECRET"))
|
||||
|
||||
// Create cache for promise engine
|
||||
arc, _ := lru.NewARC(4096)
|
||||
c := cache.New(arc)
|
||||
keyproofs.NewKeyProofApp(ctx, c).Routes(mux)
|
||||
app_keyproofs.NewKeyProofApp(ctx, c).Routes(mux)
|
||||
}
|
||||
|
||||
if env("DISABLE_DNS", "false") == "false" {
|
||||
keyproofs.NewDNSApp(ctx).Routes(mux)
|
||||
app_dns.New(ctx).Routes(mux)
|
||||
}
|
||||
|
||||
if env("DISABLE_AVATAR", "false") == "false" {
|
||||
avatarApp, err := keyproofs.NewAvatarApp(ctx, env("AVATAR_PATH", "pub"))
|
||||
app, err := app_avatar.New(ctx, env("AVATAR_PATH", "pub"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
avatarApp.Routes(mux)
|
||||
app.Routes(mux)
|
||||
}
|
||||
|
||||
if env("DISABLE_WKD", "false") == "false" {
|
||||
avatarApp, err := keyproofs.NewWKDApp(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
|
||||
}
|
||||
|
||||
avatarApp.Routes(mux)
|
||||
app.Routes(mux)
|
||||
}
|
||||
|
||||
if env("DISABLE_VCARD", "false") == "false" {
|
||||
vcardApp, err := keyproofs.NewVCardApp(ctx)
|
||||
app, err := app_vcard.New(ctx, &xmpp.Config{
|
||||
Jid: os.Getenv("XMPP_USERNAME"),
|
||||
Credential: xmpp.Password(os.Getenv("XMPP_PASSWORD")),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
vcardApp.Routes(mux)
|
||||
app.Routes(mux)
|
||||
}
|
||||
|
||||
log.Info().
|
||||
Str("app", cfg.GetString("app-name")).
|
||||
Str("version", cfg.GetString("app-version")).
|
||||
Str("build-hash", cfg.GetString("build-hash")).
|
||||
Str("build-date", cfg.GetString("build-date")).
|
||||
Str("listen", listen).
|
||||
Int("user", os.Geteuid()).
|
||||
Int("group", os.Getgid()).
|
||||
Msg("startup")
|
||||
Msg("running")
|
||||
|
||||
err := New(&http.Server{
|
||||
err := httpsrv.New(&http.Server{
|
||||
Addr: listen,
|
||||
WriteTimeout: 15 * time.Second,
|
||||
ReadTimeout: 15 * time.Second,
|
||||
@ -167,41 +177,6 @@ func run(ctx context.Context) error {
|
||||
return wg.Wait(5 * time.Second)
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
srv *http.Server
|
||||
}
|
||||
|
||||
func New(s *http.Server) *Server {
|
||||
return &Server{srv: s}
|
||||
}
|
||||
func (s *Server) Run(ctx context.Context) error {
|
||||
log := log.Ctx(ctx)
|
||||
wg := graceful.WaitGroup(ctx)
|
||||
|
||||
wg.Go(func() error {
|
||||
<-ctx.Done()
|
||||
log.Info().Msg("Shutdown HTTP")
|
||||
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
defer cancel()
|
||||
err := s.srv.Shutdown(ctx)
|
||||
if err != nil && err != http.ErrServerClosed {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Info().Msg("Stopped HTTP")
|
||||
return nil
|
||||
})
|
||||
|
||||
err := s.srv.ListenAndServe()
|
||||
if err != nil && err != http.ErrServerClosed {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func env(name, defaultValue string) string {
|
||||
if value := os.Getenv(name); value != "" {
|
||||
return value
|
||||
@ -227,3 +202,12 @@ type accessLog func() *zerolog.Event
|
||||
func (a accessLog) Print(v ...interface{}) {
|
||||
a().Msg(fmt.Sprint(v...))
|
||||
}
|
||||
|
||||
func addLogger(log *zerolog.Logger) func(next http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
r = r.WithContext(log.WithContext(r.Context()))
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package keyproofs
|
||||
package app_avatar
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -21,17 +21,20 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/sour-is/keyproofs/pkg/graceful"
|
||||
"github.com/sour-is/keyproofs/pkg/style"
|
||||
)
|
||||
|
||||
type avatarApp struct {
|
||||
var pixl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
|
||||
|
||||
type avatar struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func NewAvatarApp(ctx context.Context, path string) (*avatarApp, error) {
|
||||
func New(ctx context.Context, path string) (*avatar, error) {
|
||||
log := log.Ctx(ctx)
|
||||
|
||||
path = filepath.Clean(path)
|
||||
app := &avatarApp{path: path}
|
||||
app := &avatar{path: path}
|
||||
err := app.CheckFiles(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("check files: %w", err)
|
||||
@ -84,7 +87,7 @@ func NewAvatarApp(ctx context.Context, path string) (*avatarApp, error) {
|
||||
return app, nil
|
||||
}
|
||||
|
||||
func (app *avatarApp) CheckFiles(ctx context.Context) error {
|
||||
func (app *avatar) CheckFiles(ctx context.Context) error {
|
||||
log := log.Ctx(ctx)
|
||||
|
||||
for _, name := range []string{".links", "avatar", "bg", "cover"} {
|
||||
@ -118,7 +121,7 @@ func (app *avatarApp) CheckFiles(ctx context.Context) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (app *avatarApp) get(w http.ResponseWriter, r *http.Request) {
|
||||
func (app *avatar) get(w http.ResponseWriter, r *http.Request) {
|
||||
log := log.Ctx(r.Context())
|
||||
|
||||
log.Print(r.Host)
|
||||
@ -133,7 +136,7 @@ func (app *avatarApp) get(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debug().Int("width", sizeW).Int("height", sizeH).Bool("resize", resize).Str("kind", kind).Msg("Get Image")
|
||||
|
||||
if strings.ContainsRune(hash, '@') {
|
||||
avatarHost, _, err := styleSRV(r.Context(), hash)
|
||||
avatarHost, _, err := style.GetSRV(r.Context(), hash)
|
||||
if err != nil {
|
||||
writeText(w, 500, err.Error())
|
||||
return
|
||||
@ -213,7 +216,7 @@ func (app *avatarApp) get(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func (app *avatarApp) Routes(r *chi.Mux) {
|
||||
func (app *avatar) Routes(r *chi.Mux) {
|
||||
r.MethodFunc("GET", "/{kind:avatar|bg|cover}/{hash}", app.get)
|
||||
}
|
||||
|
||||
@ -228,7 +231,7 @@ func hashSHA256(name string) string {
|
||||
return hashString(name, sha256.New())
|
||||
}
|
||||
|
||||
func (app *avatarApp) createLinks(kind, name string) error {
|
||||
func (app *avatar) createLinks(kind, name string) error {
|
||||
if !strings.ContainsRune(name, '@') {
|
||||
return nil
|
||||
}
|
||||
@ -250,7 +253,7 @@ func (app *avatarApp) createLinks(kind, name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (app *avatarApp) removeLinks(kind, name string) error {
|
||||
func (app *avatar) removeLinks(kind, name string) error {
|
||||
if !strings.ContainsRune(name, '@') {
|
||||
return nil
|
||||
}
|
||||
@ -270,7 +273,7 @@ func (app *avatarApp) removeLinks(kind, name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (app *avatarApp) replaceLink(src, link string) error {
|
||||
func (app *avatar) replaceLink(src, link string) error {
|
||||
if dst, err := os.Readlink(link); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
err = os.Symlink(src, link)
|
||||
@ -342,3 +345,10 @@ func clamp(min, max, size int) int {
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
// WriteText writes plain text
|
||||
func writeText(w http.ResponseWriter, code int, o string) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(code)
|
||||
_, _ = w.Write([]byte(o))
|
||||
}
|
37
pkg/app/dns/dns.go
Normal file
37
pkg/app/dns/dns.go
Normal file
@ -0,0 +1,37 @@
|
||||
package app_dns
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
)
|
||||
|
||||
type app struct {
|
||||
resolver *net.Resolver
|
||||
}
|
||||
|
||||
func New(ctx context.Context) *app {
|
||||
return &app{resolver: net.DefaultResolver}
|
||||
}
|
||||
func (app *app) getDNS(w http.ResponseWriter, r *http.Request) {
|
||||
domain := chi.URLParam(r, "domain")
|
||||
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
|
||||
res, err := app.resolver.LookupTXT(r.Context(), domain)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
|
||||
fmt.Fprintln(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprintln(w, strings.Join(res, "\n"))
|
||||
}
|
||||
func (app *app) Routes(r *chi.Mux) {
|
||||
r.MethodFunc("GET", "/dns/{domain}", app.getDNS)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package keyproofs
|
||||
package app_keyproofs
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -16,7 +16,10 @@ import (
|
||||
|
||||
"github.com/sour-is/keyproofs/pkg/cache"
|
||||
"github.com/sour-is/keyproofs/pkg/config"
|
||||
"github.com/sour-is/keyproofs/pkg/opgp"
|
||||
"github.com/sour-is/keyproofs/pkg/opgp/entity"
|
||||
"github.com/sour-is/keyproofs/pkg/promise"
|
||||
"github.com/sour-is/keyproofs/pkg/style"
|
||||
)
|
||||
|
||||
var expireAfter = 20 * time.Minute
|
||||
@ -26,11 +29,11 @@ var runnerTimeout = 30 * time.Second
|
||||
var pixl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
|
||||
var keypng, _ = base64.StdEncoding.DecodeString("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABKUlEQVQ4jZ2SvUoDURCFUy/Y2Fv4BoKIiFgLSWbmCWw0e3cmNgGfwacQsbCxUEFEEIVkxsQulaK1kheIiFVW1mJXiZv904FbXb5zzvzUaiWlPqyYwIkyvRjjqwmeaauxUcbFMKOvTKEJRVPv05hCY9wrhHt+fckEJ79gxg9rweJN8qdSkESZjlLOkQm+Xe9szlubFkxwYoznuQIm9DgrQJEyjZXpPU5Eo6L+H7IEUmJFAnBQJmAMp5nw0IFnjFoiEGrQXJuBLx14JtgtiR5qAO2c4aFLAffGeGiMT8b0rAEe96WxnBlbGbbia/vZ+2CwjXO5g0pN/TZ1NNXgoQPPHO2aJLsViu4E+xdVnXsOOtPOMbxeDY6jw/6/nL+r6+qryjQyhqs/OSf1Bf+pJC1wKqO/AAAAAElFTkSuQmCC")
|
||||
|
||||
var defaultStyle = &Style{
|
||||
var defaultStyle = &style.Style{
|
||||
Avatar: pixl,
|
||||
Cover: pixl,
|
||||
Background: pixl,
|
||||
Palette: getPalette("#93CCEA"),
|
||||
Palette: style.GetPalette("#93CCEA"),
|
||||
}
|
||||
|
||||
type keyproofApp struct {
|
||||
@ -70,24 +73,24 @@ func (app *keyproofApp) getProofs(w http.ResponseWriter, r *http.Request) {
|
||||
defer cancel()
|
||||
|
||||
// Run tasks to resolve entity, style, and proofs.
|
||||
task := app.tasker.Run(EntityKey(id), func(q promise.Q) {
|
||||
task := app.tasker.Run(entity.Key(id), func(q promise.Q) {
|
||||
ctx := q.Context()
|
||||
log := zlog.Ctx(ctx).With().Interface(fmtKey(q), q.Key()).Logger()
|
||||
|
||||
key := q.Key().(EntityKey)
|
||||
key := q.Key().(entity.Key)
|
||||
|
||||
entity, err := getOpenPGPkey(ctx, string(key))
|
||||
e, err := opgp.GetKey(ctx, string(key))
|
||||
if err != nil {
|
||||
q.Reject(err)
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug().Msg("Resolving Entity")
|
||||
q.Resolve(entity)
|
||||
q.Resolve(e)
|
||||
})
|
||||
|
||||
task.After(func(q promise.ResultQ) {
|
||||
entity := q.Result().(*Entity)
|
||||
entity := q.Result().(*entity.Entity)
|
||||
|
||||
zlog.Ctx(q.Context()).
|
||||
Info().
|
||||
@ -95,14 +98,14 @@ func (app *keyproofApp) getProofs(w http.ResponseWriter, r *http.Request) {
|
||||
Interface(fmtKey(q), q.Key()).
|
||||
Msg("Do Style ")
|
||||
|
||||
q.Run(StyleKey(entity.Primary.Address), func(q promise.Q) {
|
||||
q.Run(style.Key(entity.Primary.Address), func(q promise.Q) {
|
||||
ctx := q.Context()
|
||||
log := zlog.Ctx(ctx).With().Interface(fmtKey(q), q.Key()).Logger()
|
||||
|
||||
key := q.Key().(StyleKey)
|
||||
key := q.Key().(style.Key)
|
||||
|
||||
log.Debug().Msg("start task")
|
||||
style, err := getStyle(ctx, string(key))
|
||||
style, err := style.GetStyle(ctx, string(key))
|
||||
if err != nil {
|
||||
q.Reject(err)
|
||||
return
|
||||
@ -114,7 +117,7 @@ func (app *keyproofApp) getProofs(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
|
||||
task.After(func(q promise.ResultQ) {
|
||||
entity := q.Result().(*Entity)
|
||||
entity := q.Result().(*entity.Entity)
|
||||
log := zlog.Ctx(ctx).
|
||||
With().
|
||||
Interface(fmtKey(q), q.Key()).
|
||||
@ -158,12 +161,12 @@ func (app *keyproofApp) getProofs(w http.ResponseWriter, r *http.Request) {
|
||||
page.IsComplete = true
|
||||
break
|
||||
}
|
||||
page.Entity = task.Result().(*Entity)
|
||||
page.Entity = task.Result().(*entity.Entity)
|
||||
|
||||
case <-ctx.Done():
|
||||
log.Print("Deadline Timeout")
|
||||
if e, ok := app.cache.Get(EntityKey(id)); ok {
|
||||
page.Entity = e.Value().(*Entity)
|
||||
if e, ok := app.cache.Get(entity.Key(id)); ok {
|
||||
page.Entity = e.Value().(*entity.Entity)
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,8 +174,8 @@ func (app *keyproofApp) getProofs(w http.ResponseWriter, r *http.Request) {
|
||||
if page.Entity != nil {
|
||||
var gotStyle, gotProofs bool
|
||||
|
||||
if s, ok := app.cache.Get(StyleKey(page.Entity.Primary.Address)); ok {
|
||||
page.Style = s.Value().(*Style)
|
||||
if s, ok := app.cache.Get(style.Key(page.Entity.Primary.Address)); ok {
|
||||
page.Style = s.Value().(*style.Style)
|
||||
gotStyle = true
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package keyproofs
|
||||
package app_keyproofs
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@ -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"
|
@ -1,10 +1,15 @@
|
||||
package keyproofs
|
||||
package app_keyproofs
|
||||
|
||||
import (
|
||||
"github.com/sour-is/keyproofs/pkg/opgp/entity"
|
||||
"github.com/sour-is/keyproofs/pkg/style"
|
||||
)
|
||||
|
||||
type page struct {
|
||||
AppName string
|
||||
AppBuild string
|
||||
Entity *Entity
|
||||
Style *Style
|
||||
Entity *entity.Entity
|
||||
Style *style.Style
|
||||
Proofs *Proofs
|
||||
|
||||
Markdown string
|
||||
@ -228,7 +233,11 @@ var proofTPL = `
|
||||
<div class="card">
|
||||
<div class="card-header">Public Key</div>
|
||||
<div class="card-body scroll">
|
||||
<pre><code>{{.Entity.ArmorText}}</code></pre>
|
||||
<pre><code>
|
||||
Last Updated {{.Entity.SelfSignature.CreationTime}}
|
||||
|
||||
{{.Entity.ArmorText}}
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
48
pkg/app/vcard/app.go
Normal file
48
pkg/app/vcard/app.go
Normal file
@ -0,0 +1,48 @@
|
||||
package app_vcard
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/mail"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
"gosrc.io/xmpp"
|
||||
)
|
||||
|
||||
type app struct {
|
||||
conn *connection
|
||||
}
|
||||
|
||||
func New(ctx context.Context, xmppConfig *xmpp.Config) (*app, error) {
|
||||
conn, err := NewXMPP(ctx, xmppConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &app{conn: conn}, nil
|
||||
}
|
||||
func (app *app) Routes(r *chi.Mux) {
|
||||
r.MethodFunc("GET", "/vcard/{jid}", app.getVCard)
|
||||
}
|
||||
func (app *app) getVCard(w http.ResponseWriter, r *http.Request) {
|
||||
jid := chi.URLParam(r, "jid")
|
||||
if _, err := mail.ParseAddress(jid); err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprint(w, err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
vcard, err := app.conn.GetXMPPVCard(r.Context(), jid)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
fmt.Fprint(w, err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/xml")
|
||||
w.WriteHeader(200)
|
||||
fmt.Fprint(w, vcard)
|
||||
}
|
36
pkg/app/vcard/vcard.go
Normal file
36
pkg/app/vcard/vcard.go
Normal file
@ -0,0 +1,36 @@
|
||||
package app_vcard
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
"gosrc.io/xmpp/stanza"
|
||||
)
|
||||
|
||||
type VCard struct {
|
||||
XMLName xml.Name `xml:"vcard-temp vCard"`
|
||||
FullName string `xml:"FN"`
|
||||
NickName string `xml:"NICKNAME"`
|
||||
Description string `xml:"DESC"`
|
||||
URL string `xml:"URL"`
|
||||
}
|
||||
|
||||
func NewVCard() *VCard {
|
||||
return &VCard{}
|
||||
}
|
||||
|
||||
func (c *VCard) Namespace() string {
|
||||
return c.XMLName.Space
|
||||
}
|
||||
|
||||
func (c *VCard) GetSet() *stanza.ResultSet {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *VCard) String() string {
|
||||
b, _ := xml.MarshalIndent(c, "", " ")
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func init() {
|
||||
stanza.TypeRegistry.MapExtension(stanza.PKTIQ, xml.Name{Space: "vcard-temp", Local: "vCard"}, VCard{})
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package keyproofs
|
||||
package app_vcard
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -11,35 +11,6 @@ import (
|
||||
"gosrc.io/xmpp/stanza"
|
||||
)
|
||||
|
||||
type VCard struct {
|
||||
XMLName xml.Name `xml:"vcard-temp vCard"`
|
||||
FullName string `xml:"FN"`
|
||||
NickName string `xml:"NICKNAME"`
|
||||
Description string `xml:"DESC"`
|
||||
URL string `xml:"URL"`
|
||||
}
|
||||
|
||||
func NewVCard() *VCard {
|
||||
return &VCard{}
|
||||
}
|
||||
|
||||
func (c *VCard) Namespace() string {
|
||||
return c.XMLName.Space
|
||||
}
|
||||
|
||||
func (c *VCard) GetSet() *stanza.ResultSet {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *VCard) String() string {
|
||||
b, _ := xml.MarshalIndent(c, "", " ")
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func init() {
|
||||
stanza.TypeRegistry.MapExtension(stanza.PKTIQ, xml.Name{Space: "vcard-temp", Local: "vCard"}, VCard{})
|
||||
}
|
||||
|
||||
type connection struct {
|
||||
client xmpp.StreamClient
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package keyproofs
|
||||
package app_wkd
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -17,8 +17,10 @@ import (
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/sour-is/crypto/openpgp"
|
||||
"github.com/sour-is/keyproofs/pkg/graceful"
|
||||
"github.com/tv42/zbase32"
|
||||
|
||||
"github.com/sour-is/keyproofs/pkg/graceful"
|
||||
"github.com/sour-is/keyproofs/pkg/opgp/entity"
|
||||
)
|
||||
|
||||
type wkdApp struct {
|
||||
@ -26,7 +28,7 @@ type wkdApp struct {
|
||||
domain string
|
||||
}
|
||||
|
||||
func NewWKDApp(ctx context.Context, path, domain string) (*wkdApp, error) {
|
||||
func New(ctx context.Context, path, domain string) (*wkdApp, error) {
|
||||
log := log.Ctx(ctx)
|
||||
log.Debug().Str("domain", domain).Str("path", path).Msg("NewWKDApp")
|
||||
|
||||
@ -135,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)
|
||||
@ -147,11 +149,16 @@ 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")
|
||||
domain := chi.URLParam(r, "domain")
|
||||
@ -184,7 +191,9 @@ func (app *wkdApp) Routes(r *chi.Mux) {
|
||||
r.MethodFunc("GET", "/key/{hash}", app.get)
|
||||
r.MethodFunc("POST", "/pks/add", app.postKey)
|
||||
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 {
|
||||
@ -195,8 +204,8 @@ func (app *wkdApp) createLinks(kind, name string) error {
|
||||
src := filepath.Join("..", kind, name)
|
||||
name = strings.ToLower(name)
|
||||
|
||||
hash, domain := hashHuman(name)
|
||||
link := filepath.Join(app.path, ".links", strings.Join([]string{kind, domain, hash}, "-"))
|
||||
hash, _ := hashHuman(name)
|
||||
link := filepath.Join(app.path, ".links", strings.Join([]string{kind, hash}, "-"))
|
||||
err := app.replaceLink(src, link)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -219,8 +228,8 @@ func (app *wkdApp) removeLinks(kind, name string) error {
|
||||
}
|
||||
name = strings.ToLower(name)
|
||||
|
||||
hash, domain := hashHuman(name)
|
||||
link := filepath.Join(app.path, ".links", strings.Join([]string{kind, domain, hash}, "-"))
|
||||
hash, _ := hashHuman(name)
|
||||
link := filepath.Join(app.path, ".links", strings.Join([]string{kind, hash}, "-"))
|
||||
err := os.Remove(link)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -291,7 +300,7 @@ func (app *wkdApp) postKey(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
entity, err := getEntity(lis)
|
||||
e, err := entity.GetOne(lis)
|
||||
if err != nil {
|
||||
log.Err(err).Send()
|
||||
writeText(w, http.StatusBadRequest, "ERR ENTITY")
|
||||
@ -299,7 +308,7 @@ func (app *wkdApp) postKey(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
fname := filepath.Join(app.path, "keys", entity.Primary.Address)
|
||||
fname := filepath.Join(app.path, "keys", e.Primary.Address)
|
||||
|
||||
f, err := os.Open(fname)
|
||||
if os.IsNotExist(err) {
|
||||
@ -311,7 +320,7 @@ func (app *wkdApp) postKey(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
err = entity.Serialize(out)
|
||||
err = e.Serialize(out)
|
||||
if err != nil {
|
||||
log.Err(err).Send()
|
||||
writeText(w, http.StatusInternalServerError, "ERR WRITE")
|
||||
@ -332,7 +341,7 @@ func (app *wkdApp) postKey(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
f.Close()
|
||||
|
||||
compare, err := getEntity(current)
|
||||
compare, err := entity.GetOne(current)
|
||||
if err != nil {
|
||||
log.Err(err).Send()
|
||||
writeText(w, http.StatusInternalServerError, "ERR PARSE")
|
||||
@ -340,20 +349,20 @@ func (app *wkdApp) postKey(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if entity.Fingerprint != compare.Fingerprint {
|
||||
if e.Fingerprint != compare.Fingerprint {
|
||||
w.Header().Set("X-HKP-Status", "Mismatch fingerprint")
|
||||
writeText(w, http.StatusBadRequest, "ERR FINGERPRINT")
|
||||
return
|
||||
}
|
||||
if entity.SelfSignature == nil || compare.SelfSignature == nil {
|
||||
if e.SelfSignature == nil || compare.SelfSignature == nil {
|
||||
w.Header().Set("X-HKP-Status", "Missing signature")
|
||||
writeText(w, http.StatusBadRequest, "ERR SIGNATURE")
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug().Msgf("%v < %v", entity.SelfSignature.CreationTime, compare.SelfSignature.CreationTime)
|
||||
log.Debug().Msgf("%v < %v", e.SelfSignature.CreationTime, compare.SelfSignature.CreationTime)
|
||||
|
||||
if !compare.SelfSignature.CreationTime.Before(entity.SelfSignature.CreationTime) {
|
||||
if !compare.SelfSignature.CreationTime.Before(e.SelfSignature.CreationTime) {
|
||||
w.Header().Set("X-HKP-Status", "out of date")
|
||||
writeText(w, http.StatusBadRequest, "ERR OUT OF DATE")
|
||||
|
||||
@ -368,7 +377,7 @@ func (app *wkdApp) postKey(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
err = entity.Serialize(out)
|
||||
err = e.Serialize(out)
|
||||
if err != nil {
|
||||
log.Err(err).Send()
|
||||
writeText(w, http.StatusInternalServerError, "ERR WRITE")
|
||||
@ -379,3 +388,10 @@ func (app *wkdApp) postKey(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("X-HKP-Status", "Updated key")
|
||||
writeText(w, http.StatusOK, "OK UPDATED")
|
||||
}
|
||||
|
||||
// WriteText writes plain text
|
||||
func writeText(w http.ResponseWriter, code int, o string) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(code)
|
||||
_, _ = w.Write([]byte(o))
|
||||
}
|
46
pkg/httpsrv/server.go
Normal file
46
pkg/httpsrv/server.go
Normal file
@ -0,0 +1,46 @@
|
||||
package httpsrv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/sour-is/keyproofs/pkg/graceful"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
srv *http.Server
|
||||
}
|
||||
|
||||
func New(s *http.Server) *Server {
|
||||
|
||||
return &Server{srv: s}
|
||||
}
|
||||
func (s *Server) Run(ctx context.Context) error {
|
||||
log := log.Ctx(ctx)
|
||||
wg := graceful.WaitGroup(ctx)
|
||||
|
||||
wg.Go(func() error {
|
||||
<-ctx.Done()
|
||||
log.Info().Msg("Shutdown HTTP")
|
||||
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
defer cancel()
|
||||
err := s.srv.Shutdown(ctx)
|
||||
if err != nil && err != http.ErrServerClosed {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Info().Msg("Stopped HTTP")
|
||||
return nil
|
||||
})
|
||||
|
||||
err := s.srv.ListenAndServe()
|
||||
if err != nil && err != http.ErrServerClosed {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package keyproofs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
)
|
||||
|
||||
type dnsApp struct {
|
||||
resolver *net.Resolver
|
||||
}
|
||||
|
||||
func NewDNSApp(ctx context.Context) *dnsApp {
|
||||
return &dnsApp{resolver: net.DefaultResolver}
|
||||
}
|
||||
func (app *dnsApp) getDNS(w http.ResponseWriter, r *http.Request) {
|
||||
domain := chi.URLParam(r, "domain")
|
||||
|
||||
res, err := app.resolver.LookupTXT(r.Context(), domain)
|
||||
if err != nil {
|
||||
writeText(w, 400, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
writeText(w, 200, strings.Join(res, "\n"))
|
||||
}
|
||||
func (app *dnsApp) Routes(r *chi.Mux) {
|
||||
r.MethodFunc("GET", "/dns/{domain}", app.getDNS)
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package keyproofs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/mail"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
zlog "github.com/rs/zerolog/log"
|
||||
"github.com/sour-is/keyproofs/pkg/config"
|
||||
"gosrc.io/xmpp"
|
||||
)
|
||||
|
||||
type vcardApp struct {
|
||||
conn *connection
|
||||
}
|
||||
|
||||
func NewVCardApp(ctx context.Context) (*vcardApp, error) {
|
||||
log := zlog.Ctx(ctx)
|
||||
|
||||
var ok bool
|
||||
var xmppConfig *xmpp.Config
|
||||
if xmppConfig, ok = config.FromContext(ctx).Get("xmpp-config").(*xmpp.Config); !ok {
|
||||
log.Error().Msg("no xmpp-config")
|
||||
|
||||
return nil, fmt.Errorf("no xmpp config")
|
||||
}
|
||||
|
||||
conn, err := NewXMPP(ctx, xmppConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &vcardApp{conn: conn}, nil
|
||||
}
|
||||
func (app *vcardApp) Routes(r *chi.Mux) {
|
||||
r.MethodFunc("GET", "/vcard/{jid}", app.getVCard)
|
||||
}
|
||||
func (app *vcardApp) getVCard(w http.ResponseWriter, r *http.Request) {
|
||||
jid := chi.URLParam(r, "jid")
|
||||
if _, err := mail.ParseAddress(jid); err != nil {
|
||||
fmt.Fprint(w, err)
|
||||
w.WriteHeader(400)
|
||||
}
|
||||
|
||||
vcard, err := app.conn.GetXMPPVCard(r.Context(), jid)
|
||||
if err != nil {
|
||||
fmt.Fprint(w, err)
|
||||
w.WriteHeader(500)
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/xml")
|
||||
w.WriteHeader(200)
|
||||
fmt.Fprint(w, vcard)
|
||||
}
|
89
pkg/opgp/entity/entity.go
Normal file
89
pkg/opgp/entity/entity.go
Normal file
@ -0,0 +1,89 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/mail"
|
||||
|
||||
"github.com/sour-is/crypto/openpgp"
|
||||
"github.com/sour-is/crypto/openpgp/packet"
|
||||
)
|
||||
|
||||
type Key string
|
||||
|
||||
func (k Key) Key() interface{} {
|
||||
return k
|
||||
}
|
||||
|
||||
type Entity struct {
|
||||
Primary *mail.Address
|
||||
SelfSignature *packet.Signature
|
||||
Emails []*mail.Address
|
||||
Fingerprint string
|
||||
Proofs []string
|
||||
ArmorText string
|
||||
entity *openpgp.Entity
|
||||
}
|
||||
|
||||
func (e *Entity) Serialize(f io.Writer) error {
|
||||
return e.entity.Serialize(f)
|
||||
}
|
||||
|
||||
func GetOne(lis openpgp.EntityList) (*Entity, error) {
|
||||
entity := &Entity{}
|
||||
var err error
|
||||
|
||||
for _, e := range lis {
|
||||
if e == nil {
|
||||
continue
|
||||
}
|
||||
if e.PrimaryKey == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
entity.entity = e
|
||||
entity.Fingerprint = fmt.Sprintf("%X", e.PrimaryKey.Fingerprint)
|
||||
|
||||
for name, ident := range e.Identities {
|
||||
// Pick first identity
|
||||
if entity.Primary == nil {
|
||||
entity.Primary, err = mail.ParseAddress(name)
|
||||
if err != nil {
|
||||
return entity, err
|
||||
}
|
||||
}
|
||||
// If one is marked primary use that
|
||||
if ident.SelfSignature != nil && ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature.IsPrimaryId {
|
||||
entity.Primary, err = mail.ParseAddress(name)
|
||||
if err != nil {
|
||||
return entity, err
|
||||
}
|
||||
|
||||
} else {
|
||||
var email *mail.Address
|
||||
if email, err = mail.ParseAddress(name); err != nil {
|
||||
return entity, err
|
||||
}
|
||||
if email.Address != entity.Primary.Address {
|
||||
entity.Emails = append(entity.Emails, email)
|
||||
}
|
||||
}
|
||||
|
||||
// If identity is self signed read notation data.
|
||||
if ident.SelfSignature != nil && ident.SelfSignature.NotationData != nil {
|
||||
entity.SelfSignature = ident.SelfSignature
|
||||
// Get proofs and append to list.
|
||||
if proofs, ok := ident.SelfSignature.NotationData["proof@metacode.biz"]; ok {
|
||||
entity.Proofs = append(entity.Proofs, proofs...)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if entity.Primary == nil {
|
||||
entity.Primary, _ = mail.ParseAddress("nobody@nodomain.xyz")
|
||||
}
|
||||
|
||||
return entity, err
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package keyproofs
|
||||
package opgp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -13,12 +13,12 @@ import (
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/sour-is/crypto/openpgp"
|
||||
"github.com/sour-is/crypto/openpgp/packet"
|
||||
"github.com/sour-is/keyproofs/pkg/opgp/entity"
|
||||
"github.com/tv42/zbase32"
|
||||
"golang.org/x/crypto/openpgp/armor"
|
||||
)
|
||||
|
||||
func getOpenPGPkey(ctx context.Context, id string) (entity *Entity, err error) {
|
||||
func GetKey(ctx context.Context, id string) (entity *entity.Entity, err error) {
|
||||
if isFingerprint(id) {
|
||||
addr := "https://keys.openpgp.org/vks/v1/by-fingerprint/" + strings.ToUpper(id)
|
||||
return getEntityHTTP(ctx, addr, true)
|
||||
@ -41,7 +41,7 @@ func getOpenPGPkey(ctx context.Context, id string) (entity *Entity, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func getEntityHTTP(ctx context.Context, url string, useArmored bool) (entity *Entity, err error) {
|
||||
func getEntityHTTP(ctx context.Context, url string, useArmored bool) (entity *entity.Entity, err error) {
|
||||
log := log.Ctx(ctx)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
@ -72,90 +72,11 @@ func getEntityHTTP(ctx context.Context, url string, useArmored bool) (entity *En
|
||||
return ReadKey(resp.Body, useArmored)
|
||||
}
|
||||
|
||||
type EntityKey string
|
||||
|
||||
func (k EntityKey) Key() interface{} {
|
||||
return k
|
||||
}
|
||||
|
||||
type Entity struct {
|
||||
Primary *mail.Address
|
||||
SelfSignature *packet.Signature
|
||||
Emails []*mail.Address
|
||||
Fingerprint string
|
||||
Proofs []string
|
||||
ArmorText string
|
||||
entity *openpgp.Entity
|
||||
}
|
||||
|
||||
func (e *Entity) Serialize(f io.Writer) error {
|
||||
return e.entity.Serialize(f)
|
||||
}
|
||||
|
||||
func getEntity(lis openpgp.EntityList) (*Entity, error) {
|
||||
entity := &Entity{}
|
||||
var err error
|
||||
|
||||
for _, e := range lis {
|
||||
if e == nil {
|
||||
continue
|
||||
}
|
||||
if e.PrimaryKey == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
entity.entity = e
|
||||
entity.Fingerprint = fmt.Sprintf("%X", e.PrimaryKey.Fingerprint)
|
||||
|
||||
for name, ident := range e.Identities {
|
||||
// Pick first identity
|
||||
if entity.Primary == nil {
|
||||
entity.Primary, err = mail.ParseAddress(name)
|
||||
if err != nil {
|
||||
return entity, err
|
||||
}
|
||||
}
|
||||
// If one is marked primary use that
|
||||
if ident.SelfSignature != nil && ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature.IsPrimaryId {
|
||||
entity.Primary, err = mail.ParseAddress(name)
|
||||
if err != nil {
|
||||
return entity, err
|
||||
}
|
||||
|
||||
} else {
|
||||
var email *mail.Address
|
||||
if email, err = mail.ParseAddress(name); err != nil {
|
||||
return entity, err
|
||||
}
|
||||
if email.Address != entity.Primary.Address {
|
||||
entity.Emails = append(entity.Emails, email)
|
||||
}
|
||||
}
|
||||
|
||||
// If identity is self signed read notation data.
|
||||
if ident.SelfSignature != nil && ident.SelfSignature.NotationData != nil {
|
||||
entity.SelfSignature = ident.SelfSignature
|
||||
// Get proofs and append to list.
|
||||
if proofs, ok := ident.SelfSignature.NotationData["proof@metacode.biz"]; ok {
|
||||
entity.Proofs = append(entity.Proofs, proofs...)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if entity.Primary == nil {
|
||||
entity.Primary, _ = mail.ParseAddress("nobody@nodomain.xyz")
|
||||
}
|
||||
|
||||
return entity, err
|
||||
}
|
||||
|
||||
func ReadKey(r io.Reader, useArmored bool) (e *Entity, err error) {
|
||||
func ReadKey(r io.Reader, useArmored bool) (e *entity.Entity, err error) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
var w io.Writer = &buf
|
||||
e = &Entity{}
|
||||
e = &entity.Entity{}
|
||||
|
||||
defer func() {
|
||||
if e != nil {
|
||||
@ -187,7 +108,7 @@ func ReadKey(r io.Reader, useArmored bool) (e *Entity, err error) {
|
||||
return e, fmt.Errorf("Read key: %w", err)
|
||||
}
|
||||
|
||||
e, err = getEntity(lis)
|
||||
e, err = entity.GetOne(lis)
|
||||
if err != nil {
|
||||
return e, fmt.Errorf("Parse key: %w", err)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package keyproofs
|
||||
package style
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -11,9 +11,11 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type StyleKey string
|
||||
var pixl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
|
||||
|
||||
func (s StyleKey) Key() interface{} {
|
||||
type Key string
|
||||
|
||||
func (s Key) Key() interface{} {
|
||||
return s
|
||||
}
|
||||
|
||||
@ -25,10 +27,10 @@ type Style struct {
|
||||
Palette []string
|
||||
}
|
||||
|
||||
func getStyle(ctx context.Context, email string) (*Style, error) {
|
||||
func GetStyle(ctx context.Context, email string) (*Style, error) {
|
||||
log := log.Ctx(ctx)
|
||||
|
||||
avatarHost, styleHost, err := styleSRV(ctx, email)
|
||||
avatarHost, styleHost, err := GetSRV(ctx, email)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -41,10 +43,10 @@ func getStyle(ctx context.Context, email string) (*Style, error) {
|
||||
|
||||
style := &Style{}
|
||||
|
||||
style.Palette = getPalette(fmt.Sprintf("#%x", id[:3]))
|
||||
style.Palette = GetPalette(fmt.Sprintf("#%x", id[:3]))
|
||||
style.Avatar = fmt.Sprintf("https://%s/avatar/%x", avatarHost, id)
|
||||
style.Cover = pixl
|
||||
style.Background = "https://lavana.sour.is/bg/52548b3dcb032882675afe1e4bcba0e9"
|
||||
style.Background = pixl
|
||||
|
||||
if styleHost != "" {
|
||||
style.Cover = fmt.Sprintf("https://%s/cover/%x", styleHost, id)
|
||||
@ -54,11 +56,11 @@ func getStyle(ctx context.Context, email string) (*Style, error) {
|
||||
return style, err
|
||||
}
|
||||
|
||||
func styleSRV(ctx context.Context, email string) (avatar string, style string, err error) {
|
||||
func GetSRV(ctx context.Context, email string) (avatar string, style string, err error) {
|
||||
|
||||
// Defaults
|
||||
style = ""
|
||||
avatar = "www.gravatar.com"
|
||||
avatar = "www.libravatar.org"
|
||||
|
||||
parts := strings.SplitN(email, "@", 2)
|
||||
if _, srv, err := net.DefaultResolver.LookupSRV(ctx, "style-sec", "tcp", parts[1]); err == nil {
|
||||
@ -82,7 +84,7 @@ func styleSRV(ctx context.Context, email string) (avatar string, style string, e
|
||||
}
|
||||
|
||||
// getPalette maes a complementary color palette. https://play.golang.org/p/nBXLUocGsU5
|
||||
func getPalette(hex string) []string {
|
||||
func GetPalette(hex string) []string {
|
||||
reference, _ := colorful.Hex(hex)
|
||||
reference = sat(lum(reference, 0, .5), 0, .5)
|
||||
|
18
version.sh
18
version.sh
@ -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
|
Loading…
x
Reference in New Issue
Block a user