https://github.com/bluecatengineering/dora Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + For + Enterprise + Teams + Startups + Education + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} bluecatengineering / dora Public * Notifications * Fork 2 * Star 213 A Rust DHCP server License MPL-2.0 license 213 stars 2 forks Star Notifications * Code * Issues 3 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights bluecatengineering/dora This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 2 branches 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/b] Use Git or checkout with SVN using the web URL. [gh repo clone blueca] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @leshow leshow basic integration tests (#5) ... 4893825 Dec 7, 2022 basic integration tests (#5) The test must be run with the sudo -E runner because it creates a network namespace to run dora in, and a veth interface that a client will talk over. It could be improved, right now it uses a non-default port to test the logic of various client message combinations based on a given config. Additionally, the veth interface must be given an IP rather than have it configured directly by the test client. 4893825 Git stats * 15 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .cargo basic integration tests (#5) Dec 7, 2022 .github/workflows basic integration tests (#5) Dec 7, 2022 .vscode initial commit Nov 18, 2022 bin basic integration tests (#5) Dec 7, 2022 docs touch up PI guide & README Nov 23, 2022 dora-cfg add MPL-2.0 license Nov 24, 2022 dora-core basic integration tests (#5) Dec 7, 2022 external-api Fix typos Dec 2, 2022 libs Fix typos Dec 2, 2022 migrations initial commit Nov 18, 2022 plugins Fix typos Dec 2, 2022 .editorconfig initial commit Nov 18, 2022 .env initial commit Nov 18, 2022 .gitignore initial commit Nov 18, 2022 Cargo.lock basic integration tests (#5) Dec 7, 2022 Cargo.toml initial commit Nov 18, 2022 LICENSE add MPL-2.0 license Nov 24, 2022 README.md Update README.md Dec 7, 2022 basic.yaml basic integration tests (#5) Dec 7, 2022 config_schema.json clean up README Nov 18, 2022 dora.jpg initial commit Nov 18, 2022 example.yaml Update example.yaml Dec 7, 2022 rust-toolchain initial commit Nov 18, 2022 View code [ ] dora (dhcp server) Features Build/Run Cross compiling to ARM Using cross Not using cross Dora options & environment vars Config format DHCP info RFCs implemented in dora v4 v6 Performance Troubleshooting/ Testing Using perfdhcp Setting up dora on the PI Other issues? README.md dora (dhcp server) [dora] dora is a DHCP server written in Rust using tokio. It is built on the dhcproto library and sqlx. We currently use the sqlite backend, although that could change in the future. The goal of dora is to provide a complete DHCP implementation for IPv4, and eventually IPv6. Dora supports duplicate address detection, ping, binding multiple interfaces, static addresses, etc see example.yaml for all options. It is, however, an early release version and may contain bugs. We hope to build an active community around this project so we can create a new DHCP server together. PRs, issues, and constructive comments are welcome. You can see all the options available by looking through example.yaml. dora will parse equivalent JSON or YAML formats of the schema. If started on non-default dhcp port, it is assumed this is for testing, and dora will unicast any response back rather than following the RFC. Features see example.yaml for all available options. | Build/Run You will need sqlx-cli to build, as sql queries written in Rust are checked against the database at compile time. Install sqlx-cli From workspace root run: sqlx database create sqlx migrate run This should create the em.db database specified in .env, it uses the DATABASE_URL env var so make sure that's not in use elsewhere, it can also be passed using -d/--database-url. Use standard cargo subcommands to build (with the --release flag for no debug symbols): cargo build and run (by default dora will try to bind to privileged ports, which may require sudo), see the main dora binary README for parameters. Or run help: cargo run --bin dora -- --help dora requires a config file to start. See example.yaml for all available options. Use DORA_LOG env var for adjusting log level and which targets, see here for more options. Cross compiling to ARM Using cross There is a project called cross that does most of the heavy lifting and will build everything in a docker container, this is the first thing to try. cargo install cross cross build --target armv7-unknown-linux-gnueabihf --bin dora --release Note Remember to pass --release to cross if you want an optimized version of the binary You can compile for the musl target also, although it will not have jemallocator: cross build --target armv7-unknown-linux-musleabihf --bin dora --release If that works, you should have a dora binary in target/ armv7-unknown-linux-gnueabihf/debug/dora or target/ armv7-unknown-linux-musleabihf/debug/dora Not using cross Firstly, you need the ARM toolchain from rustup: rustup target add armv7-unknown-linux-gnueabihf Notice that .cargo/config.toml has an entry for replacing the linker when cross compiling to ARM: [target.armv7-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc" This means arm-linux gnueabihf-gcc must be available on the system and will be used as the linker. Once you have it installed, you can use: TARGET_CC=arm-linux-gnueabihf-gcc TARGET_AR=arm-linux-gnueabihf-gcc-ar cargo build --target=armv7-unknown-linux-gnueabihf --bin dora To produce an ARMv7 binary. I have not tested this on an actual system, but it appears to compile & link. Dora options & environment vars see dora bin readme Config format There is a tool included in the workspace called dora-cfg, you can run it with: cargo run --bin dora-cfg -- It will pretty-print the internal dora config representation as well as parse the wire format so hex encoded values are human-readable. see dora-cfg readme DHCP info * v4 FSM * v4 RFC2131 * v4 RFC2132 * v6 RFC8415 * v4 DHCP basics * network sorcery v4 * network sorcery v6 RFCs implemented in dora v4 * v4 RFC2131 * v4 RFC2132 * v4 RFC3011 * v4 RFC3527 * v4 RFC4578 * v4 RFC6842 * v4 RFC3046 * see dhcproto for protocol level support v6 * v6 RFC3736 Performance In synthetic tests with perfdhcp I was able to get to around 5000 leases/sec, but dora was nowhere near close to consuming available CPU. dora keeps no leases in memory at the moment. It relies totally on the database in order to determine which is the next IP to allocate within a range. The db workload is fairly write-heavy, and sqlite seems to bottleneck the tokio runtime at a certain point. We could go much faster by keeping leases in memory and appending to the db like more traditional DHCP implementations, but this is a trade-off for complexity. I've experimented with the bitmap from roaring-rs and it seems pretty fast, although we'd need logic to reload the database into memory again on startup and be able to evict entries after lease expiration. Additional complexity we don't care for at the moment. There may be other ways to squeeze more performance out without having to go down this road. Troubleshooting/Testing Using perfdhcp perfdhcp can be used to test dora, include giaddr, the subnet select option or the relay agent link selection opt, you can use this as a starting point: sudo perfdhcp -4 -N 9901 -L 9903 -r 1 -xi -t 1 -o 118,C0A80001 -R 100 127.0.0.1 This will start perfdhcp using dhcpv4, send messages to 127.0.0.1:9901, listen on port 9903 at a rate of 1/sec, and using 100 different devices. It includes the subnet select opt (118) with C0A80001 as a hex encoded value of the integer of 192.168.0.1. dora must be listening on 9901 and have a config with ranges to allocate on the 192.168.0.1 network. Setting up dora on the PI See PI setup Other issues? If you find a bug, or see something that doesn't look right, please open an issue and let us know. We welcome any and all constructive feedback. We're still actively working on this. Some of the things we'd like to add in the future include: DDNS updates, stateful DHCPv6, HA & Client classification. About A Rust DHCP server Resources Readme License MPL-2.0 license Stars 213 stars Watchers 5 watching Forks 2 forks Releases No releases published Packages 0 No packages published Contributors 2 * @leshow leshow Evan Cameron * @kianmeng kianmeng Kian-Meng Ang Languages * Rust 100.0% Footer (c) 2022 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.