Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 218 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,41 @@ packages, or the Node.js/tmux layers built from source in the container
images — those are covered by the per-image SBOMs attached to every tagged
release (see src/docs/releases.md, "Software bill of materials (SBOM)").

-----------------------------------------------------------------------------

Package: blitiri.com.ar/go/spf
Version: v1.6.0
License: MIT
Source: https://blitiri.com.ar/git/r/spf/b/master/t/f=LICENSE.html


Licensed under the MIT licence, which is reproduced below (from
https://opensource.org/licenses/MIT).

-----

Copyright (c) 2016

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



-----------------------------------------------------------------------------

Package: cel.dev/expr
Expand Down Expand Up @@ -803,6 +838,154 @@ SOFTWARE.

-----------------------------------------------------------------------------

Package: github.com/emersion/go-ical
Version: v0.0.0-20261112170022-46c5b53a1723
License: MIT
Source: https://github.com/emersion/go-ical/blob/46c5b53a1723/LICENSE

MIT License

Copyright (c) 2020 Simon Ser

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-----------------------------------------------------------------------------

Package: github.com/emersion/go-message
Version: v0.18.2
License: MIT
Source: https://github.com/emersion/go-message/blob/v0.18.2/LICENSE

MIT License

Copyright (c) 2016 emersion

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-----------------------------------------------------------------------------

Package: github.com/emersion/go-msgauth
Version: v0.7.0
License: MIT
Source: https://github.com/emersion/go-msgauth/blob/v0.7.0/LICENSE

MIT License

Copyright (c) 2017 emersion

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-----------------------------------------------------------------------------

Package: github.com/emersion/go-sasl
Version: v0.0.0-20241020182733-b788ff22d5a6
License: MIT
Source: https://github.com/emersion/go-sasl/blob/b788ff22d5a6/LICENSE

The MIT License (MIT)

Copyright (c) 2016 emersion

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-----------------------------------------------------------------------------

Package: github.com/emersion/go-smtp
Version: v0.26.0
License: MIT
Source: https://github.com/emersion/go-smtp/blob/v0.26.0/LICENSE

The MIT License (MIT)

Copyright (c) 2010 The Go Authors
Copyright (c) 2014 Gleez Technologies
Copyright (c) 2016 emersion
Copyright (c) 2016 Proton Technologies AG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-----------------------------------------------------------------------------

Package: github.com/fsnotify/fsnotify
Version: v1.10.1
License: BSD-3-Clause
Expand Down Expand Up @@ -6301,6 +6484,41 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-----------------------------------------------------------------------------

Package: golang.org/x/time/rate
Version: v0.16.0
License: BSD-3-Clause
Source: https://cs.opensource.google/go/x/time/+/v0.16.0:LICENSE

Copyright 2009 The Go Authors.

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 LLC 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.

-----------------------------------------------------------------------------

Package: google.golang.org/genproto/googleapis/api
Version: v0.0.0-20260928230214-8a89bd6388cc
License: Apache-2.0
Expand Down
1 change: 1 addition & 0 deletions changelog.d/added-18395-hive-mx-receiver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- hive-mx, a receive-only mail receiver for `hive@<hive host>`: it checks SPF, DKIM and DMARC alignment, keeps only calendar invites (with join link, platform, meeting id and passcode, Windows time zones mapped), Markdown, audio and image attachments, or a proof code, and posts them to the hub. It never sends mail.
44 changes: 44 additions & 0 deletions src/cmd/hive-mx/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Command hive-mx is hive's receive-only mail receiver: it accepts mail for
// hive@<hive host>, keeps only calendar invites, mail-in files and proof
// codes, and posts them to the hub that routes them to each hive. It never
// sends mail. Configuration is environment only; see pkg/mailin and
// src/docs/meetings.md ("Inviting Betty by email").
package main

import (
"context"
"fmt"
"io"
"log/slog"
"os"
"os/signal"
"syscall"
_ "time/tzdata" // the static image has no zoneinfo; invites need IANA zones

"github.com/hivecommons/hive/pkg/mailin"
)

// run is replaced in tests.
var run = mailin.Run

func main() { os.Exit(runMain(os.Args[1:], os.Getenv, os.Stderr)) }

func runMain(args []string, getenv func(string) string, stderr io.Writer) int {
if len(args) > 0 && (args[0] == "-version" || args[0] == "--version") {
fmt.Fprintln(stderr, "hive-mx 1")
return 0
}
log := slog.New(slog.NewJSONHandler(stderr, nil))
cfg, err := mailin.ConfigFromEnv(getenv)
if err != nil {
log.Error("hive-mx: bad configuration", "err", err)
return 2
}
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
defer stop()
if err := run(ctx, cfg, log); err != nil {
log.Error("hive-mx: stopped", "err", err)
return 1
}
return 0
}
54 changes: 54 additions & 0 deletions src/cmd/hive-mx/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package main

import (
"bytes"
"context"
"errors"
"log/slog"
"strings"
"testing"

"github.com/hivecommons/hive/pkg/mailin"
)

func TestRunMainVersion(t *testing.T) {
var out bytes.Buffer
if code := runMain([]string{"-version"}, func(string) string { return "" }, &out); code != 0 {
t.Fatalf("exit %d", code)
}
if !strings.Contains(out.String(), "hive-mx") {
t.Fatalf("version output %q", out.String())
}
}

func TestRunMainBadConfig(t *testing.T) {
var out bytes.Buffer
if code := runMain(nil, func(string) string { return "" }, &out); code != 2 {
t.Fatalf("exit %d, want 2", code)
}
if !strings.Contains(out.String(), mailin.EnvHubURL) {
t.Fatalf("log %q does not name the missing setting", out.String())
}
}

func TestRunMainRuns(t *testing.T) {
orig := run
t.Cleanup(func() { run = orig })
env := map[string]string{mailin.EnvHubURL: "https://hub.example"}
getenv := func(k string) string { return env[k] }

var got mailin.Config
run = func(_ context.Context, c mailin.Config, _ *slog.Logger) error { got = c; return nil }
var out bytes.Buffer
if code := runMain(nil, getenv, &out); code != 0 {
t.Fatalf("exit %d", code)
}
if got.HubURL != "https://hub.example" {
t.Fatalf("config not passed: %+v", got)
}

run = func(context.Context, mailin.Config, *slog.Logger) error { return errors.New("boom") }
if code := runMain(nil, getenv, &out); code != 1 {
t.Fatalf("exit %d, want 1", code)
}
}
22 changes: 22 additions & 0 deletions src/docs/env-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,28 @@ Hive as a live meeting participant ([#18284](https://github.com/hivecommons/hive
| `HIVE_MEETINGS_LLM_TIMEOUT_MS` | No | `2500` | Per-call model timeout. |
| `HIVE_MEETINGS_LLM_MAX_IN_FLIGHT` | No | `4` | Concurrent model calls across all meetings. |

### Mail receiver (`hive-mx`)

`hive-mx` is the cluster's receive-only mail receiver ([#18395](https://github.com/hivecommons/hive/issues/18395)): it accepts mail only for `hive@<hive host>`, keeps calendar invites, mail-in files and proof codes, and posts them to the hub. It never sends mail, offers no AUTH and relays nothing. It reads only these variables; see [meetings.md](meetings.md#inviting-betty-by-email).

| Variable | Required | Default | Purpose |
|---|---:|---|---|
| `HIVE_MX_HUB_URL` | Yes | none | Hub base URL hive-mx fetches the host list from (`GET /api/mail/hosts`) and posts deliveries to (`POST /api/mail/inbound`). |
| `HIVE_MX_HUB_TOKEN_FILE` | No | `/var/run/secrets/hive-mx/token` | File holding the hub bearer token (a mounted Secret). Read on every call, so a rotated token needs no restart. |
| `HIVE_MX_LISTEN` | No | `:2525` | SMTP listen address. The Service maps port 25 to it, so the container runs as non-root. |
| `HIVE_MX_HEALTH_LISTEN` | No | `:8080` | `/healthz` and `/readyz` (ready once the first host list loaded). |
| `HIVE_MX_DOMAIN` | No | `mx.hive.hivecommons.dev` | Name hive-mx greets with. |
| `HIVE_MX_HOSTS_REFRESH_S` | No | `60` | Seconds between host list refreshes. A failed refresh keeps the last list. |
| `HIVE_MX_MAX_MESSAGE_BYTES` | No | `2097152` | SMTP SIZE limit (2 MB). |
| `HIVE_MX_MAX_RECIPIENTS` | No | `5` | Recipients per message. |
| `HIVE_MX_MAX_CONNECTIONS` | No | `100` | Concurrent SMTP connections. |
| `HIVE_MX_MAX_FILE_BYTES` | No | `2097152` | Largest decoded mail-in attachment. |
| `HIVE_MX_MAX_FILES` | No | `10` | Mail-in attachments kept per message. |
| `HIVE_MX_IP_MESSAGES_PER_HOUR` | No | `60` | Messages per remote IP per hour (burst of a quarter of it). |
| `HIVE_MX_DOMAIN_MESSAGES_PER_HOUR` | No | `120` | Messages per sender (MAIL FROM) organizational domain per hour. |
| `HIVE_MX_TLS_CERT` | No | none | PEM certificate file; with `HIVE_MX_TLS_KEY` it turns on STARTTLS. Re-read when the file changes. Without it hive-mx accepts plain SMTP only. |
| `HIVE_MX_TLS_KEY` | No | none | PEM key for `HIVE_MX_TLS_CERT`. |

## Backend launch controls

| Variable | Required | Default | Purpose |
Expand Down
14 changes: 14 additions & 0 deletions src/docs/meetings.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ While hive is in at least one meeting (joining, in the lobby or live), the top b

The schedule API is `/api/meetings/schedule` ([API reference](api-reference/knowledge.md)).

## Inviting Betty by email

Invite Betty by adding `hive@<your hive's dashboard host>` (for example `hive@acme.hive.hivecommons.dev`) to a calendar invite. Mail for every hive on a cluster reaches one receive-only receiver, `hive-mx` (`src/cmd/hive-mx`), through a wildcard MX record. No spoke opens port 25.

What `hive-mx` does with a message:

- **Recipients:** it accepts `RCPT TO` only for `hive@<host>` where the host is a hive the hub knows (subdomain, vanity or dashboard host; the list is refreshed from the hub every 60 seconds). Everything else is refused at `RCPT`, so it is never an open relay. At most 5 recipients and 2 MB per message, rate limits per sender IP and per sender domain, no AUTH, and it never sends mail. STARTTLS is offered when a certificate is mounted (`HIVE_MX_TLS_CERT`, `HIVE_MX_TLS_KEY`); without one it accepts plain SMTP, which is what most senders fall back to.
- **Sender authentication:** after DATA it checks SPF, DKIM and DMARC and records whether SPF or DKIM passed for a domain aligned with the `From` address (`adkim`/`aspf` honoured). Only an aligned sender can ever be trusted by a hive; the receiver itself decides nothing.
- **Calendar invites:** only `text/calendar` and `application/ics` parts are read. It keeps UID, SEQUENCE, METHOD (REQUEST or CANCEL), RECURRENCE-ID, the summary (200 characters), organizer and attendees, start and end converted to UTC (Outlook's Windows time zone names such as "Eastern Standard Time" are mapped to IANA zones), RRULE and EXDATE, and the join details: the link from `X-GOOGLE-CONFERENCE`, `X-MICROSOFT-SKYPETEAMSMEETINGURL`, `LOCATION` or a link to `meet.google.com`, `teams.microsoft.com`, `teams.live.com` or `*.zoom.us` found in the description, the platform, and the meeting id and passcode where the platform uses one (Zoom `pwd`, the Teams "Meeting ID" and "Passcode" lines). Nothing else from the description is kept.
- **Mail-in files:** a message with no invite may carry Markdown (`.md`), audio (`.m4a`, `.mp3`, `.wav`, `.ogg`, `.webm`) and image (`.png`, `.jpg`, `.gif`, `.webp`) attachments. The type is decided by the file's content, not its name, and must agree with the extension; at most 10 files and 2 MB in all. The subject becomes the title. Nothing in the message is executed or followed.
- **Proof mails:** a message whose subject carries a proof code (`hive-proof-` and 12 letters or digits) is reported as a proof of the sender address.

The result goes to the hub as JSON with a bearer token from a mounted Secret. If the hub cannot take it, the sender's mail server is told to retry later.

## Setup

### Hosted hives
Expand Down
Loading
Loading