- is_allowed matches pubkey_prefix only; sender names are never trusted
(channel senders must be known contacts of the companion for the
MeshCore integration to include their pubkey_prefix)
- channel messages on channel index 0 (public) and hashtag channels
('#name') are ignored unconditionally, before the allowlist check
- config flow validates allowlist entries as 6-64 hex characters
(invalid_allowlist error) and UI strings/README updated
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
"""Constants for the MeshCore Agent integration."""
|
|
|
|
DOMAIN = "meshcore_agent"
|
|
MESH_CORE_DOMAIN = "meshcore" # domain of the meshcore-dev/meshcore-ha integration
|
|
|
|
# MeshCore integration (meshcore-dev/meshcore-ha) event and service names.
|
|
EVENT_MESHCORE_MESSAGE = "meshcore_message"
|
|
SERVICE_MESHCORE_SEND_MESSAGE = "send_message"
|
|
SERVICE_MESHCORE_SEND_CHANNEL_MESSAGE = "send_channel_message"
|
|
|
|
# Config entry / options keys.
|
|
CONF_ALLOWLIST = "allowlist" # comma/newline separated pubkey prefixes or names
|
|
CONF_ALLOW_ALL = "allow_all"
|
|
CONF_MAX_REPLY = "max_reply"
|
|
|
|
DEFAULT_ALLOWLIST = ""
|
|
DEFAULT_ALLOW_ALL = False
|
|
DEFAULT_MAX_REPLY = 200
|
|
|
|
# Signal fired after the store changes so the todo entity can refresh.
|
|
SIGNAL_STORE_UPDATED = "meshcore_agent_store_updated_{entry_id}"
|
|
|
|
# Event data keys of meshcore_message used by the adapter.
|
|
ATTR_MESSAGE = "message"
|
|
ATTR_OUTGOING = "outgoing"
|
|
ATTR_MESSAGE_TYPE = "message_type"
|
|
ATTR_SENDER_NAME = "sender_name"
|
|
ATTR_PUBKEY_PREFIX = "pubkey_prefix"
|
|
ATTR_CHANNEL = "channel"
|
|
ATTR_CHANNEL_IDX = "channel_idx"
|
|
ATTR_ENTRY_ID = "entry_id"
|
|
|
|
# Channel 0 is the public channel; hashtag channels ("#name") are the
|
|
# other shared channels. Neither may command the agent.
|
|
PUBLIC_CHANNEL_IDX = 0
|
|
HASHTAG_CHANNEL_PREFIX = "#"
|