feat: update Mattermost proxy configuration and documentation for improved clarity and default behavior
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
# Mattermost proxy mirror configuration.
|
# Mattermost proxy mirror configuration.
|
||||||
# Copy to .env if you want local overrides. Do not commit .env.
|
# Copy to .env if you want local overrides. Do not commit .env.
|
||||||
|
|
||||||
# Restrict capture to the Mattermost host. Use the host only, no scheme.
|
# Optional: restrict capture to the Mattermost host. Use the host only, no scheme.
|
||||||
# Example: mattermost.example.com
|
# If empty, the addon captures /api/v4 traffic from the proxied Mattermost app.
|
||||||
|
# Example: mm.all-win-solutions.app
|
||||||
MATTERMOST_MIRROR_HOST_ALLOW=
|
MATTERMOST_MIRROR_HOST_ALLOW=
|
||||||
|
|
||||||
# Output directory for raw evidence and normalized AI-readable context.
|
# Output directory for raw evidence and normalized AI-readable context.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Mattermost Team Edition 11.4.2 exposes normal `/api/v4` REST and WebSocket traff
|
|||||||
- Start `scripts/mattermost-proxy/run-mirror.sh`
|
- Start `scripts/mattermost-proxy/run-mirror.sh`
|
||||||
- Open `http://mitm.it`
|
- Open `http://mitm.it`
|
||||||
- Install/trust the certificate in Keychain.
|
- Install/trust the certificate in Keychain.
|
||||||
3. Optional: copy `.env.example` to `.env` and set `MATTERMOST_MIRROR_HOST_ALLOW` to the exact Mattermost host.
|
3. Optional: copy `.env.example` to `.env` and set `MATTERMOST_MIRROR_HOST_ALLOW` to the exact Mattermost host, for example `mm.all-win-solutions.app`.
|
||||||
|
|
||||||
## Run day to day
|
## Run day to day
|
||||||
|
|
||||||
@@ -101,3 +101,32 @@ Each line in the normalized JSONL contains:
|
|||||||
- `MATTERMOST_MIRROR_CHANNEL_IDS`: optional comma-separated channel ID allowlist.
|
- `MATTERMOST_MIRROR_CHANNEL_IDS`: optional comma-separated channel ID allowlist.
|
||||||
- `MATTERMOST_MIRROR_WRITE_RAW`: set to `1` to save compact raw REST/WebSocket evidence.
|
- `MATTERMOST_MIRROR_WRITE_RAW`: set to `1` to save compact raw REST/WebSocket evidence.
|
||||||
- `MATTERMOST_APP_PATH`: Mattermost Desktop `.app` bundle path.
|
- `MATTERMOST_APP_PATH`: Mattermost Desktop `.app` bundle path.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### TLS certificate warnings
|
||||||
|
|
||||||
|
Mitmproxy uses a persistent local CA under `~/.mitmproxy`. If the desktop app
|
||||||
|
asks about the certificate after every proxy restart, install and trust that CA
|
||||||
|
in macOS Keychain instead of approving it only in the app prompt:
|
||||||
|
|
||||||
|
1. Start `scripts/mattermost-proxy/run-mirror.sh`.
|
||||||
|
2. Open `http://mitm.it` from a browser on this Mac and download the macOS certificate.
|
||||||
|
3. Add it to Keychain Access and set it to **Always Trust**.
|
||||||
|
4. Restart Mattermost Desktop through `launch-mattermost.sh`.
|
||||||
|
|
||||||
|
Warnings for unrelated hosts such as `releases.mattermost.com` or OpenGraph
|
||||||
|
preview hosts are not required for message capture. The mirror only writes
|
||||||
|
normalized messages from Mattermost `/api/v4` REST/WebSocket payloads.
|
||||||
|
|
||||||
|
### Proxy logs show traffic but no `latest.md`
|
||||||
|
|
||||||
|
The mirror writes files only after it sees a post payload. Startup calls such as
|
||||||
|
`/api/v4/teams`, `/api/v4/users`, `/api/v4/files`, or WebSocket ping/ack events
|
||||||
|
do not create message files. Open a channel, open a thread, scroll slightly in
|
||||||
|
history, or wait for/send a new message. Then check:
|
||||||
|
|
||||||
|
```text
|
||||||
|
ai/inbox/mattermost-mirror/latest.md
|
||||||
|
ai/inbox/mattermost-mirror/messages/YYYY/MM/YYYY-MM-DD.jsonl
|
||||||
|
```
|
||||||
|
|||||||
@@ -147,7 +147,11 @@ class MattermostMirror:
|
|||||||
host = host.lower()
|
host = host.lower()
|
||||||
if self.host_allow:
|
if self.host_allow:
|
||||||
return host == self.host_allow or host.endswith(f".{self.host_allow}")
|
return host == self.host_allow or host.endswith(f".{self.host_allow}")
|
||||||
return "mattermost" in host
|
# The launched Mattermost Desktop app is already scoped to this proxy.
|
||||||
|
# Some company hosts do not include "mattermost" in the hostname
|
||||||
|
# (for example, mm.example.com), so default to allowing the proxied
|
||||||
|
# app's /api/v4 traffic when no explicit host allowlist is configured.
|
||||||
|
return True
|
||||||
|
|
||||||
def _is_allowed_channel(self, channel_id: str | None) -> bool:
|
def _is_allowed_channel(self, channel_id: str | None) -> bool:
|
||||||
if not self.channel_allow:
|
if not self.channel_allow:
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ mkdir -p "$MATTERMOST_MIRROR_DIR"
|
|||||||
echo "Mattermost proxy mirror output: $MATTERMOST_MIRROR_DIR"
|
echo "Mattermost proxy mirror output: $MATTERMOST_MIRROR_DIR"
|
||||||
echo "Listening on ${MATTERMOST_MIRROR_LISTEN_HOST}:${MATTERMOST_MIRROR_LISTEN_PORT}"
|
echo "Listening on ${MATTERMOST_MIRROR_LISTEN_HOST}:${MATTERMOST_MIRROR_LISTEN_PORT}"
|
||||||
echo "Launch Mattermost Desktop with: scripts/mattermost-proxy/launch-mattermost.sh"
|
echo "Launch Mattermost Desktop with: scripts/mattermost-proxy/launch-mattermost.sh"
|
||||||
|
if [ -z "${MATTERMOST_MIRROR_HOST_ALLOW:-}" ]; then
|
||||||
|
echo "MATTERMOST_MIRROR_HOST_ALLOW is not set; capturing /api/v4 traffic from the proxied app."
|
||||||
|
fi
|
||||||
|
|
||||||
exec mitmdump \
|
exec mitmdump \
|
||||||
--listen-host "$MATTERMOST_MIRROR_LISTEN_HOST" \
|
--listen-host "$MATTERMOST_MIRROR_LISTEN_HOST" \
|
||||||
|
|||||||
Reference in New Issue
Block a user