Skip to content

Commit f1f39d9

Browse files
doublegateclaude
andcommitted
feat(release): v0.4.0 - Scripting, Plugins, DCC & IRCv3
Implement Phases 4-6 of the RustIRC development plan, transforming the project from a GUI-focused IRC client into a fully extensible platform with production-ready subsystems. Test count increased from 144 to 266. Phase 4 - Scripting, Plugins & Configuration: - Lua scripting engine: complete rewrite of ScriptEngine with load_script(), trigger_event(), execute_command(), auto_load_scripts() using std::sync::RwLock to avoid async runtime conflicts. Sandbox applies memory limits, CPU timeout via instruction count hooks, blocks io/debug/loadfile/dofile/require modules - ScriptMessage UserData: Lua-accessible IRC message with get_nick(), get_channel(), get_text(), get_command(), get_params(), get_prefix() - Plugin system: PluginManager with HashMap<String, LoadedPlugin>, full lifecycle (register, unload, enable, disable, shutdown_all), auto-init via PluginContext on registration - Built-in plugins: LoggerPlugin (file-based IRC logging), HighlightPlugin (case-insensitive keyword matching with add/remove word management) - Config I/O: Config::from_file(), Config::save() with TOML pretty-print, Config::default_path() via dirs crate (XDG), Config::generate_default_config() with example Libera Chat server. All structs use #[serde(default)] - New config structs: DccConfig, FloodConfig, ProxyConfig, NotificationConfig - Main entry point: real config loading, init_scripting(), init_plugins() Phase 5 - Advanced Features: - DCC protocol (dcc/mod.rs, chat.rs, transfer.rs): DccManager with async session lifecycle, parse_dcc_request(peer_nick, ctcp_data) for CHAT/SEND/ RESUME/ACCEPT, IP long-format conversion, TransferProgress tracking, file size limits, event channel (DccEvent) - IRCv3 batch handler (batch.rs): BatchManager tracking open/completed batches, nested batch support via parent_ref, BatchType enum with parse()/as_str(), message routing by batch tag - IRCv3 CHATHISTORY (chathistory.rs): ChatHistoryManager with request queue, FIFO correlation, BEFORE/AFTER/BETWEEN/AROUND/LATEST commands, MessageReference (MsgId/Timestamp) with parse()/to_param() - Flood protection (flood.rs): token bucket algorithm with configurable max_tokens (burst), refill_rate (tokens/sec), bounded message queue, try_send(), enqueue(), drain_ready(), next_send_time() - Proxy support (proxy/): SOCKS5 via tokio-socks with auth, HTTP CONNECT with manual implementation, ProxyConnector async trait with from_config() - Message tag helpers: get_tag(), has_tag(), get_time(), get_msgid(), get_batch(), get_label() on protocol Message - Notification rules (notifications.rs): highlight words, quiet hours, notification history with timestamped entries - Search engine (search.rs): full-text message search with channel/user/ date filters, SearchState for UI integration - URL preview (url_preview.rs): OnceLock<Regex> URL detection (MSRV 1.75) - Settings persistence: AppSettings Serialize/Deserialize with XDG paths Phase 6 - Testing & Integration: - 5 integration test files (tests/): config_test (6), scripting_test (7), plugin_test (7), ircv3_test (6), dcc_test (7) = 33 integration tests - Test isolation: unique temp subdirectories prevent parallel test races - Raw string syntax: r##"..."## for Lua code containing "#" characters Dependencies added: dirs 6.0, notify-rust 4, tokio-socks 0.5, chrono 0.4 Files: 21 new, 24 modified | 266 tests passing | 0 clippy warnings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bcd987e commit f1f39d9

46 files changed

