### Setup dae systemd Service Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/run-as-daemon.md Download the systemd service file, reload the systemd daemon, and enable and start the dae service. Check the status to confirm it's running. ```bash sudo curl -L -o /etc/systemd/system/dae.service https://github.com/daeuniverse/dae/raw/main/install/dae.service sudo systemctl daemon-reload sudo systemctl enable dae --now sudo systemctl status dae ``` -------------------------------- ### Start naiveproxy with HTTP listening Source: https://github.com/daeuniverse/dae/blob/main/docs/en/proxy-protocols.md Example command to start naiveproxy listening on an HTTP port and proxying traffic to a given link. Note that HTTP proxy does not support UDP traffic. ```bash naiveproxy --listen=http://127.0.0.1:1090 --proxy=https://yourlink ``` -------------------------------- ### Download Example Configuration Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/build-by-yourself.md Download the example configuration file for Dae. This file can be used as a template for your own configuration. ```shell curl -L -o example.dae https://github.com/daeuniverse/dae/raw/main/example.dae ``` -------------------------------- ### Install dae Binary and Check Version Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/run-as-daemon.md Install the dae binary to /usr/bin/ and verify the installation by checking the version. Ensure the binary is executable. ```bash sudo chmod +x ./dae sudo install -Dm755 dae /usr/bin/ ``` ```bash dae version ``` -------------------------------- ### Install and Configure Pre-commit Hooks Source: https://github.com/daeuniverse/dae/blob/main/docs/en/development/contribute.md Install the pre-commit package and then install the pre-commit hooks for the repository. This ensures linting checks are applied before committing code. ```bash pip3 install pre-commit pre-commit install ``` -------------------------------- ### Install DAE on Fedora Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md Install DAE on Fedora by enabling the zhullyb/v2rayA Copr repository and then installing the package using dnf. ```shell sudo dnf copr enable zhullyb/v2rayA sudo dnf install dae ``` -------------------------------- ### Start DAE VM Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-macos.md Starts the DAE virtual machine configured with Lima. ```shell # Start dae VM. limactl start dae ``` -------------------------------- ### DAE Example Configuration Source: https://github.com/daeuniverse/dae/blob/main/hack/templates/example-config.md This is an example configuration file for DAE. It is intended for demonstration purposes and may require modification for specific use cases. ```python ``` -------------------------------- ### Search and Install Kernel on Arch Linux Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/kernel-upgrade.md Use pacman to search for available kernel images and install a specific one. Ensure you reboot after installation. ```bash # Search available kernel images. pacman -Ss ^linux$ ``` ```bash # Install specific kernel image. pacman -S ``` -------------------------------- ### Run Dae with Configuration Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/build-by-yourself.md Execute the Dae application using the downloaded example configuration file. Ensure the configuration is fine-tuned before running. ```shell ./dae run -c example.dae ``` -------------------------------- ### Download and Run DAE Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-centos7.md Downloads the DAE binary, sets up configuration, and runs the application. Ensure you have `wget` and `unzip` installed. ```bash mkdir -p /opt/dae && cd /opt/dae wget https://github.com/daeuniverse/dae/releases/download/v0.2.2/dae-linux-x86_64.zip unzip dae-linux-x86_64.zip && rm -f dae-linux-x86_64.zip cp example.dae config.dae chmod 600 config.dae DAE_LOCATION_ASSET=$(pwd) ./dae-linux-x86_64 run -c config.dae ``` -------------------------------- ### Configure Network and Install DAE inside VM Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-macos.md Enters the DAE VM, configures its network using netplan, installs DAE via a script, and sets up the DAE configuration file. ```shell # Enter the dae VM. limactl shell dae # Manually configure network. cat << 'EOF' | sudo tee /etc/netplan/99-override.yaml network: ethernets: eth0: dhcp4: true dhcp4-overrides: route-metric: 200 lima0: dhcp4: true dhcp6: true version: 2 EOF # Apply netplan. sudo netplan apply # Install requirements. sudo apt-get install jq # Install dae. sudo bash -c "$(curl -s https://hubmirror.v2raya.org/raw/daeuniverse/dae-installer/main/installer.sh)" @ install # Configure config.dae. cat << 'EOF' | sudo tee /usr/local/etc/dae/config.dae global { lan_interface: lima0 wan_interface: lima0 log_level: info allow_insecure: false auto_config_kernel_parameter: true } subscription { # Fill in your subscription links here. } # See https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/dns.md for full examples. dns { upstream { googledns: 'tcp+udp://dns.google:53' alidns: 'udp://dns.alidns.com:53' } routing { request { fallback: alidns } response { upstream(googledns) -> accept ip(geoip:private) && !qname(geosite:cn) -> googledns fallback: accept } } } group { proxy { #filter: name(keyword: HK, keyword: SG) policy: min_moving_avg } } # See https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/routing.md for full examples. routing { pname(NetworkManager) -> direct dip(224.0.0.0/3, 'ff00::/8') -> direct ### Write your rules below. dip(geoip:private) -> direct dip(geoip:cn) -> direct domain(geosite:cn) -> direct fallback: proxy } EOF sudo chmod 0600 /usr/local/etc/dae/config.dae # Do not forget to add your subscriptions and nodes. sudo vim /usr/local/etc/dae/config.dae # Enable and start dae. sudo systemctl enable --now dae.service # Exit dae vm. exit ``` -------------------------------- ### Control DAE Service (systemctl) Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md Use systemctl commands to manage the DAE service after installation on systems using systemd. This includes starting the service and enabling it to start automatically at boot. ```shell # start dae sudo systemctl start dae # auto start dae at boot sudo systemctl enable dae ``` -------------------------------- ### Interface IP Configuration Example Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/dae-with-opnsense.md Example IP address assignments for OPNsense and DAE interfaces to establish communication. Ensure the subnet for the DAE interface (wan_proxy) is different from OPNsense's LAN. ```text OPN LAN: 192.168.1.1/24 OPN wan_proxy: 192.168.2.2 Gateway Auto Detect dae enp1s0: 192.168.2.1 Gateway 192.168.2.2 ``` -------------------------------- ### Start dae Service Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-alpine.md Use the rc-service command to start the dae service once the configuration is ready. This command initiates the dae daemon. ```shell rc-service dae start ``` -------------------------------- ### Install DAE on Gentoo Linux Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md Install DAE on Gentoo Linux by enabling the gentoo-zh overlay, syncing repositories, and then emerging the package. ```shell eselect repository enable gentoo-zh emaint sync -r gentoo-zh emerge -a net-proxy/dae ``` -------------------------------- ### Install DAE on Arch Linux (archlinuxcn - Latest Git) Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md Install the latest development version of DAE from the archlinuxcn repository. ```shell sudo pacman -S dae-git ``` -------------------------------- ### Install Lima and socket_vmnet Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-macos.md Installs the Lima VM and socket_vmnet for network bridging using Homebrew. It also configures sudoers for socket_vmnet launching from Lima. ```shell # Install lima for VM and socket_vmnet for bridge. brew install lima socket_vmnet # Set up the sudoers file for launching socket_vmnet from Lima limactl sudoers >etc_sudoers.d_lima sudo install -o root etc_sudoers.d_lima /etc/sudoers.d/lima ``` -------------------------------- ### Enable Community Repository on Alpine Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-alpine.md Use the setup-apkrepos command and select 'c' to enable the community repository. This is a prerequisite for installing dae. ```shell (f) Find and use fastest mirror (s) Show mirrorlist (r) Use random mirror (e) Edit /etc/apk/repositories with text editor (c) Community repo enable (skip) Skip setting up apk repositories ``` -------------------------------- ### Install DAE on Arch Linux (Official Repository) Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md Install DAE using pacman from the official Arch Linux repository. This is the recommended method for Arch Linux users. ```shell sudo pacman -S dae ``` -------------------------------- ### Compile Dae with Minimal Dependencies Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/build-by-yourself.md Build the Dae project using minimal dependencies. Ensure you have clang and golang installed. ```shell make GOFLAGS="-buildvcs=false" \ CC=clang ``` -------------------------------- ### Install DAE on Arch Linux (archlinuxcn - Latest Release) Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md Install the latest release of DAE, optimized with AVX2 for x86-64 v3, from the archlinuxcn repository. ```shell sudo pacman -S dae-avx2-bin ``` -------------------------------- ### Install DAE on Arch Linux (AUR - Latest Git) Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md Install the latest development version of DAE from the AUR using an AUR helper like yay or paru. ```shell [yay/paru] -S dae-git ``` -------------------------------- ### Install DAE on Arch Linux (AUR - Latest Release) Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md Install the latest release of DAE, optimized with AVX2 for x86-64 v3, from the AUR using an AUR helper like yay or paru. ```shell [yay/paru] -S dae-avx2-bin ``` -------------------------------- ### Install Homebrew for ARM64 on macOS Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-macos.md Installs Homebrew for ARM64 architecture in the /opt/homebrew directory. This involves creating a directory, setting ownership, and extracting the Homebrew tarball. ```shell cd /opt sudo mkdir homebrew sudo chown $(whoami):admin homebrew curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew ``` -------------------------------- ### DAE DNS Configuration Example Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/dns.md This configuration block demonstrates how to set up DNS resolution preferences, fixed domain TTLs, and upstream DNS servers with various protocols. It also includes routing rules for DNS requests and responses. ```shell dns { # For example, if ipversion_prefer is 4 and the domain name has both type A and type AAAA records, the dae will only # respond to type A queries and response empty answer to type AAAA queries. ipversion_prefer: 4 # Give a fixed ttl for domains. Zero means that dae will request to upstream every time and not cache DNS results # for these domains. fixed_domain_ttl { ddns.example.org: 10 test.example.org: 3600 } # Bind to local address to listen for DNS queries #bind: '127.0.0.1:5353' upstream { # Scheme list: tcp, udp, tcp+udp, https, tls, http3, h3, quic, details see above Schema. # If host is a domain and has both IPv4 and IPv6 record, dae will automatically choose # IPv4 or IPv6 to use according to group policy (such as min latency policy). # Please make sure DNS traffic will go through and be forwarded by dae, which is REQUIRED for domain routing. # If dial_mode is "ip", the upstream DNS answer SHOULD NOT be polluted, so domestic public DNS is not recommended. alidns: 'udp://dns.alidns.com:53' googledns: 'tcp+udp://dns.google:53' # alih3: 'h3://dns.alidns.com:443' # alih3_path: 'h3://dns.alidns.com:443/dns-query' # alihttp3: 'http3://dns.alidns.com:443' # alihttp3_path: 'http3://dns.alidns.com:443/dns-query' # ali_quic: 'quic://dns.alidns.com:853' # h3_custom_path: 'h3://dns.example.com:443/custom-path' # http3_custom_path: 'http3://dns.example.com:443/custom-path' # ali_doh: 'https://dns.alidns.com:443' # ali_dot: 'tls://dns.alidns.com:853' # doh_custom_path: 'https://dns.example.com:443/custom-path' } # The routing format of 'request' and 'response' is similar with section 'routing'. # See https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/routing.md routing { # According to the request of dns query, decide to use which DNS upstream. # Match rules from top to bottom. request { # Built-in outbounds in 'request': asis, reject. # You can also use user-defined upstreams. # Available functions for ordinary DNS requests: qname, qtype. # Additional internal dae selectors in the same block: sub, node, subnode. # - sub(): subscription fetch requests # - node(): node host resolution requests # - subnode(): node host resolution requests for subscription-derived nodes # and it is checked before node() # Internal selectors: # - only affect dae's own DNS lookups # - must target names defined in dns.upstream # - do not use fallback # - cannot be mixed with qname/qtype in the same rule # DNS request name (omit suffix dot '.'). qname(geosite:category-ads-all) -> reject qname(geosite:google@cn) -> alidns # Also see: https://github.com/v2fly/domain-list-community#attributes qname(suffix: abc.com, keyword: google) -> googledns qname(full: ok.com, regex: '^yes') -> googledns # DNS request type qtype(a, aaaa) -> alidns qtype(cname) -> googledns # disable ECH to avoid affecting traffic split qtype(https) -> reject # Route dae's own subscription fetch DNS to googledns. # sub(my_sub) -> googledns # Route all nodes with "hk" in their name to googledns. # node(name_keyword: hk) -> googledns # Use alidns for nodes from subscription "my_sub" before node() rules are checked. # subnode(subtag: my_sub) -> alidns # If no match, fallback to this upstream. fallback: asis } # According to the response of dns query, decide to accept or re-lookup using another DNS upstream. # Match rules from top to bottom. response { # Built-in outbounds in 'response': accept, reject. # You can use user-defined upstreams. # Available functions: qname, qtype, upstream, ip. # Accept the response if the request is sent to upstream 'googledns'. This is useful to avoid loop. upstream(googledns) -> accept # If DNS request name is not in CN and response answers include private IP, which is most likely polluted # in China mainland. Therefore, resend DNS request to 'googledns' to get correct result. ip(geoip:private) && !qname(geosite:cn) -> googledns fallback: accept } } } ``` -------------------------------- ### Install Homebrew for x86 on macOS Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-macos.md Installs Homebrew package manager on macOS for x86 architecture. Refer to official documentation for detailed steps. ```shell /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" ``` -------------------------------- ### Install Kernel on RedHat/Fedora Linux Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/kernel-upgrade.md Installs the latest available kernel package using yum on RedHat-based systems. A reboot is required to activate the new kernel. ```bash sudo yum install kernel ``` ```bash sudo reboot uname -r ``` -------------------------------- ### Reboot and Verify Kernel Version Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/kernel-upgrade.md Reboot the system after kernel installation and then check the current kernel version using uname -r. ```bash sudo reboot ``` ```bash uname -r ``` -------------------------------- ### Mount BPF Filesystem Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-centos7.md Enables the BPF filesystem by enabling and starting a systemd service. This is necessary for eBPF functionality. ```bash curl -s https://repo.cooluc.com/kernel/files/sys-fs-bpf.mount > /etc/systemd/system/sys-fs-bpf.mount systemctl enable sys-fs-bpf.mount ``` -------------------------------- ### Commit Message Structure Example Source: https://github.com/daeuniverse/dae/blob/main/docs/en/development/commit-msg-guide.md Illustrates the breakdown of a semantic commit message, highlighting the type and summary. ```gitcommit feat: add hat wobble ^--^ ^------------^ | | | +-> Summary in present tense. | +-------> Type: chore, docs, feat, fix, refactor, style, or test. ``` -------------------------------- ### Verify DAE VM Setup Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-macos.md Verifies the network configuration by making a request to ipinfo.io from the macOS host, checking if the traffic is routed through the DAE VM. ```shell # Verify. curl -v ipinfo.io ``` -------------------------------- ### Install Specific Kernel on Debian-based Linux Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/kernel-upgrade.md Installs a specific Linux kernel image on Debian-based systems after updating package databases. Reboot required for changes to take effect. ```shell # Sync databases. sudo apt update # Search available kernel versions. apt-cache search ^linux-image # Install specific image. sudo apt install ``` ```shell sudo reboot uname -r ``` -------------------------------- ### Enable dae Service at Boot Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-alpine.md Add the dae service to the default runlevel using rc-update. This ensures that dae starts automatically when the system boots. ```shell rc-update add dae ``` -------------------------------- ### Set Permissions for dae Config File Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-alpine.md After installing dae, set the appropriate file permissions (640 or 600) for the configuration file located at /usr/local/etc/dae/config.dae. ```shell chmod 640 /usr/local/etc/dae/config.dae ``` -------------------------------- ### Build and Run DAE with Docker Compose Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md Clone the DAE repository and use Docker Compose to build the image and start DAE in detached mode. This is a convenient way to run DAE in a containerized environment. ```shell git clone --depth=1 https://github.com/daeuniverse/dae docker compose up -d --build ``` -------------------------------- ### Set Latest Kernel as Default Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-centos7.md Configures the GRUB bootloader to prioritize the newly installed kernel. This ensures the updated kernel is used on the next boot. ```bash grub2-set-default 0 ``` -------------------------------- ### Mount Control Group v2 Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-centos7.md Enables Control Group v2 support by installing and enabling a systemd service. This is a prerequisite for certain system functionalities. ```bash curl -s https://repo.cooluc.com/kernel/mount-cgroup2.service > /etc/systemd/system/mount-cgroup2.service systemctl enable mount-cgroup2.service ``` -------------------------------- ### Download Configuration File Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/run-as-daemon.md Download the sample dae configuration file to /etc/dae/config.dae. Ensure the file has restricted read permissions. ```bash mkdir -p /etc/dae curl -L -o /etc/dae/config.dae https://github.com/daeuniverse/dae/raw/main/example.dae chmod 600 /etc/dae/config.dae ``` -------------------------------- ### Run Go Tests for Configuration, DNS, Routing, and Dialer Components Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute unit tests for configuration, DNS, routing, and dialer components, followed by a full project test and a race detector test. ```bash go test ./config/... ./component/dns/... ./component/routing/... ./component/outbound/... ./control/... ./cmd/... go test ./... go test -race ./... ``` -------------------------------- ### Update Kernel on CentOS 7 Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-centos7.md Installs a custom kernel that supports eBPF and BBRv2. Ensure your system has `curl` and `yum` installed. ```bash curl -s https://repo.cooluc.com/mailbox.repo > /etc/yum.repos.d/mailbox.repo yum makecache yum update kernel ``` -------------------------------- ### Run Go Tests for Command, DNS, and Dialer Components Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute unit tests for command, DNS, and outbound dialer components, followed by a full project test and a race detector test. ```bash go test ./cmd/... ./component/dns/... ./component/outbound/... go test ./... go test -race ./... ``` -------------------------------- ### Minimal DAE Configuration Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md This is a minimal configuration for DAE to boot. For a working state, a more complete configuration is recommended. ```shell global{} routing{} ``` -------------------------------- ### Recommended Minimal DAE Configuration Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md A best-practice minimal configuration for DAE to be in a working state. Adjust interface names and subscription links as needed. ```shell global { # Bind to LAN and/or WAN as you want. Replace the interface name to your own. #lan_interface: docker0 wan_interface: auto # Use "auto" to auto detect WAN interface. log_level: info allow_insecure: false auto_config_kernel_parameter: true } subscription { # Fill in your subscription links here. } # See https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/dns.md for full examples. dns { upstream { googledns: 'tcp+udp://dns.google:53' alidns: 'udp://dns.alidns.com:53' } routing { request { qtype(https) -> reject fallback: alidns } response { upstream(googledns) -> accept ip(geoip:private) && !qname(geosite:cn) -> googledns fallback: accept } } } group { proxy { #filter: name(keyword: HK, keyword: SG) policy: min_moving_avg } } # See https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/routing.md for full examples. routing { pname(NetworkManager) -> direct dip(224.0.0.0/3, 'ff00::/8') -> direct ### Write your rules below. # Disable h3 because it usually consumes too much cpu/mem resources. l4proto(udp) && dport(443) -> block dip(geoip:private) -> direct dip(geoip:cn) -> direct domain(geosite:cn) -> direct fallback: proxy } ``` -------------------------------- ### Run Go Tests for Command and Project-Wide Components Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute unit tests specifically for command components, followed by a full project test and a race detector test. ```bash go test ./cmd/... go test ./... go test -race ./... ``` -------------------------------- ### Run DAE with Custom Configuration Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/separate-config.md Execute the DAE application using a specified configuration file. Ensure the path to the configuration file is correct. ```sh dae run -c /etc/dae/config.dae ``` -------------------------------- ### Build eBPF Components Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Build the eBPF components for the project. ```bash make ebpf ``` -------------------------------- ### Run Go Tests for Dialer and Control Components Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute unit tests for the outbound dialer and control components, followed by a full project test. ```bash go test ./component/outbound/... ./component/outbound/dialer/... ./control/... go test ./... ``` -------------------------------- ### Complex Combined Routing Rule Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/routing.md An example of a more complex rule combining domain matching with negation, useful for sophisticated traffic management. ```shell ### Little more complex rule domain(geosite:geolocation-!cn) && !domain(geosite:google-scholar, geosite:category-scholar-!cn, geosite:category-scholar-cn ) -> my_group ``` -------------------------------- ### Run Routine Unit Tests Source: https://github.com/daeuniverse/dae/blob/main/docs/en/development/contribute.md Execute routine unit tests for the project using the 'go test' command with the 'dae_stub_ebpf' tag. This command tests all packages within the current directory and its subdirectories. ```bash go test -tags dae_stub_ebpf ./... ``` -------------------------------- ### Mount bpf Filesystem in sysfs Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-alpine.md Modify the /etc/init.d/sysfs script to include the necessary logic for mounting the eBPF filesystem. Ensure the script format is correct to avoid service failures. ```shell # Setup Kernel Support for bpf file system if [ -d /sys/fs/bpf ] && ! mountinfo -q /sys/fs/bpf; then if grep -qs bpf /proc/filesystems; then ebegin "Mounting eBPF filesystem" mount -n -t bpf -o ${sysfs_opts} bpffs /sys/fs/bpf eend $? fi fi ``` -------------------------------- ### NOT Logic Routing Rules Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/routing.md Excludes traffic matching specific criteria using the '!' operator. This example blocks traffic to certain scholar domains. ```shell ### 'Not' rule !domain(geosite:google-scholar, geosite:category-scholar-!cn, geosite:category-scholar-cn ) -> my_group ``` -------------------------------- ### Download Runtime Dependencies Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/build-by-yourself.md Download the geoip.dat and geosite.dat files required for traffic splitting. These files are essential for Dae's runtime functionality. ```shell mkdir -p /usr/local/share/dae/ pushd /usr/local/share/dae/ curl -L -o geoip.dat https://github.com/v2fly/geoip/releases/latest/download/geoip.dat curl -L -o geosite.dat https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat popd ``` -------------------------------- ### Configure LAN Interface Kernel Parameters Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/kernel-parameters.md Enable IP forwarding and disable send redirects for a specific LAN interface. Replace 'docker0' with your actual LAN interface name. This is necessary for DAE to function correctly as a router or gateway. ```shell export lan_ifname=docker0 sudo tee /etc/sysctl.d/60-dae-lan-$lan_ifname.conf << EOF net.ipv4.conf.$lan_ifname.forwarding = 1 net.ipv6.conf.$lan_ifname.forwarding = 1 net.ipv4.conf.$lan_ifname.send_redirects = 0 EOF sudo sysctl --system ``` -------------------------------- ### Query GitHub Releases with jq Source: https://github.com/daeuniverse/dae/blob/main/CHANGELOGS.md This command fetches release information from the GitHub API for the daeuniverse/dae repository and uses jq to format the output, showing tag name, creation date, and prerelease status. ```bash curl --silent "https://api.github.com/repos/daeuniverse/dae/releases" | jq -r '.[] | {tag_name,created_at,prerelease}' ``` -------------------------------- ### Run eBPF Tests Source: https://github.com/daeuniverse/dae/blob/main/docs/en/development/contribute.md Execute eBPF specific tests for the project using the 'make' command. This is used for testing functionalities related to eBPF. ```bash make ebpf-test ``` -------------------------------- ### Include DAE Configuration Files Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/separate-config.md Use the 'include' directive to load other DAE configuration files. Paths are resolved relative to the entry config file's directory. Ensure included files are within the entry config directory for security. ```jsonc # config.dae # load all dae files placed in ./config.d/ include { # Relative path example: config.d/*.dae # Absolute path example: /etc/dae/config.d/*.dae } global { tproxy_port: 12345 log_level: warn tcp_check_url: 'http://cp.cloudflare.com' udp_check_dns: 'dns.google:53' check_interval: 600s check_tolerance: 50ms #lan_interface: eth0 wan_interface: eth0 allow_insecure: false dial_mode: domain disable_waiting_network: false auto_config_kernel_parameter: true sniffing_timeout: 30ms } ``` -------------------------------- ### Configure DAE VM with Lima Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-macos.md Sets up the Lima VM configuration for DAE, specifying image locations for x86_64 and aarch64, mounts, network interfaces, memory, and disk size. ```yaml # Configure dae vm. mkdir ~/.lima/dae/ cat << 'EOF' | tee ~/.lima/dae/lima.yaml images: - location: "https://cloud.debian.org/images/cloud/bookworm/daily/20230416-1352/debian-12-generic-amd64-daily-20230416-1352.qcow2" arch: "x86_64" digest: "sha512:8dcb07f213bbe7436744ce310252f53eb06d8d0a85378e4bdeb297e29d7f8b8af82b038519fabca84a75f188aa4e5586d21856d1bb09ab89aca70fd39be7c06b" - location: "https://cloud.debian.org/images/cloud/bookworm/daily/20230416-1352/debian-12-generic-arm64-daily-20230416-1352.qcow2" arch: "aarch64" digest: "sha512:88020fbde570e4bc773d6b05d810150b64fea007a2a18dfee835f1d73025bd2872300352e5cb1acb0bb4784c3c6765be1007880177f5319385d4fdf1d75e3ccf" mounts: networks: - lima: bridged interface: "lima0" memory: "1GB" disk: "3GiB" EOF ``` -------------------------------- ### Display Kernel Configuration Items Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md This command displays the kernel configuration items on your machine. DAE requires specific BPF and cgroup related configurations to be enabled. ```shell zcat /proc/config.gz || cat /boot/{config,config-$(uname -r)} ``` -------------------------------- ### DoQ Schema Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/dns.md Use this schema for DNS over QUIC configurations. The default port is 853. ```plaintext quic://: default port: 853 ``` -------------------------------- ### Run Routing and DNS Tests Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute tests for routing, DNS, control, outbound, and command-line components. This verifies the integrated functionality after changes to the routing layer. ```bash go test ./component/routing/... ./component/dns/... ./control/... ./component/outbound/... ./cmd/... ``` -------------------------------- ### Allowing Marked Traffic in firewalld Source: https://github.com/daeuniverse/dae/blob/main/docs/en/troubleshooting.md Execute this command to insert a rule into the `firewalld`'s INPUT chain to accept traffic marked with `0x8000000`. This command needs to be run on every boot or when firewall rules change. ```bash sudo nft 'insert rule inet firewalld filter_INPUT mark 0x8000000 accept' ``` -------------------------------- ### Script for Auto Route and DNS Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-macos.md Placeholder for a script that automates setting the default route and DNS on macOS to the DAE VM, intended to be executed automatically upon network changes. ```shell Write a script to execute. ``` -------------------------------- ### Run DAE Tests Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute tests for configuration and control packages. This command is used to verify the correctness of changes made in the control plane and configuration modules. ```bash go test ./config/... ./control/... ``` -------------------------------- ### Enable Global IPv4 and IPv6 Forwarding Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/kernel-parameters.md Globally enable IPv4 and IPv6 forwarding by creating a sysctl configuration file. This ensures that the system can route traffic between interfaces, which is essential for gateway functionality. ```shell echo "net.ipv4.ip_forward = 1" | sudo tee /etc/sysctl.d/60-ip-forward.conf echo "net.ipv6.conf.all.forwarding = 1" | sudo tee /etc/sysctl.d/60-ip-forward.conf sudo sysctl --system ``` -------------------------------- ### Clone Dae Repository Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/build-by-yourself.md Clone the official Dae repository to your local machine to begin the build process. ```shell git clone https://github.com/daeuniverse/dae.git cd dae git submodule update --init ``` -------------------------------- ### DAE DNS Configuration for Local External DNS Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/external-dns.md Configure the 'dns' section to use AdGuardHome as an upstream DNS server and set it as a fallback for requests when the external DNS is on localhost. ```toml dns { upstream { adguardhome: 'udp://127.0.0.1:53' } routing { request { fallback: adguardhome } } } ``` -------------------------------- ### Check Required Kernel Configurations (Fish) Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md This command is for the Fish shell to verify if the necessary kernel configurations for DAE are enabled. It filters the kernel configuration output for specific CONFIG options. ```fish begin; zcat /proc/config.gz || bat /boot/config "/boot/config-"(uname -r); end | grep -E 'CONFIG_(DEBUG_INFO|DEBUG_INFO_BTF|KPROBES|KPROBE_EVENTS|BPF|BPF_SYSCALL|BPF_JIT|BPF_STREAM_PARSER|NET_CLS_ACT|NET_SCH_INGRESS|NET_INGRESS|NET_EGRESS|NET_CLS_BPF|BPF_EVENTS|CGROUPS)=|# CONFIG_DEBUG_INFO_REDUCED is not set' ``` -------------------------------- ### Run Targeted Tests for Routing IR Implementation Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute tests for the introduction of a unified normalized rule IR in routing, focusing on optimizers, request rules, and router behavior. This command helps ensure that rule normalization does not cause semantic drift across backends. ```bash go test ./component/routing/... ./component/dns/... ./component/daedns/... ./control/... -run 'Routing|Rule|Matcher|Optimizer' ``` -------------------------------- ### Run Targeted Tests for ControlPlane Facade Refactoring Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute tests for refactoring the ControlPlane into a facade, focusing on datapath janitor, DNS runtime handoff, and reload/retirement/drain semantics. This command helps ensure that the ControlPlane splitting does not alter existing handoff semantics. ```bash go test ./control/... ./cmd/... -run 'ReuseDNS|Drain|Janitor|Shutdown|Retirement' ``` -------------------------------- ### Firewall Rule for Traffic Splitting Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/dae-with-opnsense.md Configure a floating firewall rule in OPNsense to direct specific traffic (defined by the 'proxyroute' alias) to the 'proxy' gateway. This rule should be set to 'Pass' and 'Quick' for efficient processing. ```text Action: Pass Quick: √ Interface: LAN Direction: in TCP/IP Version: IPv4 Protocol: TCP/UDP Destination/Invert: √ Destination: proxyroute Gateway: proxy ``` -------------------------------- ### Configure Routing Rules Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/separate-config.md Define routing rules based on process names, IP addresses, and domain names. Supports direct routing, fallback policies, and geoip/geosite lookups. ```jsonc # route.dae routing { pname(NetworkManager) -> direct dip(224.0.0.0/3, 'ff00::/8') -> direct dip(geoip:private) -> direct dip(1.14.5.14) -> direct domain(geosite:openai) -> local_group dip(geoip:cn) -> direct domain(geosite:cn) -> direct domain(geosite:category-scholar-cn) -> direct domain(geosite:geolocation-cn) -> direct fallback: my_group } ``` -------------------------------- ### Define DAE Nodes and Subscriptions Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/separate-config.md Configure individual nodes, subscription links, and group policies based on filters. Supports tag-based filtering and policy selection. ```jsonc # node.dae node { node1: 'xxx' node2: 'xxx' } subscription { my_sub: 'https://www.example.com/subscription/link' } group { my_group { filter: subtag(my_sub) && !name(keyword: 'ExpireAt:') policy: min_moving_avg } local_group { filter: name(node1, node2) policy: fixed(0) } } ``` -------------------------------- ### Configure DNS Settings Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/separate-config.md Define DNS upstream servers and routing rules for DNS requests and responses. Supports various protocols and fallback mechanisms. ```jsonc # dns.dae dns { upstream { alidns: 'udp://dns.alidns.com:53' googledns: 'tcp+udp://dns.google:53' } routing { request { qname(geosite:category-ads) -> reject qname(geosite:category-ads-all) -> reject fallback: alidns } response { upstream(googledns) -> accept !qname(geosite:cn) && ip(geoip:private) -> googledns fallback: accept } } } ``` -------------------------------- ### Enable CGroups Service on Alpine Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-alpine.md Add the 'cgroups' service to the boot runlevel using rc-update. This ensures cgroups are enabled on system startup. ```shell rc-update add cgroups boot ``` -------------------------------- ### Configure Lima Networks Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-macos.md Configures Lima's network settings to use socket_vmnet by updating the networks.yaml file with the correct path to the socket_vmnet binary. ```shell # Configure lima networks. socket_vmnet_bin=$(readlink -f ${HOMEBREW_PREFIX}/opt/socket_vmnet)/bin/socket_vmnet sed -ir "s#^ *socketVMNet:.*# socketVMNet: \"${socket_vmnet_bin}\"#" ~/.lima/_config/networks.yaml ``` -------------------------------- ### Check Required Kernel Configurations (Bash) Source: https://github.com/daeuniverse/dae/blob/main/docs/en/README.md Use this command in a Bash shell to verify if the necessary kernel configurations for DAE are enabled. It filters the kernel configuration output for specific CONFIG options. ```shell (zcat /proc/config.gz || cat /boot/{config,config-$(uname -r)}) | grep -E 'CONFIG_(DEBUG_INFO|DEBUG_INFO_BTF|KPROBES|KPROBE_EVENTS|BPF|BPF_SYSCALL|BPF_JIT|BPF_STREAM_PARSER|NET_CLS_ACT|NET_SCH_INGRESS|NET_INGRESS|NET_EGRESS|NET_CLS_BPF|BPF_EVENTS|CGROUPS)=|# CONFIG_DEBUG_INFO_REDUCED is not set' ``` -------------------------------- ### Verify Kernel Version Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-centos7.md Checks the currently running kernel version. A successful update should show a version like `6.1.xx-1.el7.x86_64`. ```bash uname -r ``` -------------------------------- ### Set Default Route and DNS on macOS Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-macos.md Configures the default route and DNS settings on the macOS host to point to the DAE VM's IP address. This command may need to be re-run after network changes. ```shell # Get IP of dae VM. dae_ip=$(limactl shell dae ip --json addr | limactl shell dae jq -cr '.[] | select( .ifname == "lima0" ).addr_info | .[] | select( .family == "inet" ).local') # Set gateway of macOS host to dae VM. sudo route delete default; sudo route add default $dae_ip # Set DNS of macOS host to dae VM. networksetup -setdnsservers Wi-Fi $dae_ip ``` -------------------------------- ### Allowing Marked Traffic in UFW Source: https://github.com/daeuniverse/dae/blob/main/docs/en/troubleshooting.md Add these rules to `/etc/ufw/before*.rules` to allow traffic marked with `0x8000000` through the UFW firewall. This is necessary when binding to WAN. ```bash # before.rules -A ufw-before-input -m mark --mark 0x8000000 -j ACCEPT ``` ```bash # before6.rules -A ufw6-before-input -m mark --mark 0x8000000 -j ACCEPT ``` -------------------------------- ### Reload dae Configuration Source: https://github.com/daeuniverse/dae/blob/main/docs/en/user-guide/reload-and-suspend.md Use this command to reload dae's configuration. This operation is faster than restarting and will not interrupt existing connections. It also updates all subscriptions simultaneously. ```shell dae reload ``` -------------------------------- ### OpenWRT WireGuard Interface Configuration Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/gaming-oriented-routing.md Set up a WireGuard VPN interface in OpenWRT. Ensure the MTU is carefully chosen, as CS2 requires MTU > 1300 due to UDP Ping. ```config config interface 'wg100' option proto 'wireguard' option private_key '[Client Private Key]' list addresses '10.7.0.2/24' list addresses 'fd42:42:42::2/64' option mtu '1420' config wireguard_wg100 option public_key '[Server Public Key]' option endpoint_host '[Your Server IP]' list allowed_ips '0.0.0.0/0' list allowed_ips '::/0' config route option interface 'wg100' option target '0.0.0.0/0' option gateway '10.7.0.1' option table '114' config route6 option interface 'wg100' option target '::/0' option gateway 'fd42:42:42::1' option table '114' config rule option lookup '114' option mark '0x800/0x800' config rule6 option lookup '114' option mark '0x800/0x800' ``` -------------------------------- ### AND Logic Routing Rules Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/routing.md Applies routing rules only when multiple conditions are met simultaneously using the '&&' operator. ```shell ### 'And' rule dip(geoip:cn) && dport(80) -> direct dip(8.8.8.8) && l4proto(tcp) && dport(1-1023, 8443) -> my_group dip(1.1.1.1) && sip(10.0.0.1, 172.20.0.0/16) -> direct ``` -------------------------------- ### Run Race Detector Tests for CLI and Control Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute tests with the race detector enabled for command-line and control modules. This is crucial for identifying concurrency bugs in these critical areas. ```bash go test -race ./cmd/... ./control/... ./component/dns/... ./component/outbound/... ./config/... ./pkg/config_parser/... ``` -------------------------------- ### Rebuild GRUB Configuration Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/run-on-centos7.md Updates the GRUB bootloader configuration file to reflect the default kernel setting. This command is essential after changing the default kernel. ```bash grub2-mkconfig -o /boot/grub2/grub.cfg ``` -------------------------------- ### Run All DAE Tests Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute all tests across the entire DAE project. This provides a comprehensive check of the system's integrity after significant changes. ```bash go test ./... ``` -------------------------------- ### DoH Schema Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/dns.md Use this schema for DNS over HTTPS configurations. The default port is 443 and the default path is /dns-query. ```plaintext https://:/ default port: 443 default path: /dns-query ``` -------------------------------- ### Static Route for OPNsense Proxy Traffic Source: https://github.com/daeuniverse/dae/blob/main/docs/en/tutorials/dae-with-opnsense.md Optional: Add a static route in OPNsense to direct specific IP segments through the 'proxy' gateway. This is useful for routing OPNsense's own traffic, like configuration backups, through the DAE proxy. ```text Add a static route rule in `System: Routes: Configuration`, set the gateway for the IP segment that needs to be proxied to proxy. ``` -------------------------------- ### Advanced DNS Routing with Response Handling Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/dns.md Configure DNS routing to use alidns for all queries, with fallback to googledns. Includes response-based routing to accept trusted upstream results or re-lookup based on IP and query name. ```hcl dns { upstream { googledns: 'tcp+udp://dns.google:53' alidns: 'udp://dns.alidns.com:53' } routing { request { fallback: alidns } response { upstream(googledns) -> accept ip(geoip:private) && !qname(geosite:cn) -> googledns fallback: accept } } } ``` -------------------------------- ### DAE Routing Rule for Local External DNS Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/external-dns.md Use this rule as the first line in the 'routing' section to prevent loops when an external DNS is on localhost. It specifically targets UDP traffic on port 53 from the AdGuardHome process. ```python pname(AdGuardHome) && l4proto(udp) && dport(53) -> must_direct ``` -------------------------------- ### Run DAE Race Detector Tests Source: https://github.com/daeuniverse/dae/blob/main/docs/zh/development/refactor-validation-plan.md Execute tests with the race detector enabled for control, component, and package modules. This helps identify concurrency issues. ```bash go test -race ./control/... ./component/dns/... ./component/outbound/... ./config/... ./pkg/config_parser/... ``` -------------------------------- ### DAE DNS Configuration for LAN External DNS Source: https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/external-dns.md Configure the 'dns' section to use AdGuardHome on a specific IP address as an upstream DNS server and set it as a fallback for requests when the external DNS is on another machine in the LAN. ```toml dns { upstream { adguardhome: 'udp://192.168.30.3:53' } routing { request { fallback: adguardhome } } } ```