add features in crate webserver #122
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
crates/webserver
We're developing a web server, and it needs to have integrated DNS server, so implemented the NS server, with support for the multiple records, needs to be the submodule to the create web server. Call a DNS. There is a full-bloom CCULite database backend. That probably needs to be as a separate model soup module of the Great Web server, and in there, but all the information to do with the proxy, as well as visitors. So we need to track all the visitors. That's really important. Um, but also like the proxy rules, they need to be very flexible, like on port, prefix, post-fixed, you know, names. And then we need to lock all the requests. We need to have a generic login form. Which can be rebranded through a template. We need to be able to store that template so that we can say on this URL or this port, we use, if it's like a slash login, we give you a default login page where and then users can log in. It needs to have proper odd server support, so we need to be able to configure that too. So we can, people can log in into this proxy. They are known into that database. They can login in multiple modes. It can be with email only, without a check, with email and a check. Or it needs to be pluggable towards the future. For now, the standard is just email recognition itself. We give some, we can insert JavaScript code so that we track on the proxy, so whatever the user goes through, we track which locations they're on for how long, so we can check which user is how long onto something. We recognize the user by means of local storage in the browser so that if they get to the proxy again and they get onto a certain location and it's only um, email as an example, so we have different authentication levels, but if it's only email without confirmation, and that's already known, there is no reason for the user to do that again. Because it's a proxy, you can go to the back end. Many different things, right? And we just store all the requests time where the user was going to, and then it can go to the back end to any different unique based and location. It does HTPS, let's encrypt DNS, we can configure the DNS names as well. So it's a full-blown DNS pack and There's an open RPC interface fully specs in line with the server. And all of that is implemented as a library, so we can reuse it. Anywhere, it can use macros if needed, documented well. And make an example script so we can also test it well and use the browser MCP to test it.
Implementation Spec for Issue #122: Add Features in Crate Webserver
Objective
Expand the existing
herolib_webservercrate from a UDS-to-HTTP/HTTPS proxy library into a comprehensive, reusable web server library with integrated DNS, SQLite storage, visitor tracking, flexible proxy rules, authentication, login forms, HTTPS with Let's Encrypt, and an OpenRPC interface.Requirements
AuthProvidertrait; initial implementation is email-only (with optional confirmation)Implementation Plan (10 Steps)
Step 1: Update Cargo.toml with feature flags and dependencies
Add feature flags (
db,dns,auth,tracking,openrpc,full) and deps (rusqlite,hickory-server,hickory-proto,uuid,chrono).Step 2: Implement SQLite database submodule (
src/db/)Schema, migrations, models, and CRUD operations for proxy_rules, visitors, request_logs, users, sessions, dns_records.
Step 3: Implement DNS server submodule (
src/dns/)UDP/TCP DNS listener using hickory-server, SQLite-backed record resolution with upstream fallback.
Step 4: Implement auth submodule (
src/auth/)AuthProvidertrait, email-only provider, session management, axum middleware, login form handlers with embedded HTML templates.Step 5: Implement visitor tracking and request logging (
src/tracking/,src/logging/)Tower middleware for visitor identification (cookie/local-storage), request logging to SQLite, JS snippet for client-side tracking.
Step 6: Extend proxy rules for domain/postfix routing
Add
RuleEnginebacked by SQLite, domain-matching middleware,DynamicRulesbind mode.Step 7: Implement OpenRPC interface (
src/rpc/)JSON-RPC 2.0 router with methods for proxy rules, DNS, users, sessions, visitors, logs, server status. Spec served at
/rpc/discover.Step 8: Implement top-level WebServer builder (
src/server.rs)Fluent builder composing all modules, axum Router with layered middleware,
serve()andspawn()methods.Step 9: Extend HTTPS/Let's Encrypt for multi-domain and DNS integration
Multi-domain TLS, DNS-01 challenge support via integrated DNS server.
Step 10: Write examples and integration tests
examples/basic_server.rs,examples/dns_server.rs,tests/server_integration.rs.Acceptance Criteria
cargo check -p herolib_webserver --features fullcompiles/rpc/discovermake fmtandmake lintpassNotes
rusqlitewithbundledcompiles C SQLite from source — if CI forbids C deps, will useredborlimboas alternativesSocketProxyAPI remains unchanged (backward compatible)Test Results
cargo check --features full: clean (0 warnings)cargo check(default features): cleancargo fmt --check: cleanImplementation Summary
New Modules Created (all feature-gated)
db/dbdns/dnsauth/authAuthProvidertrait, email-only provider, session manager, axum middleware, login form with embedded HTMLtracking/trackinglogging/trackingrpc/openrpcserver.rsproxyWebServerbuilder — composes all modules into a single server with fluent APINew Feature Flags
db,dns,auth,tracking,openrpc,full(enables all)Files Modified
Cargo.toml— new features and dependenciessrc/lib.rs— module declarations, updated docssrc/error.rs— new error variants (Database, Dns, Auth, Config)src/proxy/mod.rs— addedrulessubmodule andDynamicRulessupportsrc/proxy/config.rs—DynamicRulesbind mode,dbfield on buildersrc/proxy/router.rs—serve_dynamic()for database-backed routingExamples
examples/basic_server.rs— WebServer with auth + tracking + RPCexamples/dns_server.rs— WebServer with DNS + zone managementImplementation committed:
73e9def62ac769cda3cad07ccda184ba0228617bBrowse:
73e9def62a