Lines changed: 7425 additions & 496 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 175 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,175 @@ All notable changes to RustIRC will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.4.0] - 2026-03-07 (Scripting, Plugins, DCC & IRCv3)
9+
10+
### Summary
11+
Major feature release implementing Phases 4-6 of the RustIRC development plan. This release transforms the project from a GUI-focused IRC client into a fully extensible platform with production-ready Lua scripting, a plugin system with built-in plugins, DCC protocol support, IRCv3 batch/chathistory extensions, flood protection, proxy support (SOCKS5/HTTP CONNECT), and comprehensive integration tests. Test count increased from 144 to 266.
12+
13+
### Added
14+
15+
#### Phase 4: Scripting, Plugins & Configuration
16+
17+
##### Config File I/O (`crates/rustirc-core/src/config.rs`)
18+
- **TOML Persistence**: `Config::from_file()`, `Config::save()` with pretty TOML serialization and automatic parent directory creation
19+
- **XDG Compliance**: `Config::default_path()` using `dirs::config_dir()/rustirc/config.toml`
20+
- **First-Run Experience**: `Config::generate_default_config()` creates commented default config with example Libera Chat server
21+
- **Forward Compatibility**: All config structs annotated with `#[serde(default)]` for graceful handling of missing fields
22+
- **New Config Sections**: `DccConfig`, `FloodConfig`, `ProxyConfig`, `NotificationConfig`, `QuietHours` structs
23+
24+
##### Lua Scripting Engine (`crates/rustirc-scripting/`)
25+
- **Complete Engine Rewrite**: `ScriptEngine` with `load_script()`, `unload_script()`, `trigger_event()`, `execute_command()`, `auto_load_scripts()`, `list_scripts()` -- all sync methods using `std::sync::RwLock` to avoid async runtime conflicts
26+
- **ScriptMessage UserData** (`script_message.rs`): Lua-accessible IRC message type with `get_nick()`, `get_channel()`, `get_text()`, `get_command()`, `get_params()`, `get_prefix()` methods
27+
- **Sandbox Security** (`sandbox.rs`): Memory limits, CPU timeout via Lua instruction count hooks (returns `mlua::VmState::Continue`), blocks `io`/`debug`/`loadfile`/`dofile`/`require`, restricts `os` to safe subset (`clock`/`date`/`difftime`/`time`)
28+
- **IRC API Table**: `irc.print()`, `irc.send_message()`, `irc.join()`, `irc.part()`, `irc.register_handler()`, `irc.command()`, `irc.get_var()`, `irc.set_var()` registered in Lua global scope
29+
- **Priority System**: Scripts sorted by priority (highest first) for deterministic event handler execution order
30+
- **Config Integration**: `ScriptEngine::from_config(&ScriptingConfig)` with configurable memory limits, timeout, scripts path
31+
32+
##### Plugin System (`crates/rustirc-plugins/`)
33+
- **Plugin Manager Rewrite** (`manager.rs`): `PluginManager` with `HashMap<String, LoadedPlugin>`, full lifecycle management (`register_plugin()`, `unload_plugin()`, `enable_plugin()`, `disable_plugin()`, `shutdown_all()`), auto-initialization on registration via `PluginContext`
34+
- **Built-in Logger Plugin** (`builtin/logger.rs`): `LoggerPlugin` that creates log directories and manages file-based IRC message logging
35+
- **Built-in Highlight Plugin** (`builtin/highlight.rs`): `HighlightPlugin` with case-insensitive keyword matching (`check_message()`), dynamic word management (`add_word()`, `remove_word()`)
36+
- **Plugin Loader** (`loader.rs`): `PluginLoader` with search path discovery and `default_plugin_dir()` using `dirs::data_dir()/rustirc/plugins`
37+
38+
##### Integration Wiring (`src/main.rs`)
39+
- **Real Config Loading**: Replaced no-op `load_config()` with `Config::from_file()` / `Config::load_or_default()`
40+
- **Script Engine Init**: `init_scripting()` creates `ScriptEngine` from config and calls `auto_load_scripts()`
41+
- **Plugin Manager Init**: `init_plugins()` creates `PluginManager` and registers built-in `LoggerPlugin` and `HighlightPlugin`
42+
43+
#### Phase 5: Advanced Features
44+
45+
##### DCC Protocol (`crates/rustirc-core/src/dcc/`)
46+
- **DCC Manager** (`mod.rs`): Central session tracker with async session lifecycle, event channel (`DccEvent`), auto-incrementing session IDs
47+
- **DCC Request Parsing**: `parse_dcc_request(peer_nick, ctcp_data)` supporting CHAT, SEND, RESUME, ACCEPT with IP long-format conversion
48+
- **DCC Chat** (`chat.rs`): Direct client-to-client messaging over TCP
49+
- **DCC Transfer** (`transfer.rs`): File send/receive with `TransferProgress` tracking (bytes_transferred, speed_bps, percentage), cancel support
50+
- **Session Types**: `DccSession::Chat`, `DccSession::Send`, `DccSession::Receive` with direction tracking (Incoming/Outgoing)
51+
- **Security**: File size limits via `DccConfig::max_file_size`, disabled-by-config check on all operations
52+
- **IP Conversion**: `ip_to_long(&IpAddr) -> u64` and `parse_ip_long(&str) -> DccResult<IpAddr>` for DCC protocol encoding
53+
54+
##### IRCv3 Extensions
55+
56+
###### Batch Message Handler (`crates/rustirc-core/src/batch.rs`)
57+
- **BatchManager**: Tracks open/completed batches with `handle_batch_start()`, `handle_batch_end()`, `add_message()`
58+
- **Nested Batches**: Parent reference tracking via batch tags on BATCH commands
59+
- **Batch Types**: `Netjoin`, `Netsplit`, `ChatHistory`, `LabeledResponse`, `Custom(String)` with `parse()` and `as_str()` methods
60+
- **Message Routing**: `message_is_batched()` checks if a message belongs to any open batch
61+
62+
###### CHATHISTORY Support (`crates/rustirc-core/src/chathistory.rs`)
63+
- **ChatHistoryManager**: Request queue with FIFO correlation, builds protocol messages for BEFORE, AFTER, BETWEEN, AROUND, LATEST commands
64+
- **MessageReference**: `MsgId(String)` and `Timestamp(String)` variants with `parse()` and `to_param()` methods
65+
- **Request Lifecycle**: `request_history()` returns `(u64, Message)` for correlation, `handle_response()` pops FIFO queue
66+
67+
###### Message Tag Helpers (`crates/rustirc-protocol/src/message.rs`)
68+
- **Tag Access Methods**: `get_tag()`, `has_tag()`, `get_time()`, `get_msgid()`, `get_batch()`, `get_label()` on `Message`
69+
70+
##### Flood Protection (`crates/rustirc-core/src/flood.rs`)
71+
- **Token Bucket Algorithm**: `FloodProtector` with configurable `max_tokens` (burst capacity), `refill_rate` (tokens/sec), bounded message queue
72+
- **API**: `try_send()` (consume token), `enqueue()` (queue message), `drain_ready()` (send queued messages), `next_send_time()` (calculate wait)
73+
- **Config Integration**: `FloodProtector::from_config(&FloodConfig)` with enable/disable toggle
74+
75+
##### Proxy Support (`crates/rustirc-core/src/proxy/`)
76+
- **SOCKS5 Proxy** (`socks5.rs`): Via `tokio-socks` crate with optional username/password authentication
77+
- **HTTP CONNECT Proxy** (`http.rs`): Manual implementation with basic authentication header support
78+
- **ProxyConnector Trait**: `async fn connect()` trait with `from_config()` factory dispatching to Socks5 or HttpConnect
79+
- **ProxyConfig**: `proxy_type` (None/Socks5/HttpConnect), `address`, `port`, `username`, `password` fields
80+
81+
##### GUI Enhancements
82+
83+
###### Notification Rules Engine (`crates/rustirc-gui/src/notifications.rs`)
84+
- **NotificationRules**: Configurable highlight words, nick mention detection, channel/user filters
85+
- **QuietHours**: Time-based notification suppression with weekend override
86+
- **Notification History**: Timestamped `NotificationEntry` log with `NotificationType` classification
87+
88+
###### Search Engine (`crates/rustirc-gui/src/search.rs`)
89+
- **SearchEngine**: Full-text message search with `SearchQuery` (text, channel filter, user filter, date range, case sensitivity)
90+
- **SearchState**: UI state management for search panel integration
91+
92+
###### URL Preview (`crates/rustirc-gui/src/widgets/url_preview.rs`)
93+
- **URL Detection**: Regex-based URL extraction from messages using `OnceLock<Regex>` (MSRV 1.75 compatible)
94+
- **URL Info**: Extracted URL metadata with display text and original URL
95+
96+
###### Settings Persistence (`crates/rustirc-gui/src/state.rs`)
97+
- **AppSettings Serialization**: Added `serde::Serialize`/`Deserialize` derives with `#[serde(default)]`
98+
- **Persistence Methods**: `AppSettings::settings_path()`, `save()`, `load()` for XDG-compliant settings storage
99+
100+
#### Phase 6: Testing & Integration
101+
102+
##### Integration Test Suite (`tests/`)
103+
- **`tests/config_test.rs`** (6 tests): Config save/load roundtrip, parent directory creation, forward compatibility, default path validation, default config generation, all-sections persistence
104+
- **`tests/scripting_test.rs`** (7 tests): Engine creation from config, event handler firing, command execution, sandbox blocking dangerous operations, variable persistence across scripts, priority ordering, ScriptMessage method access
105+
- **`tests/plugin_test.rs`** (7 tests): Plugin registration and listing, enable/disable toggle, unload lifecycle, built-in highlight plugin word matching, built-in logger plugin initialization, shutdown_all cleanup, plugin info retrieval
106+
- **`tests/ircv3_test.rs`** (6 tests): Batch lifecycle (start/add/end), message tag helpers, CHATHISTORY request building, MessageReference parsing, flood protection burst limiting, flood protection queue management
107+
- **`tests/dcc_test.rs`** (7 tests): DCC manager creation, SEND request parsing, CHAT request parsing, RESUME request parsing, IP long-format conversion, disabled config behavior, invalid request handling
108+
109+
### Changed
110+
- **Config structs**: All config structs now derive `Default` and use `#[serde(default)]` for forward compatibility
111+
- **ScriptEngine**: Switched from `tokio::sync::RwLock` to `std::sync::RwLock` to prevent "Cannot start runtime from within runtime" panics
112+
- **BatchType**: Renamed `from_str()` to `parse()` to avoid confusion with `FromStr` trait (clippy lint)
113+
- **Root Cargo.toml**: Added `rustirc-protocol` to binary dependencies for integration test access
114+
115+
### Dependencies
116+
- Added `dirs = "6.0"` (XDG-compliant config/data paths)
117+
- Added `notify-rust = "4"` (Linux D-Bus notifications)
118+
- Added `tokio-socks = "0.5"` (SOCKS5 proxy support)
119+
- Added `chrono = "0.4"` (notification quiet hours)
120+
121+
### Quality
122+
- **Test Count**: 144 -> 266 (84% increase)
123+
- **Unit Tests**: 233 across all workspace crates
124+
- **Integration Tests**: 33 across 5 test files
125+
- **Clippy**: Zero warnings with `-D warnings`
126+
- **Build**: Zero compilation errors
127+
128+
### New Files (27)
129+
| File | Purpose |
130+
|------|---------|
131+
| `crates/rustirc-scripting/src/script_message.rs` | ScriptMessage UserData for Lua |
132+
| `crates/rustirc-plugins/src/builtin/mod.rs` | Built-in plugin module |
133+
| `crates/rustirc-plugins/src/builtin/logger.rs` | Logger plugin |
134+
| `crates/rustirc-plugins/src/builtin/highlight.rs` | Highlight plugin |
135+
| `crates/rustirc-core/src/dcc/mod.rs` | DCC manager and protocol |
136+
| `crates/rustirc-core/src/dcc/chat.rs` | DCC chat sessions |
137+
| `crates/rustirc-core/src/dcc/transfer.rs` | DCC file transfers |
138+
| `crates/rustirc-core/src/batch.rs` | IRCv3 batch handler |
139+
| `crates/rustirc-core/src/chathistory.rs` | IRCv3 CHATHISTORY |
140+
| `crates/rustirc-core/src/flood.rs` | Flood protection |
141+
| `crates/rustirc-core/src/proxy/mod.rs` | Proxy connector trait |
142+
| `crates/rustirc-core/src/proxy/socks5.rs` | SOCKS5 proxy |
143+
| `crates/rustirc-core/src/proxy/http.rs` | HTTP CONNECT proxy |
144+
| `crates/rustirc-gui/src/notifications.rs` | Notification rules engine |
145+
| `crates/rustirc-gui/src/search.rs` | Full-text search engine |
146+
| `crates/rustirc-gui/src/widgets/url_preview.rs` | URL detection/preview |
147+
| `tests/config_test.rs` | Config integration tests |
148+
| `tests/scripting_test.rs` | Scripting integration tests |
149+
| `tests/plugin_test.rs` | Plugin integration tests |
150+
| `tests/ircv3_test.rs` | IRCv3 integration tests |
151+
| `tests/dcc_test.rs` | DCC integration tests |
152+
153+
### Modified Files (19)
154+
| File | Changes |
155+
|------|---------|
156+
| `Cargo.toml` | Version bump, added deps (dirs, notify-rust, tokio-socks), added rustirc-protocol dep |
157+
| `crates/rustirc-core/Cargo.toml` | Added dirs, tokio-socks deps |
158+
| `crates/rustirc-gui/Cargo.toml` | Added toml, dirs, notify-rust, chrono deps |
159+
| `crates/rustirc-plugins/Cargo.toml` | Added dirs, tracing deps |
160+
| `crates/rustirc-core/src/config.rs` | Config I/O methods, new config structs, serde(default) |
161+
| `crates/rustirc-core/src/lib.rs` | Added batch, chathistory, dcc, flood, proxy modules |
162+
| `crates/rustirc-gui/src/lib.rs` | Added notifications, search modules |
163+
| `crates/rustirc-gui/src/state.rs` | AppSettings Serialize/Deserialize, persistence methods |
164+
| `crates/rustirc-gui/src/widgets/mod.rs` | Added url_preview module |
165+
| `crates/rustirc-plugins/src/lib.rs` | Added builtin module |
166+
| `crates/rustirc-plugins/src/loader.rs` | Real plugin discovery implementation |
167+
| `crates/rustirc-plugins/src/manager.rs` | Full lifecycle management rewrite |
168+
| `crates/rustirc-protocol/src/message.rs` | Tag helper methods (get_tag, has_tag, etc.) |
169+
| `crates/rustirc-scripting/src/api.rs` | Real ScriptApi implementations |
170+
| `crates/rustirc-scripting/src/engine.rs` | Full ScriptEngine rewrite |
171+
| `crates/rustirc-scripting/src/lib.rs` | Added script_message module |
172+
| `crates/rustirc-scripting/src/sandbox.rs` | Full sandbox implementation |
173+
| `src/main.rs` | Real config loading, scripting/plugin initialization |
174+
175+
---
176+
8177
## [0.3.9] - 2026-01-10 (iced 0.14.0 Migration & CI Improvements)
9178

