summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/ENTERTAIN.md21
-rw-r--r--docs/MASTER-GUIDE.md3
-rw-r--r--include/hybbx/entertain_config.h34
-rw-r--r--include/hybbx/networks.h2
-rw-r--r--plugins/entertain/entertain.c10
-rw-r--r--share/commands.yaml5
-rw-r--r--share/hybbx-main.ini.example6
-rw-r--r--share/hybbx-standalone.ini.example6
-rw-r--r--share/hybbxd-main.ini.example6
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/core/entertain_config.c65
-rw-r--r--src/core/instance.c18
-rw-r--r--src/core/networks.c15
-rw-r--r--src/core/service.c3
14 files changed, 154 insertions, 41 deletions
diff --git a/docs/ENTERTAIN.md b/docs/ENTERTAIN.md
index f6b9667..4fd75b0 100644
--- a/docs/ENTERTAIN.md
+++ b/docs/ENTERTAIN.md
@@ -1,22 +1,26 @@
# Entertain Area · HyBBX
-Optional **Main / standalone Main** feature plugin for games (chess first).
-Not loaded on Secondary or Proxy. AmigaOS builds force the plugin **OFF** at CMake.
+Optional **Main / standalone Main** feature plugin. Chess is a **fixed** part of
+Entertain (no separate `chess=` INI key). AmigaOS builds force the plugin **OFF**.
## Enable
| Layer | Setting |
|-------|---------|
| Build | `-DHYBBX_PLUGIN_ENTERTAIN=ON` (default on POSIX; forced off on AmigaOS) |
-| INI | `[networks] entertain=yes` |
-| Role | `hybbxd` Main (or standalone Main) |
+| INI | **`[entertain] enabled=yes`** (not under `[networks]`) |
+| Role | `hybbxd` Main or standalone Main only |
```ini
-[networks]
-entertain = yes
+[entertain]
+enabled = yes
```
-Log line on success: `[entertain] plugin loaded — chess_max_games=…`
+Legacy `[networks] entertain=yes` is still read with a warning — prefer `[entertain]`.
+
+Log: `[entertain] enabled=yes …` then `[entertain] plugin loaded — chess_max_games=…`
+
+When Entertain is off, `/chess` stays **Unknown command** (by design).
## Chess
@@ -30,8 +34,9 @@ Log line on success: `[entertain] plugin loaded — chess_max_games=…`
| `/chess resign` / `/chess draw` | Resign / offer-accept draw |
| `/chess list` / `/chess board` / `/chess clear` | List / show / free finished slots |
| `/play …` | Alias for `/chess` |
+| `/proxychess …` | **Stub** — future chess via mains_proxy mesh |
-Limits: no castling, no en passant; pawn promotes to Q/R/B/N. ASCII board for telnet/SSH.
+Limits: no castling, no en passant; pawn promotes to Q/R/B/N. Compact ASCII board.
## Related
diff --git a/docs/MASTER-GUIDE.md b/docs/MASTER-GUIDE.md
index b6d025d..2f5d180 100644
--- a/docs/MASTER-GUIDE.md
+++ b/docs/MASTER-GUIDE.md
@@ -61,7 +61,8 @@ Full key tables: frozen `docs/MANUAL.md`. Vault INI copy (reference station): `s
|---------|---------|
| `[service]` | Name, session limit, prompt |
| `[storage]` | `flatfile` or `sqlite`; user shards under `users/` |
-| `[networks]` | Enable plugins: `ax25`, `baycom`, `crdop`, `circuit`, `ssh`, `websocket`, `entertain` (Main chess) |
+| `[networks]` | Enable transports: `ax25`, `baycom`, `crdop`, `circuit`, `ssh`, `websocket`, … |
+| `[entertain]` | Main/standalone Entertain area (`enabled=yes`; chess built-in) |
| `[transport.telnet]` | Bind, port `2323` |
| `[transport.circuit]` | HBX hub port `7323`, `max_links` (default 8, max 16) |
| `[transport.packet_radioN]` | TNC instance — device, `tnc=` profile, `protocol=kiss` |
diff --git a/include/hybbx/entertain_config.h b/include/hybbx/entertain_config.h
new file mode 100644
index 0000000..8042d8a
--- /dev/null
+++ b/include/hybbx/entertain_config.h
@@ -0,0 +1,34 @@
+#ifndef HYBBX_ENTERTAIN_CONFIG_H
+#define HYBBX_ENTERTAIN_CONFIG_H
+
+#include "hybbx/config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Entertain feature area — Main / standalone Main only.
+ * Chess is a fixed part of Entertain (no separate chess= INI key).
+ * Future: /proxychess (stub) for mesh play via Mains.
+ */
+typedef struct hybbx_entertain_config {
+ /** Non-zero when [entertain] enabled=yes and role allows. */
+ int enabled;
+} hybbx_entertain_config_t;
+
+void hybbx_entertain_config_defaults(hybbx_entertain_config_t *cfg);
+
+/** Load [entertain]; force off on Secondary/Proxy. */
+void hybbx_entertain_config_apply(const hybbx_config_t *config);
+
+const hybbx_entertain_config_t *hybbx_entertain_config_get(void);
+
+/** Non-zero when Entertain plugin should load. */
+int hybbx_entertain_enabled(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HYBBX_ENTERTAIN_CONFIG_H */
diff --git a/include/hybbx/networks.h b/include/hybbx/networks.h
index b58642d..ab8e954 100644
--- a/include/hybbx/networks.h
+++ b/include/hybbx/networks.h
@@ -35,8 +35,6 @@ typedef struct hybbx_networks_config {
int circuit;
/** Main-to-Main mesh (`transport.mains_proxy`) — Secondary primary. */
int mains_proxy;
- /** Entertain feature plugin (chess, …) — Main / standalone Main only. */
- int entertain;
} hybbx_networks_config_t;
void hybbx_networks_config_defaults(hybbx_networks_config_t *networks);
diff --git a/plugins/entertain/entertain.c b/plugins/entertain/entertain.c
index f8dfa6a..23f61b1 100644
--- a/plugins/entertain/entertain.c
+++ b/plugins/entertain/entertain.c
@@ -5,6 +5,7 @@
*/
#include "hybbx/plugin.h"
#include "hybbx/service.h"
+#include "hybbx/session.h"
#include "hybbx/command.h"
#include "hybbx/log.h"
#include "entertain_chess.h"
@@ -56,6 +57,15 @@ static hybbx_result_t entertain_on_command(struct hybbx_service *service,
return HYBBX_ERR_NOT_FOUND;
}
+ /* Future: chess over mains_proxy mesh — stub only. */
+ if (strcmp(cmd->verb, "proxychess") == 0) {
+ if (session != NULL) {
+ hybbx_session_write_line(session,
+ "proxychess: not implemented yet (Main mesh stub).");
+ }
+ return HYBBX_OK;
+ }
+
if (verb_is_chess(cmd->verb)) {
return entertain_cmd_chess(service, session, cmd);
}
diff --git a/share/commands.yaml b/share/commands.yaml
index 566f281..008bb4b 100644
--- a/share/commands.yaml
+++ b/share/commands.yaml
@@ -314,6 +314,11 @@ commands:
line1: "/chess new|join|watch|move|board|resign|draw|list|leave|clear"
line2: "Help: Entertain chess (Main). Moves: /chess move e2 e4 or /mv e2e4. Alias: /play"
+ proxychess:
+ group: entertain
+ min: User
+ line1: "/proxychess …"
+ line2: "Help: Stub — chess via mains_proxy mesh (not implemented yet)."
diff --git a/share/hybbx-main.ini.example b/share/hybbx-main.ini.example
index 473f79c..b6bb6ae 100644
--- a/share/hybbx-main.ini.example
+++ b/share/hybbx-main.ini.example
@@ -56,8 +56,10 @@ ssh = yes
websocket = yes
circuit = yes
mains_proxy = no
-; Entertain (chess) — Main only; set yes to load plugin
-entertain = yes
+
+; Entertain area (chess built-in) — Main / standalone Main only
+[entertain]
+enabled = yes
[transport.telnet]
bind = 0.0.0.0
diff --git a/share/hybbx-standalone.ini.example b/share/hybbx-standalone.ini.example
index 3353892..86ed314 100644
--- a/share/hybbx-standalone.ini.example
+++ b/share/hybbx-standalone.ini.example
@@ -61,8 +61,10 @@ baycom = yes
tmodem = no
ssh = yes
circuit = yes
-; Entertain (chess) — Main only
-entertain = yes
+
+; Entertain area (chess built-in) — Main / standalone Main only
+[entertain]
+enabled = yes
[max25]
check = yes
diff --git a/share/hybbxd-main.ini.example b/share/hybbxd-main.ini.example
index 1988b41..8ce2db0 100644
--- a/share/hybbxd-main.ini.example
+++ b/share/hybbxd-main.ini.example
@@ -58,8 +58,10 @@ ardop = no
crdop = no
circuit = yes
mains_proxy = no
-; Entertain (chess) — Main / standalone Main only; AmigaOS build omits plugin
-entertain = yes
+
+; Entertain area (chess built-in) — Main / standalone Main only
+[entertain]
+enabled = yes
[transport.websocket]
bind = 127.0.0.1
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9b71bcc..bcc337b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -40,6 +40,7 @@ if(HYBBX_BUILD_DAEMON)
core/util.c
core/log.c
core/monitor.c
+ core/entertain_config.c
core/max25.c
core/security.c
core/security_ban.c
diff --git a/src/core/entertain_config.c b/src/core/entertain_config.c
new file mode 100644
index 0000000..7f1e35e
--- /dev/null
+++ b/src/core/entertain_config.c
@@ -0,0 +1,65 @@
+#include "hybbx/entertain_config.h"
+#include "hybbx/instance.h"
+#include "hybbx/log.h"
+#include "hybbx/util.h"
+
+#include <string.h>
+
+static hybbx_entertain_config_t g_entertain;
+static int g_entertain_ready;
+
+void hybbx_entertain_config_defaults(hybbx_entertain_config_t *cfg)
+{
+ if (cfg == NULL) {
+ return;
+ }
+
+ memset(cfg, 0, sizeof(*cfg));
+ cfg->enabled = 0;
+}
+
+void hybbx_entertain_config_apply(const hybbx_config_t *config)
+{
+ hybbx_instance_role_t role;
+ const char *legacy;
+
+ hybbx_entertain_config_defaults(&g_entertain);
+ g_entertain_ready = 1;
+
+ if (config != NULL) {
+ g_entertain.enabled = hybbx_config_get_bool(config, "entertain",
+ "enabled", 0);
+ /* Legacy: [networks] entertain= — prefer [entertain] enabled= */
+ legacy = hybbx_config_get(config, "networks", "entertain", NULL);
+ if (legacy != NULL && legacy[0] != '\0' &&
+ !hybbx_config_get(config, "entertain", "enabled", NULL)) {
+ g_entertain.enabled = hybbx_bool_is_true(legacy);
+ hybbx_log_warn("[entertain] legacy [networks] entertain= — "
+ "use [entertain] enabled=yes");
+ }
+ }
+
+ role = hybbx_instance_role();
+ if (g_entertain.enabled && role != HYBBX_INSTANCE_MAIN) {
+ hybbx_log_warn("[entertain] Main / standalone Main only — forcing off "
+ "(role=%s)",
+ hybbx_instance_role_name());
+ g_entertain.enabled = 0;
+ }
+
+ hybbx_log_info("[entertain] enabled=%s (chess built-in; Main/standalone only)",
+ hybbx_bool_to_string(g_entertain.enabled));
+}
+
+const hybbx_entertain_config_t *hybbx_entertain_config_get(void)
+{
+ if (!g_entertain_ready) {
+ hybbx_entertain_config_defaults(&g_entertain);
+ }
+ return &g_entertain;
+}
+
+int hybbx_entertain_enabled(void)
+{
+ return hybbx_entertain_config_get()->enabled;
+}
diff --git a/src/core/instance.c b/src/core/instance.c
index 0b9f717..1734c4f 100644
--- a/src/core/instance.c
+++ b/src/core/instance.c
@@ -160,7 +160,7 @@ hybbx_result_t hybbx_networks_enforce_instance(hybbx_networks_config_t *networks
hybbx_instance_binary_name());
hybbx_log_info("[instance] binary=%s role=%s standalone=yes user_bbx=%s "
"telnet=%s ssh=%s ax25=%s baycom=%s ardop=%s crdop=%s "
- "websocket=%s circuit=%s mains_proxy=%s entertain=%s",
+ "websocket=%s circuit=%s mains_proxy=%s",
hybbx_instance_binary_name(),
hybbx_instance_role_name(),
hybbx_instance_offers_user_bbx() ? "yes" : "no",
@@ -172,8 +172,7 @@ hybbx_result_t hybbx_networks_enforce_instance(hybbx_networks_config_t *networks
hybbx_bool_to_string(networks->crdop),
hybbx_bool_to_string(networks->websocket),
hybbx_bool_to_string(networks->circuit),
- hybbx_bool_to_string(networks->mains_proxy),
- hybbx_bool_to_string(networks->entertain));
+ hybbx_bool_to_string(networks->mains_proxy));
return HYBBX_OK;
}
@@ -218,10 +217,6 @@ hybbx_result_t hybbx_networks_enforce_instance(hybbx_networks_config_t *networks
break;
case HYBBX_INSTANCE_SECONDARY:
- if (networks->entertain) {
- hybbx_log_warn("[instance] hybbxsd: entertain Main-only — forcing off");
- networks->entertain = 0;
- }
if (networks->telnet) {
hybbx_log_warn("[instance] hybbxsd: no user telnet — forcing off");
networks->telnet = 0;
@@ -243,10 +238,6 @@ hybbx_result_t hybbx_networks_enforce_instance(hybbx_networks_config_t *networks
break;
case HYBBX_INSTANCE_PROXY:
- if (networks->entertain) {
- hybbx_log_warn("[instance] hybbxpd: entertain Main-only — forcing off");
- networks->entertain = 0;
- }
if (networks->websocket) {
hybbx_log_warn("[instance] hybbxpd: WebSocket forbidden — forcing off");
networks->websocket = 0;
@@ -268,7 +259,7 @@ hybbx_result_t hybbx_networks_enforce_instance(hybbx_networks_config_t *networks
hybbx_log_info("[instance] binary=%s role=%s user_bbx=%s "
"telnet=%s ssh=%s ax25=%s baycom=%s ardop=%s crdop=%s "
- "websocket=%s circuit=%s mains_proxy=%s entertain=%s",
+ "websocket=%s circuit=%s mains_proxy=%s",
hybbx_instance_binary_name(),
hybbx_instance_role_name(),
hybbx_instance_offers_user_bbx() ? "yes" : "no",
@@ -280,8 +271,7 @@ hybbx_result_t hybbx_networks_enforce_instance(hybbx_networks_config_t *networks
hybbx_bool_to_string(networks->crdop),
hybbx_bool_to_string(networks->websocket),
hybbx_bool_to_string(networks->circuit),
- hybbx_bool_to_string(networks->mains_proxy),
- hybbx_bool_to_string(networks->entertain));
+ hybbx_bool_to_string(networks->mains_proxy));
return HYBBX_OK;
}
diff --git a/src/core/networks.c b/src/core/networks.c
index f61479e..dfc1370 100644
--- a/src/core/networks.c
+++ b/src/core/networks.c
@@ -1,4 +1,5 @@
#include "hybbx/networks.h"
+#include "hybbx/entertain_config.h"
#include "hybbx/instance.h"
#include "hybbx/config.h"
#include "hybbx/util.h"
@@ -54,7 +55,6 @@ void hybbx_networks_config_defaults(hybbx_networks_config_t *networks)
networks->websocket = 0;
networks->circuit = 1;
networks->mains_proxy = 0;
- networks->entertain = 0;
}
void hybbx_networks_config_apply(hybbx_networks_config_t *networks,
@@ -107,13 +107,8 @@ void hybbx_networks_config_apply(hybbx_networks_config_t *networks,
"mains_proxy", 0);
}
- if (networks_has_key(config, "entertain")) {
- networks->entertain = hybbx_config_get_bool(config, "networks",
- "entertain", 0);
- }
-
hybbx_log_info("[networks] telnet=%s ssh=%s ax25=%s baycom=%s ardop=%s "
- "crdop=%s websocket=%s circuit=%s mains_proxy=%s entertain=%s",
+ "crdop=%s websocket=%s circuit=%s mains_proxy=%s",
hybbx_bool_to_string(networks->telnet),
hybbx_bool_to_string(networks->ssh),
hybbx_bool_to_string(networks->ax25),
@@ -122,8 +117,7 @@ void hybbx_networks_config_apply(hybbx_networks_config_t *networks,
hybbx_bool_to_string(networks->crdop),
hybbx_bool_to_string(networks->websocket),
hybbx_bool_to_string(networks->circuit),
- hybbx_bool_to_string(networks->mains_proxy),
- hybbx_bool_to_string(networks->entertain));
+ hybbx_bool_to_string(networks->mains_proxy));
}
int hybbx_networks_is_static_transport(const char *plugin_name)
@@ -195,7 +189,8 @@ int hybbx_networks_transport_wanted(const char *plugin_name,
}
if (str_ieq(plugin_name, "entertain")) {
- return networks->entertain;
+ (void)networks;
+ return hybbx_entertain_enabled();
}
return 0;
diff --git a/src/core/service.c b/src/core/service.c
index dda6311..8d0233e 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -27,6 +27,7 @@ void hybbx_mains_proxy_plugin_tick(void);
#include "hybbx/instance.h"
#include "hybbx/log.h"
#include "hybbx/monitor.h"
+#include "hybbx/entertain_config.h"
#include <errno.h>
#include "hybbx/security.h"
#include "hybbx/security_ban.h"
@@ -1300,6 +1301,8 @@ hybbx_result_t hybbx_service_apply_config(hybbx_service_t *service,
return rc;
}
+ hybbx_entertain_config_apply(config);
+
rc = service_apply_circuit(svc, config);
if (rc != HYBBX_OK) {
return rc;
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com