mirror of
https://github.com/mjl-/mox.git
synced 2025-04-15 20:15:28 +03:00
update to go1.23 and replace golang.org/x/exp/maps with stdlib maps
This commit is contained in:
parent
7a87522be0
commit
027e5754a0
21 changed files with 39 additions and 215 deletions
|
@ -99,7 +99,7 @@ for other platforms.
|
|||
# Compiling
|
||||
|
||||
You can easily (cross) compile mox yourself. You need a recent Go toolchain
|
||||
installed. Run `go version`, it must be >= 1.22. Download the latest version
|
||||
installed. Run `go version`, it must be >= 1.23. Download the latest version
|
||||
from https://go.dev/dl/ or see https://go.dev/doc/manage-install.
|
||||
|
||||
To download the source code of the latest release, and compile it to binary "mox":
|
||||
|
|
|
@ -12,14 +12,13 @@ import (
|
|||
"fmt"
|
||||
"io/fs"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"github.com/mjl-/mox/config"
|
||||
"github.com/mjl-/mox/dns"
|
||||
"github.com/mjl-/mox/junk"
|
||||
|
|
|
@ -2,14 +2,12 @@ package admin
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
"github.com/mjl-/mox/config"
|
||||
"github.com/mjl-/mox/dns"
|
||||
"github.com/mjl-/mox/mox-"
|
||||
"slices"
|
||||
)
|
||||
|
||||
type TLSMode uint8
|
||||
|
@ -92,8 +90,7 @@ func ClientConfigDomain(d dns.Domain) (rconfig ClientConfig, rerr error) {
|
|||
}
|
||||
}
|
||||
// Go through the other listeners in consistent order.
|
||||
names := maps.Keys(mox.Conf.Static.Listeners)
|
||||
sort.Strings(names)
|
||||
names := slices.Sorted(maps.Keys(mox.Conf.Static.Listeners))
|
||||
for _, name := range names {
|
||||
if gather(mox.Conf.Static.Listeners[name]) {
|
||||
return
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"mime"
|
||||
"mime/multipart"
|
||||
"net/textproto"
|
||||
|
@ -17,13 +18,10 @@ import (
|
|||
"os"
|
||||
"runtime/debug"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
|
||||
|
@ -689,9 +687,7 @@ func sendReportDomain(ctx context.Context, log mlog.Log, resolver dns.Resolver,
|
|||
report.PolicyPublished = last.PolicyPublished
|
||||
|
||||
// Process records in-order for testable results.
|
||||
recstrs := maps.Keys(counts)
|
||||
sort.Strings(recstrs)
|
||||
for _, recstr := range recstrs {
|
||||
for _, recstr := range slices.Sorted(maps.Keys(counts)) {
|
||||
rc := counts[recstr]
|
||||
rc.ReportRecord.Row.Count = rc.count
|
||||
report.Records = append(report.Records, rc.ReportRecord)
|
||||
|
|
3
go.mod
3
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/mjl-/mox
|
||||
|
||||
go 1.22.0
|
||||
go 1.23.0
|
||||
|
||||
require (
|
||||
github.com/mjl-/adns v0.0.0-20250321173553-ab04b05bdfea
|
||||
|
@ -16,7 +16,6 @@ require (
|
|||
github.com/russross/blackfriday/v2 v2.1.0
|
||||
go.etcd.io/bbolt v1.3.11
|
||||
golang.org/x/crypto v0.32.0
|
||||
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f
|
||||
golang.org/x/net v0.34.0
|
||||
golang.org/x/sys v0.29.0
|
||||
golang.org/x/text v0.21.0
|
||||
|
|
2
go.sum
2
go.sum
|
@ -77,8 +77,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
|||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY=
|
||||
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
|
||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
|
||||
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
|
|
|
@ -6,12 +6,10 @@ import (
|
|||
"crypto/sha256"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"github.com/mjl-/mox/admin"
|
||||
"github.com/mjl-/mox/smtp"
|
||||
)
|
||||
|
@ -39,8 +37,7 @@ func (m dict) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
|||
if err := e.EncodeToken(xml.StartElement{Name: xml.Name{Local: "dict"}}); err != nil {
|
||||
return err
|
||||
}
|
||||
l := maps.Keys(m)
|
||||
sort.Strings(l)
|
||||
l := slices.Sorted(maps.Keys(m))
|
||||
for _, k := range l {
|
||||
tokens := []xml.Token{
|
||||
xml.StartElement{Name: xml.Name{Local: "key"}},
|
||||
|
|
10
http/web.go
10
http/web.go
|
@ -11,6 +11,7 @@ import (
|
|||
"io"
|
||||
golog "log"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -23,7 +24,6 @@ import (
|
|||
_ "embed"
|
||||
_ "net/http/pprof"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
"golang.org/x/net/http2"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
@ -545,14 +545,12 @@ func redirectToTrailingSlash(srv *serve, hostMatch func(dns.IPDomain) bool, name
|
|||
func Listen() {
|
||||
// Initialize listeners in deterministic order for the same potential error
|
||||
// messages.
|
||||
names := maps.Keys(mox.Conf.Static.Listeners)
|
||||
sort.Strings(names)
|
||||
names := slices.Sorted(maps.Keys(mox.Conf.Static.Listeners))
|
||||
for _, name := range names {
|
||||
l := mox.Conf.Static.Listeners[name]
|
||||
portServe := portServes(name, l)
|
||||
|
||||
ports := maps.Keys(portServe)
|
||||
sort.Ints(ports)
|
||||
ports := slices.Sorted(maps.Keys(portServe))
|
||||
for _, port := range ports {
|
||||
srv := portServe[port]
|
||||
for _, ip := range l.IPs {
|
||||
|
@ -886,7 +884,7 @@ func portServes(name string, l config.Listener) map[int]*serve {
|
|||
}
|
||||
|
||||
if s := portServe[443]; s != nil && s.TLSConfig != nil && len(s.NextProto) > 0 {
|
||||
s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, maps.Keys(s.NextProto)...)
|
||||
s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, slices.Collect(maps.Keys(s.NextProto))...)
|
||||
}
|
||||
|
||||
for _, srv := range portServe {
|
||||
|
|
|
@ -8,12 +8,11 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"net/textproto"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"github.com/mjl-/bstore"
|
||||
|
||||
"github.com/mjl-/mox/message"
|
||||
|
@ -230,7 +229,7 @@ func (c *conn) cmdxFetch(isUID bool, tag, cmdstr string, p *parser) {
|
|||
checkVanished(store.UID(num))
|
||||
}
|
||||
}
|
||||
vanishedUIDs = append(vanishedUIDs, maps.Keys(more)...)
|
||||
vanishedUIDs = slices.AppendSeq(vanishedUIDs, maps.Keys(more))
|
||||
})
|
||||
// We are continuing without a lock, working off our snapshot of uids to process.
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ import (
|
|||
"hash"
|
||||
"io"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"math"
|
||||
"net"
|
||||
"os"
|
||||
|
@ -58,7 +59,6 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
"golang.org/x/text/unicode/norm"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
@ -363,8 +363,7 @@ type msgseq uint32
|
|||
|
||||
// Listen initializes all imap listeners for the configuration, and stores them for Serve to start them.
|
||||
func Listen() {
|
||||
names := maps.Keys(mox.Conf.Static.Listeners)
|
||||
sort.Strings(names)
|
||||
names := slices.Sorted(maps.Keys(mox.Conf.Static.Listeners))
|
||||
for _, name := range names {
|
||||
listener := mox.Conf.Static.Listeners[name]
|
||||
|
||||
|
@ -2764,8 +2763,7 @@ func (c *conn) cmdSelectExamine(isselect bool, tag, cmd string, p *parser) {
|
|||
|
||||
// Now that we have all vanished UIDs, send them over compactly.
|
||||
if len(vanishedUIDs) > 0 {
|
||||
l := maps.Keys(vanishedUIDs)
|
||||
slices.Sort(l)
|
||||
l := slices.Sorted(maps.Keys(vanishedUIDs))
|
||||
// ../rfc/7162:1985
|
||||
for _, s := range compactUIDSet(l).Strings(4*1024 - 32) {
|
||||
c.bwritelinef("* VANISHED (EARLIER) %s", s)
|
||||
|
@ -4067,7 +4065,7 @@ func (c *conn) cmdxCopy(isUID bool, tag, cmd string, p *parser) {
|
|||
mbDst.Add(m.MailboxCounts())
|
||||
}
|
||||
|
||||
mbDst.Keywords, _ = store.MergeKeywords(mbDst.Keywords, maps.Keys(mbKeywords))
|
||||
mbDst.Keywords, _ = store.MergeKeywords(mbDst.Keywords, slices.Sorted(maps.Keys(mbKeywords)))
|
||||
|
||||
err = tx.Update(&mbDst)
|
||||
xcheckf(err, "updating destination mailbox for uids, keywords and counts")
|
||||
|
|
|
@ -17,8 +17,6 @@ import (
|
|||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
var destdir string
|
||||
|
@ -69,8 +67,6 @@ func main() {
|
|||
for _, files := range srcdirs {
|
||||
sort.Strings(files)
|
||||
}
|
||||
dirs := maps.Keys(srcdirs)
|
||||
sort.Strings(dirs)
|
||||
var codeBuf bytes.Buffer
|
||||
err := codeTemplate.Execute(&codeBuf, map[string]any{
|
||||
"Dirs": srcdirs,
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"hash"
|
||||
"io"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"math"
|
||||
"net"
|
||||
"net/textproto"
|
||||
|
@ -31,7 +32,6 @@ import (
|
|||
"time"
|
||||
"unicode"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
"golang.org/x/text/unicode/norm"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
@ -202,8 +202,7 @@ func durationDefault(delay *time.Duration, def time.Duration) time.Duration {
|
|||
// Listen initializes network listeners for incoming SMTP connection.
|
||||
// The listeners are stored for a later call to Serve.
|
||||
func Listen() {
|
||||
names := maps.Keys(mox.Conf.Static.Listeners)
|
||||
sort.Strings(names)
|
||||
names := slices.Sorted(maps.Keys(mox.Conf.Static.Listeners))
|
||||
for _, name := range names {
|
||||
listener := mox.Conf.Static.Listeners[name]
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"github.com/mjl-/mox/mlog"
|
||||
)
|
||||
|
||||
|
@ -182,7 +182,7 @@ func (mr *MboxReader) Next() (*Message, *os.File, string, error) {
|
|||
return nil, nil, mr.Position(), fmt.Errorf("flush: %v", err)
|
||||
}
|
||||
|
||||
m := &Message{Flags: flags, Keywords: maps.Keys(keywords), Size: size}
|
||||
m := &Message{Flags: flags, Keywords: slices.Sorted(maps.Keys(keywords)), Size: size}
|
||||
|
||||
if t := strings.SplitN(fromLine, " ", 3); len(t) == 3 {
|
||||
layouts := []string{time.ANSIC, time.UnixDate, time.RubyDate}
|
||||
|
@ -357,7 +357,7 @@ func (mr *MaildirReader) Next() (*Message, *os.File, string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
m := &Message{Received: received, Flags: flags, Keywords: maps.Keys(keywords), Size: size}
|
||||
m := &Message{Received: received, Flags: flags, Keywords: slices.Sorted(maps.Keys(keywords)), Size: size}
|
||||
|
||||
// Prevent cleanup by defer.
|
||||
mf := f
|
||||
|
|
27
vendor/golang.org/x/exp/LICENSE
generated
vendored
27
vendor/golang.org/x/exp/LICENSE
generated
vendored
|
@ -1,27 +0,0 @@
|
|||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
22
vendor/golang.org/x/exp/PATENTS
generated
vendored
22
vendor/golang.org/x/exp/PATENTS
generated
vendored
|
@ -1,22 +0,0 @@
|
|||
Additional IP Rights Grant (Patents)
|
||||
|
||||
"This implementation" means the copyrightable works distributed by
|
||||
Google as part of the Go project.
|
||||
|
||||
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable (except as stated in this section)
|
||||
patent license to make, have made, use, offer to sell, sell, import,
|
||||
transfer and otherwise run, modify and propagate the contents of this
|
||||
implementation of Go, where such license applies only to those patent
|
||||
claims, both currently owned or controlled by Google and acquired in
|
||||
the future, licensable by Google that are necessarily infringed by this
|
||||
implementation of Go. This grant does not include claims that would be
|
||||
infringed only as a consequence of further modification of this
|
||||
implementation. If you or your agent or exclusive licensee institute or
|
||||
order or agree to the institution of patent litigation against any
|
||||
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||
that this implementation of Go or any code incorporated within this
|
||||
implementation of Go constitutes direct or contributory patent
|
||||
infringement, or inducement of patent infringement, then any patent
|
||||
rights granted to you under this License for this implementation of Go
|
||||
shall terminate as of the date such litigation is filed.
|
94
vendor/golang.org/x/exp/maps/maps.go
generated
vendored
94
vendor/golang.org/x/exp/maps/maps.go
generated
vendored
|
@ -1,94 +0,0 @@
|
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package maps defines various functions useful with maps of any type.
|
||||
package maps
|
||||
|
||||
// Keys returns the keys of the map m.
|
||||
// The keys will be in an indeterminate order.
|
||||
func Keys[M ~map[K]V, K comparable, V any](m M) []K {
|
||||
r := make([]K, 0, len(m))
|
||||
for k := range m {
|
||||
r = append(r, k)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// Values returns the values of the map m.
|
||||
// The values will be in an indeterminate order.
|
||||
func Values[M ~map[K]V, K comparable, V any](m M) []V {
|
||||
r := make([]V, 0, len(m))
|
||||
for _, v := range m {
|
||||
r = append(r, v)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// Equal reports whether two maps contain the same key/value pairs.
|
||||
// Values are compared using ==.
|
||||
func Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool {
|
||||
if len(m1) != len(m2) {
|
||||
return false
|
||||
}
|
||||
for k, v1 := range m1 {
|
||||
if v2, ok := m2[k]; !ok || v1 != v2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// EqualFunc is like Equal, but compares values using eq.
|
||||
// Keys are still compared with ==.
|
||||
func EqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, eq func(V1, V2) bool) bool {
|
||||
if len(m1) != len(m2) {
|
||||
return false
|
||||
}
|
||||
for k, v1 := range m1 {
|
||||
if v2, ok := m2[k]; !ok || !eq(v1, v2) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Clear removes all entries from m, leaving it empty.
|
||||
func Clear[M ~map[K]V, K comparable, V any](m M) {
|
||||
for k := range m {
|
||||
delete(m, k)
|
||||
}
|
||||
}
|
||||
|
||||
// Clone returns a copy of m. This is a shallow clone:
|
||||
// the new keys and values are set using ordinary assignment.
|
||||
func Clone[M ~map[K]V, K comparable, V any](m M) M {
|
||||
// Preserve nil in case it matters.
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
r := make(M, len(m))
|
||||
for k, v := range m {
|
||||
r[k] = v
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// Copy copies all key/value pairs in src adding them to dst.
|
||||
// When a key in src is already present in dst,
|
||||
// the value in dst will be overwritten by the value associated
|
||||
// with the key in src.
|
||||
func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
|
||||
for k, v := range src {
|
||||
dst[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteFunc deletes any key/value pairs from m for which del returns true.
|
||||
func DeleteFunc[M ~map[K]V, K comparable, V any](m M, del func(K, V) bool) {
|
||||
for k, v := range m {
|
||||
if del(k, v) {
|
||||
delete(m, k)
|
||||
}
|
||||
}
|
||||
}
|
3
vendor/modules.txt
vendored
3
vendor/modules.txt
vendored
|
@ -74,9 +74,6 @@ golang.org/x/crypto/bcrypt
|
|||
golang.org/x/crypto/blake2b
|
||||
golang.org/x/crypto/blowfish
|
||||
golang.org/x/crypto/pbkdf2
|
||||
# golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f
|
||||
## explicit; go 1.20
|
||||
golang.org/x/exp/maps
|
||||
# golang.org/x/mod v0.22.0
|
||||
## explicit; go 1.22.0
|
||||
golang.org/x/mod/internal/lazyregexp
|
||||
|
|
|
@ -13,16 +13,15 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"os"
|
||||
"path"
|
||||
"runtime/debug"
|
||||
"sort"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"golang.org/x/text/unicode/norm"
|
||||
|
||||
"github.com/mjl-/bstore"
|
||||
|
@ -669,7 +668,7 @@ func importMessages(ctx context.Context, log mlog.Log, token string, acc *store.
|
|||
m := store.Message{
|
||||
Received: received,
|
||||
Flags: flags,
|
||||
Keywords: maps.Keys(keywords),
|
||||
Keywords: slices.Sorted(maps.Keys(keywords)),
|
||||
Size: size,
|
||||
}
|
||||
xdeliver(mb, &m, f, filename)
|
||||
|
@ -755,8 +754,7 @@ func importMessages(ctx context.Context, log mlog.Log, token string, acc *store.
|
|||
|
||||
oflags := m.Flags
|
||||
m.Flags = m.Flags.Set(flags, flags)
|
||||
m.Keywords = maps.Keys(keywords)
|
||||
sort.Strings(m.Keywords)
|
||||
m.Keywords = slices.Sorted(maps.Keys(keywords))
|
||||
|
||||
mb.Add(m.MailboxCounts())
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -35,7 +36,6 @@ import (
|
|||
|
||||
_ "embed"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
"golang.org/x/text/unicode/norm"
|
||||
|
||||
"github.com/mjl-/adns"
|
||||
|
@ -895,7 +895,7 @@ EOF
|
|||
tlsal, tlsaResult, err := resolver.LookupTLSA(ctx, 25, "tcp", mx.Host+".")
|
||||
if dns.IsNotFound(err) {
|
||||
if len(expect) > 0 {
|
||||
addf(&r.DANE.Errors, "No DANE records for MX host %s, expected: %s.", mx.Host, strings.Join(maps.Keys(expect), "; "))
|
||||
addf(&r.DANE.Errors, "No DANE records for MX host %s, expected: %s.", mx.Host, strings.Join(slices.Collect(maps.Keys(expect)), "; "))
|
||||
}
|
||||
continue
|
||||
} else if err != nil {
|
||||
|
@ -915,13 +915,11 @@ EOF
|
|||
}
|
||||
}
|
||||
if len(expect) > 0 {
|
||||
l := maps.Keys(expect)
|
||||
sort.Strings(l)
|
||||
l := slices.Sorted(maps.Keys(expect))
|
||||
addf(&r.DANE.Errors, "Missing DANE records of type TLSA for MX host _25._tcp.%s: %s", mx.Host, strings.Join(l, "; "))
|
||||
}
|
||||
if len(extra) > 0 {
|
||||
l := maps.Keys(extra)
|
||||
sort.Strings(l)
|
||||
l := slices.Sorted(maps.Keys(extra))
|
||||
addf(&r.DANE.Errors, "Unexpected DANE records of type TLSA for MX host _25._tcp.%s: %s", mx.Host, strings.Join(l, "; "))
|
||||
}
|
||||
}
|
||||
|
@ -932,8 +930,7 @@ EOF
|
|||
if pubDom.ASCII == "" {
|
||||
pubDom = mox.Conf.Static.HostnameDomain
|
||||
}
|
||||
records := maps.Keys(daneRecords(public))
|
||||
sort.Strings(records)
|
||||
records := slices.Sorted(maps.Keys(daneRecords(public)))
|
||||
if len(records) > 0 {
|
||||
instr := "Ensure the DNS records below exist. These records are for the whole machine, not per domain, so create them only once. Make sure DNSSEC is enabled, otherwise the records have no effect. The records indicate that a remote mail server trying to deliver email with SMTP (TCP port 25) must verify the TLS certificate with DANE-EE (3), based on the certificate public key (\"SPKI\", 1) that is SHA2-256-hashed (1) to the hexadecimal hash. DANE-EE verification means only the certificate or public key is verified, not whether the certificate is signed by a (centralized) certificate authority (CA), is expired, or matches the host name.\n\n"
|
||||
for _, r := range records {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"mime"
|
||||
"mime/multipart"
|
||||
"net"
|
||||
|
@ -26,8 +27,6 @@ import (
|
|||
|
||||
_ "embed"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"github.com/mjl-/bstore"
|
||||
"github.com/mjl-/sherpa"
|
||||
"github.com/mjl-/sherpadoc"
|
||||
|
@ -1526,7 +1525,7 @@ func (Webmail) ThreadCollapse(ctx context.Context, messageIDs []int64, collapse
|
|||
var updated []store.Message
|
||||
q := bstore.QueryTx[store.Message](tx)
|
||||
q.FilterEqual("Expunged", false)
|
||||
q.FilterEqual("ThreadID", slicesAny(maps.Keys(threadIDs))...)
|
||||
q.FilterEqual("ThreadID", slicesAny(slices.Sorted(maps.Keys(threadIDs)))...)
|
||||
q.FilterNotEqual("ThreadCollapsed", collapse)
|
||||
q.FilterFn(func(tm store.Message) bool {
|
||||
for _, id := range tm.ThreadParentIDs {
|
||||
|
@ -1580,7 +1579,7 @@ func (Webmail) ThreadMute(ctx context.Context, messageIDs []int64, mute bool) {
|
|||
|
||||
q := bstore.QueryTx[store.Message](tx)
|
||||
q.FilterEqual("Expunged", false)
|
||||
q.FilterEqual("ThreadID", slicesAny(maps.Keys(threadIDs))...)
|
||||
q.FilterEqual("ThreadID", slicesAny(slices.Sorted(maps.Keys(threadIDs)))...)
|
||||
q.FilterFn(func(tm store.Message) bool {
|
||||
if tm.ThreadMuted == mute && (!mute || tm.ThreadCollapsed) {
|
||||
return false
|
||||
|
|
|
@ -53,7 +53,7 @@ for other platforms.
|
|||
## Compiling
|
||||
|
||||
You can easily (cross) compile mox yourself. You need a recent Go toolchain
|
||||
installed. Run `go version`, it must be >= 1.22. Download the latest version
|
||||
installed. Run `go version`, it must be >= 1.23. Download the latest version
|
||||
from https://go.dev/dl/ or see https://go.dev/doc/manage-install.
|
||||
|
||||
To download the source code of the latest release, and compile it to binary "mox":
|
||||
|
|
Loading…
Reference in a new issue