10179
### Summary
@@ -76,12 +245,12 @@ Complete GUI framework upgrade from iced 0.13.1 to iced 0.14.0 with 82+ breaking
76245

77246
## [Unreleased]
78247

79-
### Planned for Next Release (Phase 5: Advanced Features)
80-
- DCC support for file transfers and direct chats
81-
- Enhanced IRCv3 features (message-tags, server-time, batch)
82-
- Proxy support (SOCKS5, HTTP)
83-
- Native desktop notifications
84-
- Advanced channel management features
248+
### Planned for Next Release
249+
- Python scripting engine (PyO3)
250+
- Dynamic plugin loading (libloading)
251+
- Performance optimization (async script execution, ring buffers)
252+
- Fuzzing tests for protocol parser
253+
- First-run welcome experience in GUI/TUI
85254

86255
## [0.3.8] - 2025-08-26 (Material Design 3 Integration + Dependency Updates)
87256

CLAUDE.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,22 @@ The project prioritizes full compatibility with IRC standards including IRCv3 ex
1414

1515
## Development Status
1616

17-
**v0.3.9 iced 0.14.0 Migration & CI Improvements** (2026-01-10)
17+
**v0.4.0 Scripting, Plugins, DCC & IRCv3** (2026-03-07)
1818

1919
- **Phase 1**: Research & Setup ✅ (Complete 2025-08-14)
2020
- **Phase 2**: Core IRC Engine ✅ (Complete 2025-08-17)
2121
- **Phase 3**: User Interface ✅ (Complete 2025-08-17)
22-
- **GUI Fixes**: Comprehensive issue resolution ✅ (Complete 2025-08-21 12:34 AM EDT)
23-
- **CLI Enhancement**: Multi-server architecture with full GUI parity ✅ (Complete 2025-08-21 1:34 AM EDT)
24-
- **Advanced Interface Features**: Tab completion, key handling, command routing ✅ (Complete 2025-08-21 9:18 PM EDT)
25-
- **100% Full Implementation**: All code complete with no stubs or placeholders ✅ (Complete 2025-08-21 10:55 PM EDT)
26-
- **v0.3.5 GitHub Actions Resilience**: Comprehensive sccache HTTP 400 fallback, cross-platform timeout compatibility ✅ (Complete 2025-08-24 1:35 AM EDT)
27-
- **v0.3.8 Material Design 3 GUI**: Enhanced Iced implementation merged to main ✅ (100% COMPLETE - ZERO ERRORS!)
22+
- **Phase 4**: Scripting, Plugins & Config ✅ (Complete 2026-03-07)
23+
- **Phase 5**: Advanced Features (DCC, IRCv3, Proxy, Notifications) ✅ (Complete 2026-03-07)
24+
- **Phase 6**: Testing & Integration ✅ (Complete 2026-03-07)
2825
- **v0.3.9 iced 0.14.0 Migration**: Complete GUI framework upgrade with 82+ breaking API changes resolved ✅
26+
- **v0.4.0 Major Feature Release**: Lua scripting engine, plugin system, DCC protocol, IRCv3 extensions, flood protection, proxy support, 266 tests ✅
2927
- **GUI Framework**: Material Design 3 with iced 0.14.0 - reactive rendering, time-travel debugging
3028
- **Working Features**: typography, input, chip, plus major fixes in 7+ other components (0 errors)
3129
- **Implementation Complete**: SerializableColor wrapper, iced 0.14.0 API migration, lifetime management, ALL components fully functional
32-
- **Current Status**: 100% functional MD3 implementation with iced 0.14.0 - ZERO errors, ZERO warnings
30+
- **Current Status**: 266 tests passing, ZERO errors, ZERO clippy warnings
3331
- **Interface Status**: Main branch stable with iced 0.14.0 and Material Design 3 integration
32+
- **Test Status**: 266 tests (233 unit + 33 integration) across all workspace crates
3433

3534
The repository now contains:
3635

0 commit comments

Comments
 (0)