Warning
WIP Waring
This project has not yet completed a security review. Please do not deploy it in a production environment or on an open network lightly.
Mainly based on interest
Other reasons:
- As part of the network infrastructure, miniupnpd has fewer vulnerability reports thanks to active maintenance, but the code is more confusing.
- As a low-level language, C language will gradually have fewer maintainers, and switching to rust may inject new impetus into the community.
Of course , replace to rust will be take some defect:
- binary size
rust complier difficult to reduce binary size in large projects
- platform support
Due to language requirements, it is difficult to support some special platforms
- basic demo
- iptable backend
- nftables backend
- function review
- security review
- evaluate binary size
- pf/ipfw
- ...
Use Rust's expressiveness to simplify code
Currently, this project is compiled with the nightly toolchain because it needs to use build-std and some other unstable features to reduce the binary size.
RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none " cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features="optimize_for_size" -Z build-std-features=panic_immediate_abort --features pcp_peer,strict -Z unstable-options --release
apk add libuuid libcap-ng-dev util-linux-dev
# depends by bindgen
apk add clang-dev musl-dev llvm-dev
# iptables
apk add iptables-dev
# nftables
apk add libmnl-dev libnftnl-dev
rustup component add rust-src
RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none -C target-feature=-crt-static " cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features="optimize_for_size" -Z build-std-features=panic_immediate_abort --features pcp_peer,strict -Z unstable-options --release
Currently, the project uses a significant amount of unsafe code to access cABI and reduce binary size. Due to the nature of the project, it is difficult to completely eliminate unsafe usage;
however, we will gradually reduce its impact and conduct rigorous testing.
some feature marco in config.h are merged/remove, the following is the list if real need , tell me I can roll back
ENABLE_6FC_SERVICE
merge toipv6
ENABLE_HTTP_DATE
merge tostrict
DELAY_MSEARCH_RESPONSE
merge tostrict
ADVERTISE_WANPPPCONN
merge tostrict
RANDOMIZE_URLS
torandomurl
HAS_DUMMY_SERVICE
: only useENABLE_L3F_SERVICE
SSDP_PACKET_MAX_LEN
: no limit for String implHAVE_IP_MREQN
: force enabled, base on rust cannot support linux<3.2ENABLE_NATPMP
: force enabled, nat-pmp/pcp is a really simple and suit protocol for the nat firewall , won't close it unless there is enough reasonUSE_DAEMON
: use dynamic flagENABLE_LEASEFILE
: force enabledENABLE_L3F_SERVICE
: force enabledUSE_TIME_AS_BOOTID
: force enabledENABLE_NFT_RULE_COUNTER
: force enabled
-
ENABLE_GETIFSTATS_CACHING
-
GETIFSTATS_CACHING_DURATION
-
LEASEFILE_USE_REMAINING_TIME
-
CHECK_PORTINUSE
-
V6SOCKETS_ARE_V6ONLY
-
ENABLE_HTTPS
-
ENABLE_NFQUEUE
: when if real user need -
USE_SYSTEMD
-
PF_SET_DST_ADDR
-
MULTIPLE_EXTERNAL_IP
: need full refactor -
ENABLE_REGEX
-
USE_IFNAME_IN_RULES