mirror of
https://github.com/foxcpp/maddy.git
synced 2025-04-01 20:27:36 +03:00
Fix a few linter warnings + gofmt + goimports
This commit is contained in:
parent
75ac2a6f20
commit
80328b8dee
61 changed files with 132 additions and 68 deletions
|
@ -79,4 +79,4 @@ nav:
|
|||
- internals/specifications.md
|
||||
- internals/unicode.md
|
||||
- internals/quirks.md
|
||||
- internals/sqlite.md
|
||||
- internals/sqlite.md
|
||||
|
|
|
@ -15,7 +15,7 @@ daemon with uniform configuration and minimal maintenance cost.
|
|||
feature-packed implementation you may want to use Dovecot instead. maddy still
|
||||
can handle message delivery business.
|
||||
|
||||
[](https://builds.sr.ht/~emersion/maddy?)
|
||||
[](https://github.com/foxcpp/maddy/actions/workflows/cicd.yml)
|
||||
[](https://github.com/foxcpp/maddy)
|
||||
|
||||
* [Setup tutorial](https://maddy.email/tutorials/setting-up/)
|
||||
|
|
|
@ -20,7 +20,7 @@ package main
|
|||
|
||||
import (
|
||||
_ "github.com/foxcpp/maddy"
|
||||
"github.com/foxcpp/maddy/internal/cli"
|
||||
maddycli "github.com/foxcpp/maddy/internal/cli"
|
||||
_ "github.com/foxcpp/maddy/internal/cli/ctl"
|
||||
)
|
||||
|
||||
|
|
13
cmd/maddy/test.conf
Normal file
13
cmd/maddy/test.conf
Normal file
|
@ -0,0 +1,13 @@
|
|||
state_dir /tmp
|
||||
runtime_dir /tmp
|
||||
|
||||
imap tcp://127.0.0.1:2222 {
|
||||
tls off
|
||||
auth pam
|
||||
storage imapsql {
|
||||
driver sqlite3
|
||||
dsn /tmp/hello.db
|
||||
delivery_map email_localpart
|
||||
auth_normalize precis_casefold
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
//+build !docker
|
||||
//go:build !docker
|
||||
// +build !docker
|
||||
|
||||
package maddy
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build docker
|
||||
//go:build docker
|
||||
// +build docker
|
||||
|
||||
package maddy
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build debugflags
|
||||
//go:build debugflags
|
||||
// +build debugflags
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build !windows,!plan9
|
||||
//go:build !windows && !plan9
|
||||
// +build !windows,!plan9
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build windows plan9
|
||||
//go:build windows || plan9
|
||||
// +build windows plan9
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build cgo,libpam
|
||||
//go:build cgo && libpam
|
||||
// +build cgo,libpam
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build !cgo !libpam
|
||||
//go:build !cgo || !libpam
|
||||
// +build !cgo !libpam
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build !windows
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -119,4 +119,3 @@ func TestRequireMXRecord(t *testing.T) {
|
|||
test("", "", nil, false) // Permit <> for bounces.
|
||||
test("foo@example.org", "example.org", []net.MX{{Host: "."}}, true)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build ignore
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -95,11 +95,15 @@ func Run() {
|
|||
// Actual entry point is registered in maddy.go.
|
||||
|
||||
// Print help when called via maddyctl executable. To be removed
|
||||
// once backward compatbility hack for 'maddy run' is removed too.
|
||||
// once backward compatibility hack for 'maddy run' is removed too.
|
||||
if strings.Contains(os.Args[0], "maddyctl") && len(os.Args) == 1 {
|
||||
app.Run([]string{os.Args[0], "help"})
|
||||
if err := app.Run([]string{os.Args[0], "help"}); err != nil {
|
||||
log.DefaultLogger.Error("app.Run failed", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
app.Run(os.Args)
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
log.DefaultLogger.Error("app.Run failed", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build linux
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build !linux
|
||||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -468,7 +468,8 @@ func mboxesCreate(be module.Storage, ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
if ctx.IsSet("special") {
|
||||
attr := "\\" + strings.Title(ctx.String("special"))
|
||||
attr := "\\" + strings.Title(ctx.String("special")) //nolint:staticcheck
|
||||
// (nolint) strings.Title is perfectly fine there since special mailbox tags will never use Unicode.
|
||||
|
||||
suu, ok := u.(SpecialUseUser)
|
||||
if !ok {
|
||||
|
|
|
@ -199,8 +199,8 @@ func usersCreate(be module.PlainUserDB, ctx *cli.Context) error {
|
|||
}
|
||||
}
|
||||
|
||||
if be, ok := be.(*pass_table.Auth); ok {
|
||||
return be.CreateUserHash(username, pass, ctx.String("hash"), pass_table.HashOpts{
|
||||
if beHash, ok := be.(*pass_table.Auth); ok {
|
||||
return beHash.CreateUserHash(username, pass, ctx.String("hash"), pass_table.HashOpts{
|
||||
BcryptCost: ctx.Int("bcrypt-cost"),
|
||||
})
|
||||
} else if ctx.IsSet("hash") || ctx.IsSet("bcrypt-cost") {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_alidns libdns_all
|
||||
//go:build libdns_alidns || libdns_all
|
||||
// +build libdns_alidns libdns_all
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_cloudflare !libdns_separate
|
||||
//go:build libdns_cloudflare || !libdns_separate
|
||||
// +build libdns_cloudflare !libdns_separate
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_digitalocean !libdns_separate
|
||||
//go:build libdns_digitalocean || !libdns_separate
|
||||
// +build libdns_digitalocean !libdns_separate
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_gandi !libdns_separate
|
||||
//go:build libdns_gandi || !libdns_separate
|
||||
// +build libdns_gandi !libdns_separate
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_googleclouddns libdns_all
|
||||
//go:build libdns_googleclouddns || libdns_all
|
||||
// +build libdns_googleclouddns libdns_all
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_hetzner !libdns_separate
|
||||
//go:build libdns_hetzner || !libdns_separate
|
||||
// +build libdns_hetzner !libdns_separate
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_leaseweb libdns_all
|
||||
//go:build libdns_leaseweb || libdns_all
|
||||
// +build libdns_leaseweb libdns_all
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_metaname libdns_all
|
||||
//go:build libdns_metaname || libdns_all
|
||||
// +build libdns_metaname libdns_all
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build go1.16
|
||||
//go:build go1.16
|
||||
// +build go1.16
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_namedotdom libdns_all
|
||||
//go:build libdns_namedotdom || libdns_all
|
||||
// +build libdns_namedotdom libdns_all
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_route53 libdns_all
|
||||
//go:build libdns_route53 || libdns_all
|
||||
// +build libdns_route53 libdns_all
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build libdns_vultr !libdns_separate
|
||||
//go:build libdns_vultr || !libdns_separate
|
||||
// +build libdns_vultr !libdns_separate
|
||||
|
||||
package libdns
|
||||
|
||||
|
|
|
@ -103,7 +103,6 @@ func testReplaceAddr(t *testing.T, modName string) {
|
|||
test("test@example.com", []string{"1@example.com", "2@example.com", "3@example.com"},
|
||||
map[string][]string{"test@example.com": []string{"1@example.com", "2@example.com", "3@example.com"}})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestReplaceAddr_RewriteSender(t *testing.T) {
|
||||
|
|
|
@ -339,7 +339,6 @@ func (dd *msgpipelineDelivery) AddRcpt(ctx context.Context, to string) error {
|
|||
dd.log.Debugln("per-rcpt modifiers:", to, "=>", newTo)
|
||||
|
||||
for _, to = range newTo {
|
||||
|
||||
wrapErr = func(err error) error {
|
||||
return exterrors.WithFields(err, map[string]interface{}{
|
||||
"effective_rcpt": to,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build cgo,!no_sqlite3
|
||||
//go:build cgo && !no_sqlite3
|
||||
// +build cgo,!no_sqlite3
|
||||
|
||||
package blob
|
||||
|
||||
|
@ -40,8 +41,8 @@ func TestStore(t *testing.T, newStore func() module.BlobStore, cleanStore func(m
|
|||
|
||||
b, err := imapsql.New("sqlite3", ":memory:",
|
||||
imapsql2.ExtBlobStore{Base: store}, imapsql.Opts{
|
||||
PRNG: prng,
|
||||
Log: testutils.Logger(t, "imapsql"),
|
||||
PRNG: prng,
|
||||
Log: testutils.Logger(t, "imapsql"),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build !cgo no_sqlite3
|
||||
//go:build !cgo || no_sqlite3
|
||||
// +build !cgo no_sqlite3
|
||||
|
||||
package blob
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ func createTestDB(tb testing.TB, compAlgo string) *Storage {
|
|||
}
|
||||
|
||||
db, err := imapsql.New(testDB, testDSN, &imapsql.FSStore{Root: testFsstore}, imapsql.Opts{
|
||||
CompressAlgo: compAlgo,
|
||||
CompressAlgo: compAlgo,
|
||||
})
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build !nosqlite3,cgo
|
||||
//go:build !nosqlite3 && cgo
|
||||
// +build !nosqlite3,cgo
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -119,11 +119,11 @@ func (f *File) reloader() {
|
|||
}()
|
||||
|
||||
t := time.NewTicker(reloadInterval)
|
||||
defer t.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-t.C:
|
||||
var latestStamp time.Time
|
||||
info, err := os.Stat(f.file)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
@ -133,10 +133,10 @@ func (f *File) reloader() {
|
|||
f.mLck.Unlock()
|
||||
continue
|
||||
}
|
||||
f.log.Printf("%v", err)
|
||||
f.log.Error("os stat", err)
|
||||
}
|
||||
if info.ModTime().After(latestStamp) {
|
||||
latestStamp = info.ModTime()
|
||||
if info.ModTime().Before(f.mStamp) {
|
||||
continue // reload not necessary
|
||||
}
|
||||
case <-f.forceReload:
|
||||
case <-f.stopReloader:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build !nosqlite3,cgo
|
||||
//go:build !nosqlite3 && cgo
|
||||
// +build !nosqlite3,cgo
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build !nosqlite3,cgo
|
||||
//go:build !nosqlite3 && cgo
|
||||
// +build !nosqlite3,cgo
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build debugflags
|
||||
//go:build debugflags
|
||||
// +build debugflags
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build ignore
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
// Copy that file into target/ subdirectory.
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build debugflags
|
||||
//go:build debugflags
|
||||
// +build debugflags
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build windows plan9
|
||||
//go:build windows || plan9
|
||||
// +build windows plan9
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build linux
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build !linux
|
||||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build cover_main
|
||||
//go:build cover_main
|
||||
// +build cover_main
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//+build integration
|
||||
//+build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
//go:build integration && (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris)
|
||||
// +build integration
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
//
|
||||
// From: https://git.lukeshu.com/go/cmd/gocovcat/
|
||||
//
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
// Copyright 2017 Luke Shumaker <lukeshu@parabola.nu>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration,cgo,!nosqlite3
|
||||
//go:build integration && cgo && !nosqlite3
|
||||
// +build integration,cgo,!nosqlite3
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration,cgo,!nosqlite3
|
||||
//go:build integration && cgo && !nosqlite3
|
||||
// +build integration,cgo,!nosqlite3
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//+build integration
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Maddy Mail Server - Composable all-in-one email server.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue