From 1ee020b0f60e76cb74f4449f9a3a12d067c86bc0 Mon Sep 17 00:00:00 2001 From: Mark Mennell Date: Sun, 9 Aug 2026 20:57:46 +1000 Subject: [PATCH] Default FMSG_CHALLENGE_MODE to HAS_NOT_PARTICIPATED Challenge new threads and unreplied-to senders, but skip the automatic challenge once a message in the thread is from this host's domain. --- README.md | 2 +- cmd/fmsgd/host.go | 12 ++++++------ cmd/fmsgd/host_test.go | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 998f99b..9802aae 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Tested with Go 1.25 on Linux and Windows, AMD64 and ARM | FMSG_MAX_CONCURRENT_SEND | 1024 | Maximum number of concurrent outbound message deliveries. | | FMSG_SKIP_DOMAIN_IP_CHECK | false | Set to "true" to skip verifying this host's external IP is in the fmsg DNS authorised IP set on startup. | | FMSG_SKIP_AUTHORISED_IPS | false | Set to "true" to skip verifying remote hosts IP is in the fmsg DNS authorised IP set during message exchange. WARNING setting this true effectively disables sender verification. | -| FMSG_CHALLENGE_MODE | ALWAYS | When to issue an automatic CHALLENGE to the sending host. `ALWAYS` (default): always challenge. `HAS_NOT_PARTICIPATED`: challenge only when the message has no pid, or no message in the thread is from this host's domain. `NEVER`: never challenge. | +| FMSG_CHALLENGE_MODE | HAS_NOT_PARTICIPATED | When to issue an automatic CHALLENGE to the sending host. `HAS_NOT_PARTICIPATED` (default): challenge only when the message has no pid, or no message in the thread is from this host's domain. `ALWAYS`: always challenge. `NEVER`: never challenge. | diff --git a/cmd/fmsgd/host.go b/cmd/fmsgd/host.go index 483c0d4..ef334bb 100644 --- a/cmd/fmsgd/host.go +++ b/cmd/fmsgd/host.go @@ -126,7 +126,7 @@ var MaxMessageSize = uint32(1024 * 10) var MaxExpandedSize = uint32(1024 * 10) var SkipAuthorisedIPs = false var TLSInsecureSkipVerify = false -var ChallengeMode = ChallengeModeAlways +var ChallengeMode = ChallengeModeHasNotParticipated var DataDir = "got on startup" var Domain = "got on startup" var IDURI = "got on startup" @@ -165,14 +165,14 @@ func buildClientTLSConfig(serverName string) *tls.Config { } } -// parseChallengeMode normalises FMSG_CHALLENGE_MODE. Empty defaults to ALWAYS. -// HAVE_NOT_PARTICIPATED is accepted as an alias of HAS_NOT_PARTICIPATED. +// parseChallengeMode normalises FMSG_CHALLENGE_MODE. Empty defaults to +// HAS_NOT_PARTICIPATED. HAVE_NOT_PARTICIPATED is accepted as an alias. func parseChallengeMode(s string) (string, error) { switch strings.ToUpper(strings.TrimSpace(s)) { - case "", ChallengeModeAlways: - return ChallengeModeAlways, nil - case ChallengeModeHasNotParticipated, "HAVE_NOT_PARTICIPATED": + case "", ChallengeModeHasNotParticipated, "HAVE_NOT_PARTICIPATED": return ChallengeModeHasNotParticipated, nil + case ChallengeModeAlways: + return ChallengeModeAlways, nil case ChallengeModeNever: return ChallengeModeNever, nil default: diff --git a/cmd/fmsgd/host_test.go b/cmd/fmsgd/host_test.go index a7975b1..c38db03 100644 --- a/cmd/fmsgd/host_test.go +++ b/cmd/fmsgd/host_test.go @@ -518,13 +518,14 @@ func TestParseChallengeMode(t *testing.T) { want string wantErr bool }{ - {"", ChallengeModeAlways, false}, + {"", ChallengeModeHasNotParticipated, false}, {"ALWAYS", ChallengeModeAlways, false}, {"always", ChallengeModeAlways, false}, {" Always ", ChallengeModeAlways, false}, {"HAS_NOT_PARTICIPATED", ChallengeModeHasNotParticipated, false}, {"has_not_participated", ChallengeModeHasNotParticipated, false}, {"HAVE_NOT_PARTICIPATED", ChallengeModeHasNotParticipated, false}, + {" Has_Not_Participated ", ChallengeModeHasNotParticipated, false}, {"NEVER", ChallengeModeNever, false}, {"never", ChallengeModeNever, false}, {"SOMETIMES", "", true},