Full Code of shadowsocks/shadowsocks-rust for AI

master ae80b84e2262 cached
282 files
3.3 MB
887.0k tokens
10153 symbols
1 requests
Download .txt
Showing preview only (3,542K chars total). Download the full file or copy to clipboard to get everything.
Repository: shadowsocks/shadowsocks-rust
Branch: master
Commit: ae80b84e2262
Files: 282
Total size: 3.3 MB

Directory structure:
gitextract_1sakp8po/

├── .circleci/
│   └── config.yml
├── .dockerignore
├── .github/
│   ├── dependabot.yml
│   └── workflows/
│       ├── build-and-test.yml
│       ├── build-docker-image.yml
│       ├── build-msrv.yml
│       ├── build-nightly-release.yml
│       ├── build-release.yml
│       ├── clippy-check.yml
│       └── deny-check.yml
├── .gitignore
├── .travis.yml
├── Cargo.toml
├── Cross-centos.toml
├── Cross.toml
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── acl/
│   └── genacl_proxy_gfw_bypass_china_ip.py
├── appveyor.yml
├── bin/
│   ├── sslocal.rs
│   ├── ssmanager.rs
│   ├── ssserver.rs
│   ├── ssservice.rs
│   ├── ssurl.rs
│   └── sswinservice.rs
├── build/
│   ├── README.md
│   ├── build-host-release
│   ├── build-host-release.ps1
│   └── build-release
├── cargo-publish.sh
├── clippy.toml
├── configs/
│   ├── genipset.py
│   ├── iptables_mixed.sh
│   ├── iptables_tproxy.sh
│   ├── log4rs.yaml
│   ├── org.shadowsocks.shadowsocks-rust.plist
│   └── shadowsocks.procd.sh
├── crates/
│   ├── shadowsocks/
│   │   ├── Cargo.toml
│   │   ├── LICENSE
│   │   ├── README.md
│   │   ├── src/
│   │   │   ├── config.rs
│   │   │   ├── context.rs
│   │   │   ├── dns_resolver/
│   │   │   │   ├── hickory_dns_resolver.rs
│   │   │   │   ├── mod.rs
│   │   │   │   └── resolver.rs
│   │   │   ├── lib.rs
│   │   │   ├── manager/
│   │   │   │   ├── client.rs
│   │   │   │   ├── datagram.rs
│   │   │   │   ├── error.rs
│   │   │   │   ├── listener.rs
│   │   │   │   ├── mod.rs
│   │   │   │   └── protocol.rs
│   │   │   ├── net/
│   │   │   │   ├── mod.rs
│   │   │   │   ├── option.rs
│   │   │   │   ├── sys/
│   │   │   │   │   ├── mod.rs
│   │   │   │   │   ├── unix/
│   │   │   │   │   │   ├── bsd/
│   │   │   │   │   │   │   ├── freebsd.rs
│   │   │   │   │   │   │   ├── macos.rs
│   │   │   │   │   │   │   ├── mod.rs
│   │   │   │   │   │   │   └── others.rs
│   │   │   │   │   │   ├── linux/
│   │   │   │   │   │   │   └── mod.rs
│   │   │   │   │   │   ├── mod.rs
│   │   │   │   │   │   ├── others.rs
│   │   │   │   │   │   └── uds.rs
│   │   │   │   │   └── windows/
│   │   │   │   │       └── mod.rs
│   │   │   │   ├── tcp.rs
│   │   │   │   └── udp.rs
│   │   │   ├── plugin/
│   │   │   │   ├── mod.rs
│   │   │   │   ├── obfs_proxy.rs
│   │   │   │   └── ss_plugin.rs
│   │   │   ├── relay/
│   │   │   │   ├── mod.rs
│   │   │   │   ├── socks5.rs
│   │   │   │   ├── tcprelay/
│   │   │   │   │   ├── aead.rs
│   │   │   │   │   ├── aead_2022.rs
│   │   │   │   │   ├── crypto_io.rs
│   │   │   │   │   ├── mod.rs
│   │   │   │   │   ├── proxy_listener.rs
│   │   │   │   │   ├── proxy_stream/
│   │   │   │   │   │   ├── client.rs
│   │   │   │   │   │   ├── mod.rs
│   │   │   │   │   │   ├── protocol/
│   │   │   │   │   │   │   ├── mod.rs
│   │   │   │   │   │   │   ├── v1.rs
│   │   │   │   │   │   │   └── v2.rs
│   │   │   │   │   │   └── server.rs
│   │   │   │   │   ├── stream.rs
│   │   │   │   │   └── utils.rs
│   │   │   │   └── udprelay/
│   │   │   │       ├── aead.rs
│   │   │   │       ├── aead_2022.rs
│   │   │   │       ├── compat.rs
│   │   │   │       ├── crypto_io.rs
│   │   │   │       ├── mod.rs
│   │   │   │       ├── options.rs
│   │   │   │       ├── proxy_socket.rs
│   │   │   │       └── stream.rs
│   │   │   └── security/
│   │   │       ├── mod.rs
│   │   │       └── replay/
│   │   │           ├── mod.rs
│   │   │           └── ppbloom.rs
│   │   └── tests/
│   │       ├── tcp.rs
│   │       ├── tcp_tfo.rs
│   │       └── udp.rs
│   └── shadowsocks-service/
│       ├── Cargo.toml
│       ├── README.md
│       └── src/
│           ├── acl/
│           │   ├── mod.rs
│           │   └── sub_domains_tree.rs
│           ├── config.rs
│           ├── dns/
│           │   └── mod.rs
│           ├── lib.rs
│           ├── local/
│           │   ├── context.rs
│           │   ├── dns/
│           │   │   ├── client_cache.rs
│           │   │   ├── config.rs
│           │   │   ├── dns_resolver.rs
│           │   │   ├── mod.rs
│           │   │   ├── server.rs
│           │   │   └── upstream.rs
│           │   ├── fake_dns/
│           │   │   ├── manager.rs
│           │   │   ├── mod.rs
│           │   │   ├── processor.rs
│           │   │   ├── proto.rs
│           │   │   ├── server.rs
│           │   │   ├── tcp_server.rs
│           │   │   └── udp_server.rs
│           │   ├── http/
│           │   │   ├── config.rs
│           │   │   ├── http_client.rs
│           │   │   ├── http_service.rs
│           │   │   ├── http_stream.rs
│           │   │   ├── mod.rs
│           │   │   ├── server.rs
│           │   │   ├── tokio_rt.rs
│           │   │   └── utils.rs
│           │   ├── loadbalancing/
│           │   │   ├── mod.rs
│           │   │   ├── ping_balancer.rs
│           │   │   ├── server_data.rs
│           │   │   └── server_stat.rs
│           │   ├── mod.rs
│           │   ├── net/
│           │   │   ├── mod.rs
│           │   │   ├── tcp/
│           │   │   │   ├── auto_proxy_io.rs
│           │   │   │   ├── auto_proxy_stream.rs
│           │   │   │   ├── listener.rs
│           │   │   │   └── mod.rs
│           │   │   └── udp/
│           │   │       ├── association.rs
│           │   │       ├── listener.rs
│           │   │       └── mod.rs
│           │   ├── online_config/
│           │   │   ├── content_encoding.rs
│           │   │   └── mod.rs
│           │   ├── redir/
│           │   │   ├── mod.rs
│           │   │   ├── redir_ext.rs
│           │   │   ├── server.rs
│           │   │   ├── sys/
│           │   │   │   ├── mod.rs
│           │   │   │   └── unix/
│           │   │   │       ├── bsd_pf.rs
│           │   │   │       ├── mod.rs
│           │   │   │       ├── pfvar_bindgen_freebsd.rs
│           │   │   │       ├── pfvar_bindgen_macos.rs
│           │   │   │       └── pfvar_bindgen_openbsd.rs
│           │   │   ├── tcprelay/
│           │   │   │   ├── mod.rs
│           │   │   │   └── sys/
│           │   │   │       ├── mod.rs
│           │   │   │       ├── unix/
│           │   │   │       │   ├── bsd.rs
│           │   │   │       │   ├── linux.rs
│           │   │   │       │   ├── mod.rs
│           │   │   │       │   └── not_supported.rs
│           │   │   │       └── windows/
│           │   │   │           └── mod.rs
│           │   │   └── udprelay/
│           │   │       ├── mod.rs
│           │   │       └── sys/
│           │   │           ├── mod.rs
│           │   │           ├── unix/
│           │   │           │   ├── freebsd.rs
│           │   │           │   ├── linux.rs
│           │   │           │   ├── macos.rs
│           │   │           │   ├── mod.rs
│           │   │           │   ├── not_supported.rs
│           │   │           │   └── openbsd.rs
│           │   │           └── windows/
│           │   │               └── mod.rs
│           │   ├── socks/
│           │   │   ├── client/
│           │   │   │   ├── mod.rs
│           │   │   │   ├── socks4/
│           │   │   │   │   ├── mod.rs
│           │   │   │   │   └── tcp_client.rs
│           │   │   │   └── socks5/
│           │   │   │       ├── mod.rs
│           │   │   │       ├── tcp_client.rs
│           │   │   │       └── udp_client.rs
│           │   │   ├── config.rs
│           │   │   ├── mod.rs
│           │   │   ├── server/
│           │   │   │   ├── mod.rs
│           │   │   │   ├── server.rs
│           │   │   │   ├── socks4/
│           │   │   │   │   ├── mod.rs
│           │   │   │   │   └── tcprelay.rs
│           │   │   │   └── socks5/
│           │   │   │       ├── mod.rs
│           │   │   │       ├── tcprelay.rs
│           │   │   │       └── udprelay.rs
│           │   │   └── socks4.rs
│           │   ├── tun/
│           │   │   ├── fake_tun.rs
│           │   │   ├── ip_packet.rs
│           │   │   ├── mod.rs
│           │   │   ├── tcp.rs
│           │   │   ├── udp.rs
│           │   │   └── virt_device.rs
│           │   ├── tunnel/
│           │   │   ├── mod.rs
│           │   │   ├── server.rs
│           │   │   ├── tcprelay.rs
│           │   │   └── udprelay.rs
│           │   └── utils.rs
│           ├── manager/
│           │   ├── mod.rs
│           │   └── server.rs
│           ├── net/
│           │   ├── flow.rs
│           │   ├── launch_activate_socket.rs
│           │   ├── mod.rs
│           │   ├── mon_socket.rs
│           │   ├── mon_stream.rs
│           │   ├── packet_window.rs
│           │   └── utils.rs
│           ├── server/
│           │   ├── context.rs
│           │   ├── mod.rs
│           │   ├── server.rs
│           │   ├── tcprelay.rs
│           │   └── udprelay.rs
│           ├── sys/
│           │   ├── mod.rs
│           │   └── unix/
│           │       ├── macos.rs
│           │       └── mod.rs
│           └── utils.rs
├── debian/
│   ├── .gitignore
│   ├── changelog
│   ├── compat
│   ├── config.json
│   ├── control
│   ├── copyright
│   ├── install
│   ├── rules
│   ├── shadowsocks-rust-local@.service
│   ├── shadowsocks-rust-server@.service
│   ├── shadowsocks-rust.default
│   ├── shadowsocks-rust.init
│   ├── shadowsocks-rust.postinst
│   ├── shadowsocks-rust.service
│   └── source/
│       └── format
├── deny.toml
├── docker/
│   ├── Dockerfile.v2ray
│   ├── docker-entrypoint.sh
│   └── linux-cross/
│       └── Dockerfile
├── examples/
│   ├── config.json
│   └── config_ext.json
├── homebrew/
│   └── shadowsocks-rust.rb
├── k8s/
│   ├── chart/
│   │   ├── .helmignore
│   │   ├── Chart.yaml
│   │   ├── templates/
│   │   │   ├── NOTES.txt
│   │   │   ├── _helpers.tpl
│   │   │   ├── config.yaml
│   │   │   ├── deployment.yaml
│   │   │   ├── hpa.yaml
│   │   │   ├── service.yaml
│   │   │   ├── serviceaccount.yaml
│   │   │   └── tests/
│   │   │       └── test-connection.yaml
│   │   └── values.yaml
│   └── shadowsocks-rust.yaml
├── rustfmt.toml
├── selinux/
│   ├── README.md
│   ├── shadowsocks.fc
│   └── shadowsocks.te
├── snap/
│   └── snapcraft.yaml
├── src/
│   ├── allocator/
│   │   └── mod.rs
│   ├── config.rs
│   ├── daemonize/
│   │   ├── daemonize/
│   │   │   ├── error.rs
│   │   │   └── mod.rs
│   │   ├── mod.rs
│   │   └── unix.rs
│   ├── error.rs
│   ├── lib.rs
│   ├── logging/
│   │   ├── log4rs.rs
│   │   ├── mod.rs
│   │   └── tracing.rs
│   ├── monitor/
│   │   ├── mod.rs
│   │   ├── other.rs
│   │   ├── unix.rs
│   │   └── windows.rs
│   ├── password.rs
│   ├── service/
│   │   ├── genkey.rs
│   │   ├── local.rs
│   │   ├── manager.rs
│   │   ├── mod.rs
│   │   └── server.rs
│   ├── sys.rs
│   └── vparser/
│       └── mod.rs
└── tests/
    ├── dns.rs
    ├── http.rs
    ├── socks4.rs
    ├── socks5.rs
    ├── tunnel.rs
    └── udp.rs

================================================
FILE CONTENTS
================================================

================================================
FILE: .circleci/config.yml
================================================
version: 2.1

orbs:
    windows: circleci/windows@5.1.1

jobs:
    build-linux:
        docker:
            - image: circleci/rust:stretch

        environment:
            OPENSSL_STATIC: "1"
            OPENSSL_LIB_DIR: "/usr/lib/x86_64-linux-gnu/"
            OPENSSL_INCLUDE_DIR: "/usr/include/x86_64-linux-gnu/"
            RUSTFLAGS: "-Ctarget-feature=+aes,+ssse3"

        steps:
            - checkout
            - run:
                  name: "APT Install Dependencies"
                  command: |
                      sudo apt-get update
                      sudo apt-get install -y build-essential
            - run:
                  name: "Generate Cargo.lock"
                  command: |
                      rustc --version >rust-version
                      test -e Cargo.lock || cargo generate-lockfile
            - restore_cache:
                  key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }}
            - run:
                  name: "Build Release"
                  command: BUILD_EXTRA_FEATURES="openssl-vendored local-redir" ./build-host-release
                  no_output_timeout: 1h
            - save_cache:
                  paths:
                      - /usr/local/cargo/registry
                      - ./target
                  key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }}

    build-windows:
        executor: windows/default

        environment:
            OPENSSL_STATIC: "1"
            OPENSSL_DIR: "C:\\OpenSSL"
            RUSTFLAGS: "-Ctarget-feature=+aes,+ssse3"
            CARGO_NET_GIT_FETCH_WITH_CLI: "true"

        steps:
            - checkout
            - run:
                  name: "Install Rust"
                  command: |
                      $ProgressPreference = "SilentlyContinue"
                      Invoke-WebRequest -Uri "https://win.rustup.rs/" -OutFile "C:\rustup-init.exe"
                      & C:\rustup-init.exe -y --default-toolchain "stable-x86_64-pc-windows-msvc" --no-modify-path --profile minimal

                      $env:Path += ";C:\Users\circleci\.cargo\bin"
                      rustc -Vv
                      cargo --version

                      rustc --version | Out-File -FilePath "rust-version"
                      if (!(Test-Path "Cargo.lock" -PathType Leaf)) {
                          cargo generate-lockfile
                      }
            - run:
                  name: "Install OpenSSL"
                  command: |
                      $env:Path += ";C:\Users\circleci\.cargo\bin"

                      $TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | foreach {$_.Matches.Value}).split()[-1]
                      if ($TargetTriple.StartsWith("x86_64-")) {
                          $OpenSSLBits = "64"
                      } else {
                          $OpenSSLBits = "32"
                      }
                      $OpenSSLVersion = "1_1_0L"
                      $OpenSSLFileName = "Win${OpenSSLBits}OpenSSL-${OpenSSLVersion}.exe"

                      $ProgressPreference = "SilentlyContinue"
                      Invoke-WebRequest -Uri "http://slproweb.com/download/${OpenSSLFileName}" -OutFile "${OpenSSLFileName}"
                      Write-Host "* Done downloading ${OpenSSLFileName}"
                      dir
                      Start-Process "${OpenSSLFileName}" -ArgumentList "/SILENT /VERYSILENT /SP- /SUPPRESSMSGBOXES /DIR=C:\OpenSSL" -Wait
                      Write-Host "* Done installing ${OpenSSLFileName}"
            - restore_cache:
                  key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }}
            # - run: ./build-host-release
            - run:
                  name: "Package Release"
                  command: |
                      $ProgressPreference = "SilentlyContinue"
                      $env:Path += ";C:\Users\circleci\.cargo\bin;."

                      $PackageReleasePath = "${PWD}\build\release"

                      Pushd target\release
                      $Version = (sslocal -V).split()[-1]
                      $TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | foreach {$_.Matches.Value}).split()[-1]
                      $PackageName = "shadowsocks-v${Version}.${TargetTriple}.zip"
                      $PackagePath = "${PackageReleasePath}\${PackageName}"

                      Write-Host "${Version}"
                      Write-Host "${TargetTriple}"
                      Write-Host "${PackagePath}"

                      New-Item "${PackageReleasePath}" -ItemType Directory -ErrorAction SilentlyContinue
                      $CompressParam = @{
                          LiteralPath = "sslocal.exe", "ssserver.exe", "ssurl.exe", "ssmanager.exe"
                          DestinationPath = "${PackagePath}"
                      }
                      Compress-Archive @CompressParam
                      Popd

                      $PackageChecksumPath = "${PackagePath}.sha256"
                      $PackageHash = (Get-FileHash -Path "${PackagePath}" -Algorithm SHA256).Hash
                      "${PackageHash}  ${PackageName}" | Out-File -FilePath "${PackageChecksumPath}"
            - save_cache:
                  paths:
                      - C:\Users\circleci\.cargo\registry
                      - target
                  key: cargo-cache-{{ arch }}-{{ checksum "rust-version" }}-{{ checksum "Cargo.lock" }}
            - store_artifacts:
                  path: build\\release
                  destination: releases
            - persist_to_workspace:
                  root: build
                  paths:
                      - release

    build-docker:
        machine:
            image: ubuntu-1604:201903-01
            docker_layer_caching: true

        steps:
            - checkout
            - run:
                  name: "APT Install Dependencies"
                  command: |
                      sudo apt-get update
                      sudo apt-get install curl
            - run:
                  name: "Build docker images"
                  command: |
                      cd build
                      docker build -t shadowsocks-rust:x86_64-pc-windows-gnu -f Dockerfile.x86_64-pc-windows-gnu .
                      docker build -t shadowsocks-rust:x86_64-unknown-linux-musl -f Dockerfile.x86_64-unknown-linux-musl .
                      docker build -t shadowsocks-rust:x86_64-unknown-linux-gnu -f Dockerfile.x86_64-unknown-linux-gnu .
                      docker build -t shadowsocks-rust:arm-unknown-linux-gnueabihf -f Dockerfile.arm-unknown-linux-gnueabihf .
                      docker build -t shadowsocks-rust:arm-unknown-linux-musleabi -f Dockerfile.arm-unknown-linux-musleabi .
                      docker build -t shadowsocks-rust:aarch64-unknown-linux-gnu -f Dockerfile.aarch64-unknown-linux-gnu .
            - run:
                  name: "Install Rust"
                  command: |
                      curl "https://sh.rustup.rs" -o "rust-init.sh"
                      chmod +x "rust-init.sh"
                      ./rust-init.sh -y --default-toolchain stable --no-modify-path --profile minimal
                      export PATH="$HOME/.cargo/bin:$PATH"
                      echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> $BASH_ENV
                      rustup --version
                      cargo --version
                      rustc --version
            - restore_cache:
                  key: cargo-cache-{{ arch }}
            - run: cargo install cross
            - run:
                  name: "Build Releases"
                  command: |
                      cd build
                      ./build-release
                  no_output_timeout: 2h
            - save_cache:
                  paths:
                      - /usr/local/cargo/registry
                      - ./target
                  key: cargo-cache-{{ arch }}
            - store_artifacts:
                  path: ./build/release
                  destination: releases
            - persist_to_workspace:
                  root: build
                  paths:
                      - release

    publish-github-releases:
        docker:
            - image: circleci/golang:1.17
        steps:
            - attach_workspace:
                  at: /tmp/workspace
            - run:
                  name: "Publish Release on GitHub"
                  command: |
                      ls -alh /tmp/workspace/release

                      if [[ ! -z "${CIRCLE_TAG}" ]]; then
                          go get github.com/tcnksm/ghr
                          EXTRA_FLAGS="-replace"
                          if [[ "${CIRCLE_TAG}" == *"-alpha."* ]]; then
                              EXTRA_FLAGS="${EXTRA_FLAGS} -prerelease"
                          fi
                          ghr -t "${GITHUB_TOKEN}" \
                              -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" \
                              -c "${CIRCLE_SHA1}" \
                              ${EXTRA_FLAGS} \
                              "${CIRCLE_TAG}" /tmp/workspace/release
                      else
                          echo "Current build is not tagged."
                      fi

workflows:
    version: 2
    build-releases:
        jobs:
            - build-linux:
                  filters:
                      tags:
                          only: /^v\d+\.\d+\.\d+(-alpha\.\d+)?$/
            - build-windows:
                  filters:
                      tags:
                          only: /^v\d+\.\d+\.\d+(-alpha\.\d+)?$/
            - build-docker:
                  filters:
                      branches:
                          ignore: /.*/
                      tags:
                          only: /^v\d+\.\d+\.\d+(-alpha\.\d+)?$/
            - publish-github-releases:
                  requires:
                      - build-windows
                      - build-docker
                  filters:
                      branches:
                          ignore: /.*/
                      tags:
                          only: /^v\d+\.\d+\.\d+(-alpha\.\d+)?$/


================================================
FILE: .dockerignore
================================================
**/.git
.circleci
.devcontainer
.github
.ssh
.vscode
**/target
dev


================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: cargo
  directory: "/"
  schedule:
    interval: weekly
  open-pull-requests-limit: 0


================================================
FILE: .github/workflows/build-and-test.yml
================================================
name: Build & Test

on: [push, pull_request]

env:
  CARGO_TERM_COLOR: always
  RUST_LOG: "trace"

jobs:
  build-and-test:
    strategy:
      matrix:
        platform:
          - ubuntu-latest
          - windows-latest
          - macos-latest
    runs-on: ${{ matrix.platform }}

    steps:
      - if: ${{ matrix.platform == 'ubuntu-latest' }}
        name: Free Disk Space (Ubuntu)
        uses: jlumbroso/free-disk-space@main
      - uses: actions/checkout@v6
      - uses: Swatinem/rust-cache@v2
      - if: ${{ runner.os == 'Windows' }}
        uses: ilammy/setup-nasm@v1
      - if: ${{ matrix.platform == 'ubuntu-latest' }}
        name: Install LLVM and Clang
        run: sudo apt update && sudo apt install -y clang
      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install stable
          rustup default stable
          rustup override set stable
      - name: Build & Test (Default)
        run: cargo test --verbose --no-fail-fast
      - name: Build & Test (full)
        run: cargo test --features "full" --verbose --no-fail-fast
      - name: Build & Test (full-extra)
        run: cargo test --features "full-extra" --verbose --no-fail-fast
      - name: Build & Test (Default) - shadowsocks
        run: cargo test --manifest-path ./crates/shadowsocks/Cargo.toml --verbose --no-fail-fast
      - name: Build & Test (Default) - shadowsocks-service
        run: cargo test --manifest-path ./crates/shadowsocks-service/Cargo.toml --verbose --no-fail-fast
      - name: Build & Test (--no-default-features)
        run: cargo test --verbose --no-default-features --no-fail-fast
      - name: Build & Test (--no-default-features) - shadowsocks
        run: cargo test --manifest-path ./crates/shadowsocks/Cargo.toml --verbose --no-default-features --no-fail-fast
      - name: Build & Test (--no-default-features) - shadowsocks-service
        run: cargo test --manifest-path ./crates/shadowsocks-service/Cargo.toml --verbose --no-default-features --no-fail-fast
      - name: Build with All Features Enabled (Unix)
        if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
        run: cargo build --verbose --features "full-extra local-flow-stat utility-url-outline"
      - name: Build with All Features Enabled (Windows)
        if: ${{ runner.os == 'Windows' }}
        run: cargo build --verbose --features "full-extra local-flow-stat utility-url-outline winservice"
      - name: Build with All Features Enabled - shadowsocks
        run: cargo build --manifest-path ./crates/shadowsocks/Cargo.toml --verbose --features "stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect"


================================================
FILE: .github/workflows/build-docker-image.yml
================================================
name: Build Docker Images
on:
  push:
    tags:
      - v*
  workflow_dispatch:

jobs:
  build-docker-image:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        bin:
          - ssserver
          - sslocal
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      - name: Setup Docker Buildx
        uses: docker/setup-buildx-action@v4
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Docker metadata
        id: metadata
        uses: docker/metadata-action@v6
        with:
          images: ghcr.io/${{ github.repository_owner }}/${{ matrix.bin }}-rust
      - name: Build and release Docker images
        uses: docker/build-push-action@v7
        with:
          platforms: linux/386,linux/amd64,linux/arm64/v8
          target: ${{ matrix.bin }}
          tags: ${{ steps.metadata.outputs.tags }}
          push: true


================================================
FILE: .github/workflows/build-msrv.yml
================================================
name: Build MSRV

on: [push, pull_request]

env:
  CARGO_TERM_COLOR: always
  RUST_LOG: "trace"

jobs:
  build-msrv-shadowsocks-rust:
    strategy:
      matrix:
        platform:
          - ubuntu-latest
          - windows-latest
          - macos-latest
    runs-on: ${{ matrix.platform }}

    steps:
      - if: ${{ matrix.platform == 'ubuntu-latest' }}
        name: Free Disk Space (Ubuntu)
        uses: jlumbroso/free-disk-space@main
      - if: ${{ matrix.platform == 'ubuntu-latest' }}
        name: Install LLVM and Clang
        run: sudo apt update && sudo apt install -y clang
      - uses: actions/checkout@v6
      - uses: Swatinem/rust-cache@v2
      - if: ${{ runner.os == 'Windows' }}
        uses: ilammy/setup-nasm@v1
      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install 1.88
          rustup default 1.88
          rustup override set 1.88
      - name: Build with All Features Enabled (Unix)
        if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
        run: cargo build --verbose --features "full-extra local-flow-stat utility-url-outline"
      - name: Build with All Features Enabled (Windows)
        if: ${{ runner.os == 'Windows' }}
        run: cargo build --verbose --features "full-extra local-flow-stat utility-url-outline winservice"

  build-msrv-shadowsocks-service:
    strategy:
      matrix:
        platform:
          - ubuntu-latest
          - windows-latest
          - macos-latest
    runs-on: ${{ matrix.platform }}

    steps:
      - if: ${{ matrix.platform == 'ubuntu-latest' }}
        name: Free Disk Space (Ubuntu)
        uses: jlumbroso/free-disk-space@main
      - if: ${{ matrix.platform == 'ubuntu-latest' }}
        name: Install LLVM and Clang
        run: sudo apt update && sudo apt install -y clang
      - uses: actions/checkout@v6
      - uses: Swatinem/rust-cache@v2
      - if: ${{ runner.os == 'Windows' }}
        uses: ilammy/setup-nasm@v1
      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install 1.88
          rustup default 1.88
          rustup override set 1.88
      - name: Build with All Features Enabled
        run: cargo build --manifest-path crates/shadowsocks-service/Cargo.toml --verbose --features "full dns-over-tls dns-over-https dns-over-h3 local-dns local-flow-stat local-http-rustls local-tun local-fake-dns local-online-config stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect"

  build-msrv-shadowsocks:
    strategy:
      matrix:
        platform:
          - ubuntu-latest
          - windows-latest
          - macos-latest
    runs-on: ${{ matrix.platform }}

    steps:
      - if: ${{ matrix.platform == 'ubuntu-latest' }}
        name: Free Disk Space (Ubuntu)
        uses: jlumbroso/free-disk-space@main
      - if: ${{ matrix.platform == 'ubuntu-latest' }}
        name: Install LLVM and Clang
        run: sudo apt update && sudo apt install -y clang
      - uses: actions/checkout@v6
      - uses: Swatinem/rust-cache@v2
      - if: ${{ runner.os == 'Windows' }}
        uses: ilammy/setup-nasm@v1
      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install 1.88
          rustup default 1.88
          rustup override set 1.88
      - name: Build with All Features Enabled
        run: cargo build --manifest-path crates/shadowsocks/Cargo.toml --verbose --features "stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect"


================================================
FILE: .github/workflows/build-nightly-release.yml
================================================
name: Build Nightly Releases
on:
  push:
    branches: [master]
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  build-nightly-cross:
    runs-on: ubuntu-latest
    env:
      RUST_BACKTRACE: full
    strategy:
      fail-fast: false
      matrix:
        platform:
          - target: x86_64-unknown-linux-gnu
            toolchain: stable
          - target: x86_64-unknown-linux-musl
            toolchain: stable
          - target: aarch64-unknown-linux-gnu
            toolchain: stable
          - target: aarch64-unknown-linux-musl
            toolchain: stable
          - target: mips-unknown-linux-gnu
            toolchain: nightly
          - target: mipsel-unknown-linux-gnu
            toolchain: nightly
          - target: mips64el-unknown-linux-gnuabi64
            toolchain: nightly
          - target: x86_64-unknown-freebsd
            toolchain: stable
          - target: x86_64-unknown-netbsd
            toolchain: stable
          - target: loongarch64-unknown-linux-gnu
            toolchain: stable
          - target: loongarch64-unknown-linux-musl
            toolchain: stable
          - target: powerpc-unknown-linux-gnu
            toolchain: stable
          - target: powerpc64-unknown-linux-gnu
            toolchain: stable
          - target: powerpc64le-unknown-linux-gnu
            toolchain: stable
          - target: riscv64gc-unknown-linux-gnu
            toolchain: stable
          - target: riscv64gc-unknown-linux-musl
            toolchain: stable
          - target: aarch64-linux-android
            toolchain: stable
          - target: x86_64-linux-android
            toolchain: stable

    steps:
      - name: Free Disk Space (Ubuntu)
        uses: jlumbroso/free-disk-space@main

      - name: Install LLVM and Clang
        run: sudo apt update && sudo apt install -y clang

      - uses: actions/checkout@v6

      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install ${{ matrix.platform.toolchain }}
          rustup default ${{ matrix.platform.toolchain }}
          rustup override set ${{ matrix.platform.toolchain }}

      - name: Install cross
        run: cargo install cross --git https://github.com/cross-rs/cross

      - name: Build ${{ matrix.platform.target }}
        timeout-minutes: 120
        run: |
          compile_target=${{ matrix.platform.target }}

          compile_features="-f full"

          if [[ "$compile_target" == *"-windows-"* ]]; then
            compile_features="$compile_features -f winservice"
          fi

          if [[ "$compile_target" == "mips-"* || "$compile_target" == "mipsel-"* || "$compile_target" == "mips64-"* || "$compile_target" == "mips64el-"* ]]; then
            sudo apt-get update -y && sudo apt-get install -y upx;
            if [[ "$?" == "0" ]]; then
              compile_compress="-u"
            fi

            compile_nightly="-n"
            #compile_cargo_flags="-Z build-std=std,panic_abort,proc_macro"
          fi

          cd build
          ./build-release -t ${{ matrix.platform.target }} $compile_features $compile_compress $compile_nightly $compile_cargo_flags

      - name: Upload Artifacts
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.platform.target }}
          path: build/release/*

  build-nightly-unix:
    runs-on: ${{ matrix.os }}
    env:
      BUILD_EXTRA_FEATURES: "full"
      RUST_BACKTRACE: full
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest]
        target:
          - x86_64-apple-darwin
          - aarch64-apple-darwin
    steps:
      - uses: actions/checkout@v6

      - name: Install GNU tar
        if: runner.os == 'macOS'
        run: |
          brew install gnu-tar
          # echo "::add-path::/usr/local/opt/gnu-tar/libexec/gnubin"
          echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH

      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install stable
          rustup default stable
          rustup override set stable
          rustup target add --toolchain stable ${{ matrix.target }}

      - name: Build release
        shell: bash
        run: |
          ./build/build-host-release -t ${{ matrix.target }}

      - name: Upload Artifacts
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.target }}
          path: build/release/*

  build-nightly-windows:
    runs-on: windows-latest
    env:
      RUSTFLAGS: "-C target-feature=+crt-static"
      RUST_BACKTRACE: full
    steps:
      - uses: actions/checkout@v6
      - uses: ilammy/setup-nasm@v1

      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install stable
          rustup default stable
          rustup override set stable

      - name: Build release
        run: |
          pwsh ./build/build-host-release.ps1 "full winservice"

      - name: Upload Artifacts
        uses: actions/upload-artifact@v7
        with:
          name: windows-native
          path: build/release/*


================================================
FILE: .github/workflows/build-release.yml
================================================
name: Build Releases
on:
  push:
    tags:
      - v*
  workflow_dispatch:
    inputs:
      tag:
        description: 'Release Tag'
        required: true
        type: string

env:
  CARGO_TERM_COLOR: always

jobs:
  build-release-cross:
    runs-on: ubuntu-latest
    env:
      RUST_BACKTRACE: full
    strategy:
      fail-fast: false
      matrix:
        platform:
          - target: i686-unknown-linux-musl
            toolchain: stable
          - target: x86_64-pc-windows-gnu
            toolchain: stable
          - target: x86_64-unknown-linux-gnu
            toolchain: stable
          - target: x86_64-unknown-linux-musl
            toolchain: stable
          - target: armv7-unknown-linux-musleabihf
            toolchain: stable
          - target: armv7-unknown-linux-gnueabihf
            toolchain: stable
          - target: arm-unknown-linux-gnueabi
            toolchain: stable
          - target: arm-unknown-linux-gnueabihf
            toolchain: stable
          - target: arm-unknown-linux-musleabi
            toolchain: stable
          - target: arm-unknown-linux-musleabihf
            toolchain: stable
          - target: aarch64-unknown-linux-gnu
            toolchain: stable
          - target: aarch64-unknown-linux-musl
            toolchain: stable
          - target: mips-unknown-linux-gnu
            toolchain: nightly
          # cross mips-*-musl images are disabled
          # - target: mips-unknown-linux-musl
          #   toolchain: nightly
          - target: mipsel-unknown-linux-gnu
            toolchain: nightly
          # - target: mipsel-unknown-linux-musl
          #   toolchain: nightly
          # FIXME: ring doesn't support mips64 CPU
          # - target: mips64-unknown-linux-gnuabi64
          #   toolchain: nightly
          # - target: mips64-unknown-linux-muslabi64
          #   toolchain: nightly
          - target: mips64el-unknown-linux-gnuabi64
            toolchain: nightly
          # FIXME: Link Error. 
          #   = note: mips64el-linux-muslsf-gcc: error: crt1.o: No such file or directory
          #           mips64el-linux-muslsf-gcc: error: crti.o: No such file or directory
          #           mips64el-linux-muslsf-gcc: error: crtbegin.o: No such file or directory
          #           mips64el-linux-muslsf-gcc: error: crtend.o: No such file or directory
          #           mips64el-linux-muslsf-gcc: error: crtn.o: No such file or directory
          # - target: mips64el-unknown-linux-muslabi64
          #   toolchain: nightly
          - target: x86_64-unknown-freebsd
            toolchain: stable
          - target: x86_64-unknown-netbsd
            toolchain: stable
          - target: loongarch64-unknown-linux-gnu
            toolchain: stable
          - target: loongarch64-unknown-linux-musl
            toolchain: stable
          - target: riscv64gc-unknown-linux-gnu
            toolchain: stable
          - target: riscv64gc-unknown-linux-musl
            toolchain: stable
          - target: aarch64-linux-android
            toolchain: stable
          - target: x86_64-linux-android
            toolchain: stable

    steps:
      - name: Free Disk Space (Ubuntu)
        uses: jlumbroso/free-disk-space@main

      - name: Install LLVM and Clang
        run: sudo apt update && sudo apt install -y clang

      - uses: actions/checkout@v6

      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install ${{ matrix.platform.toolchain }}
          rustup default ${{ matrix.platform.toolchain }}
          rustup override set ${{ matrix.platform.toolchain }}

      - name: Install cross
        run: cargo install cross --git https://github.com/cross-rs/cross

      - name: Build ${{ matrix.platform.target }}
        timeout-minutes: 120
        run: |
          compile_target=${{ matrix.platform.target }}

          compile_features="-f full"

          if [[ "$compile_target" == *"-windows-"* ]]; then
            compile_features="$compile_features -f winservice"
          fi

          if [[ "$compile_target" == "mips-"* || "$compile_target" == "mipsel-"* || "$compile_target" == "mips64-"* || "$compile_target" == "mips64el-"* ]]; then
            sudo apt-get update -y && sudo apt-get install -y upx;
            if [[ "$?" == "0" ]]; then
              compile_compress="-u"
            fi

            compile_nightly="-n"
            #compile_cargo_flags="-Z build-std=std,panic_abort,proc_macro"
          fi

          cd build
          ./build-release -t ${{ matrix.platform.target }} $compile_features $compile_compress $compile_nightly $compile_cargo_flags

      - name: Upload Github Assets
        uses: softprops/action-gh-release@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          files: build/release/*
          prerelease: ${{ contains(github.ref_name, '-') }}
          tag_name: ${{ inputs.tag || github.ref_name }}

  build-release-unix:
    runs-on: ${{ matrix.os }}
    env:
      BUILD_EXTRA_FEATURES: "full"
      RUST_BACKTRACE: full
    strategy:
      fail-fast: false
      matrix:
        # os: [ubuntu-latest, macos-latest]
        os: [macos-latest]
        target:
          - x86_64-apple-darwin
          - aarch64-apple-darwin
    steps:
      - uses: actions/checkout@v6

      - name: Install GNU tar
        if: runner.os == 'macOS'
        run: |
          brew install gnu-tar
          # echo "::add-path::/usr/local/opt/gnu-tar/libexec/gnubin"
          echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH

      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install stable
          rustup default stable
          rustup override set stable
          rustup target add --toolchain stable ${{ matrix.target }}

      - name: Build release
        shell: bash
        run: |
          ./build/build-host-release -t ${{ matrix.target }}

      - name: Upload Github Assets
        uses: softprops/action-gh-release@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          files: build/release/*
          prerelease: ${{ contains(github.ref_name, '-') }}
          tag_name: ${{ inputs.tag || github.ref_name }}

  build-release-windows:
    runs-on: windows-latest
    env:
      RUSTFLAGS: "-C target-feature=+crt-static"
      RUST_BACKTRACE: full
    steps:
      - uses: actions/checkout@v6
      - uses: ilammy/setup-nasm@v1

      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install stable
          rustup default stable
          rustup override set stable

      - name: Build release
        run: |
          pwsh ./build/build-host-release.ps1 "full winservice"

      - name: Upload Github Assets
        uses: softprops/action-gh-release@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          files: build/release/*
          prerelease: ${{ contains(github.ref_name, '-') }}
          tag_name: ${{ inputs.tag || github.ref_name }}


================================================
FILE: .github/workflows/clippy-check.yml
================================================
name: Clippy Check

on: [push, pull_request]

env:
  CARGO_TERM_COLOR: always
  RUST_LOG: "trace"

jobs:
  clippy-check:
    strategy:
      matrix:
        platform:
          - ubuntu-latest
          - windows-latest
          - macos-latest
    runs-on: ${{ matrix.platform }}

    steps:
      - uses: actions/checkout@v6
      - uses: Swatinem/rust-cache@v2
      - if: ${{ runner.os == 'Windows' }}
        uses: ilammy/setup-nasm@v1
      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install stable --component clippy
      - name: Clippy Check
        uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: |
            --features "full-extra local-flow-stat utility-url-outline"
            -- -A clippy::absurd_extreme_comparisons
          name: clippy ${{ matrix.platform }}


================================================
FILE: .github/workflows/deny-check.yml
================================================
name: Cargo Deny Check
on: [push, pull_request]
jobs:
  deny-check:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        checks:
          - advisories
          - bans licenses sources

    # Prevent sudden announcement of a new advisory from failing ci:
    continue-on-error: ${{ matrix.checks == 'advisories' }}

    steps:
    - uses: actions/checkout@v6
    - uses: EmbarkStudios/cargo-deny-action@v2
      with:
        command: check ${{ matrix.checks }}


================================================
FILE: .gitignore
================================================
target
/build/release
/build/target
/build/install
/build/*.sha256
/dev
/*.log
/debian/*.log
/.vscode
/*.json
/restart.sh
/udp_echo_server.py
/.idea
/.devcontainer
.DS_Store


================================================
FILE: .travis.yml
================================================
sudo: false
language: rust
jobs:
  include:
    - os: windows
      rust: stable

    - os: osx
      rust: stable
      osx_image: xcode11.3
      env: SODIUM_USE_PKG_CONFIG=1

    - os: linux
      rust: stable
      dist: bionic
      env: SODIUM_USE_PKG_CONFIG=1
    - os: linux
      rust: beta
      dist: bionic
      env: SODIUM_USE_PKG_CONFIG=1
    - os: linux
      rust: nightly
      dist: bionic
      env: SODIUM_USE_PKG_CONFIG=1

  allow_failures:
    # FIXME: Travis build success but tests crash
    - os: osx
    - os: windows

env:
  - RUSTFLAGS="-Ctarget-feature=+aes,+ssse3" RUSTDOCFLAGS="-Ctarget-feature=+aes,+ssse3" RUST_BACKTRACE=1

addons:
  apt:
    packages:
      - libssl-dev
      - libsodium-dev
  homebrew:
    packages:
      - libsodium

install:
  # Install OpenSSL on Windows
  - if [ "${TRAVIS_OS_NAME}" = "windows" ]; then
    curl -Lo "openssl-1.0.2c-win64-mingw.zip" "https://dl.bintray.com/vszakats/generic/openssl-1.0.2c-win64-mingw.zip";
    unzip "openssl-1.0.2c-win64-mingw.zip" -d "/c/OpenSSL";
    export OPENSSL_LIB_DIR=/c/OpenSSL/openssl-1.0.2c-win64-mingw;
    export OPENSSL_INCLUDE_DIR=/c/OpenSSL/openssl-1.0.2c-win64-mingw/include;
    export OPENSSL_DIR=/c/OpenSSL/openssl-1.0.2c-win64-mingw;
    fi
  # - if [ "${TRAVIS_OS_NAME}" = "windows" ]; then
  #   choco install openssl;
  #   export OPENSSL_DIR='/c/Program Files/OpenSSL-Win64/';
  #   export OPENSSL_STATIC=1;
  #   fi

script:
  - cargo test --no-fail-fast
  # - cargo test --no-fail-fast --no-default-features
  # - cargo test --no-fail-fast --features aes-pmac-siv
  # - cargo test --no-fail-fast --features single-threaded
  # - cargo test --no-fail-fast --features openssl-vendored
  # - cargo test --no-fail-fast --no-default-features --features "local-http local-http-rustls"
  - if [ "${TRAVIS_OS_NAME}" = "linux" -o "${TRAVIS_OS_NAME}" = "osx" ]; then
    cargo test --no-fail-fast --features local-redir;
    fi

# cache: cargo


================================================
FILE: Cargo.toml
================================================
[package]
name = "shadowsocks-rust"
version = "1.24.0"
authors = ["Shadowsocks Contributors"]
description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls."
repository = "https://github.com/shadowsocks/shadowsocks-rust"
readme = "README.md"
documentation = "https://docs.rs/shadowsocks-rust"
keywords = ["shadowsocks", "proxy", "socks", "socks5", "firewall"]
license = "MIT"
edition = "2024"
rust-version = "1.88"

[badges]
maintenance = { status = "passively-maintained" }

[[bin]]
name = "sslocal"
path = "bin/sslocal.rs"
required-features = ["local"]

[[bin]]
name = "ssserver"
path = "bin/ssserver.rs"
required-features = ["server"]

[[bin]]
name = "ssurl"
path = "bin/ssurl.rs"
required-features = ["utility"]

[[bin]]
name = "ssmanager"
path = "bin/ssmanager.rs"
required-features = ["manager"]

[[bin]]
name = "ssservice"
path = "bin/ssservice.rs"
required-features = ["service"]

[[bin]]
name = "sswinservice"
path = "bin/sswinservice.rs"
required-features = ["winservice"]

[workspace]
members = ["crates/shadowsocks", "crates/shadowsocks-service"]

[profile.release]
lto = "fat"
codegen-units = 1
incremental = false
panic = "abort"
strip = true

[features]
default = ["full"]

# Basic Features
basic = [
    "logging",
    "hickory-dns",
    "local",
    "server",
    "multi-threaded",
    "aead-cipher",
]

# All Suggested Features
full = [
    "logging",
    "hickory-dns",
    "dns-over-tls",
    "dns-over-https",
    "local",
    "server",
    "manager",
    "utility",
    "service",
    "local-http",
    "local-http-rustls",
    "local-tunnel",
    "local-socks4",
    "local-dns",
    "local-redir",
    "local-tun",
    "local-online-config",
    "multi-threaded",
    "stream-cipher",
    "aead-cipher",
    "aead-cipher-2022",
]

# Full features with extra (non-stable)
full-extra = [
    "full",
    "dns-over-h3",
    "local-fake-dns",
    "aead-cipher-extra",
    "aead-cipher-2022-extra",
    "security-replay-attack-detect",
]

# Enable local server
local = ["shadowsocks-service/local"]
# Enable remote server
server = ["shadowsocks-service/server"]
# Enable manager server
manager = ["shadowsocks-service/manager"]
# Enable utility
utility = ["qrcode"]
# Enable service
service = ["local", "server", "manager"]
# Enable Windows Service
winservice = ["service", "windows-service"]

# Enables Hickory-DNS for replacing tokio's builtin DNS resolver
hickory-dns = ["shadowsocks-service/hickory-dns"]
# Hickory-DNS was renamed from Trust-DNS, keep compatibility.
trust-dns = ["hickory-dns"]
dns-over-tls = ["shadowsocks-service/dns-over-tls"]
dns-over-https = ["shadowsocks-service/dns-over-https"]
dns-over-h3 = ["shadowsocks-service/dns-over-h3"]

# Enable logging output
logging = [
    "log4rs",
    "tracing",
    "tracing-subscriber",
    "time",
    "tracing-appender",
    "tracing-syslog",
]

# Enable DNS-relay
local-dns = ["local", "shadowsocks-service/local-dns"]
# Enable client flow statistic report
# Currently is only used in Android
local-flow-stat = ["local", "shadowsocks-service/local-flow-stat"]
# Enable HTTP protocol for sslocal
local-http = ["local", "shadowsocks-service/local-http"]
local-http-native-tls = [
    "local-http",
    "shadowsocks-service/local-http-native-tls",
]
local-http-native-tls-vendored = [
    "local-http",
    "shadowsocks-service/local-http-native-tls-vendored",
]
local-http-rustls = ["local-http", "shadowsocks-service/local-http-rustls"]
# Enable REDIR protocol for sslocal
# (transparent proxy)
local-redir = ["local", "shadowsocks-service/local-redir"]
# Enable tunnel protocol for sslocal
local-tunnel = ["local", "shadowsocks-service/local-tunnel"]
# Enable socks4 protocol for sslocal
local-socks4 = ["local", "shadowsocks-service/local-socks4"]
# Enable Tun interface protocol for sslocal
local-tun = ["local", "shadowsocks-service/local-tun", "ipnet"]
# Enable Fake DNS for sslocal
local-fake-dns = ["local", "shadowsocks-service/local-fake-dns", "ipnet"]
# sslocal support online URL (SIP008 Online Configuration Delivery)
# https://shadowsocks.org/doc/sip008.html
local-online-config = ["local", "shadowsocks-service/local-online-config"]

# ssurl support outline (ssconf) URL
utility-url-outline = ["reqwest"]

# Enable jemalloc for binaries
jemalloc = ["jemallocator"]
# Enable bundled tcmalloc
tcmalloc-vendored = ["tcmalloc/bundled"]

# Enable snmalloc for binaries
snmalloc = ["snmalloc-rs"]

# Enable tokio's multi-threaded runtime
multi-threaded = ["tokio/rt-multi-thread"]

# Enable Stream Cipher Protocol
# WARN: Stream Cipher Protocol is proved to be insecure
# https://github.com/shadowsocks/shadowsocks-rust/issues/373
# Users should always avoid using these ciphers in practice
stream-cipher = ["shadowsocks-service/stream-cipher"]

# Enable AEAD ciphers
aead-cipher = ["shadowsocks-service/aead-cipher"]

# Enable extra AEAD ciphers
# WARN: These non-standard AEAD ciphers are not officially supported by shadowsocks community
aead-cipher-extra = ["aead-cipher", "shadowsocks-service/aead-cipher-extra"]

# Enable AEAD 2022
aead-cipher-2022 = ["shadowsocks-service/aead-cipher-2022"]
# Enable AEAD 2022 with extra ciphers
aead-cipher-2022-extra = ["shadowsocks-service/aead-cipher-2022-extra"]

# Enable detection against replay attack (Stream / AEAD)
security-replay-attack-detect = [
    "shadowsocks-service/security-replay-attack-detect",
]
replay-attack-detect = [
    "security-replay-attack-detect",
] # Backward compatibility. DO NOT USE.

# Logging to syslog (Unix only)
tracing-syslog = ["dep:syslog-tracing"]

[dependencies]
log = "0.4"
log4rs = { version = "1.2", optional = true }
tracing = { version = "0.1", optional = true }
tracing-subscriber = { version = "0.3", optional = true, features = [
    "std",
    "fmt",
    "env-filter",
    "time",
    "local-time",
] }
tracing-appender = { version = "0.2.3", optional = true, default-features = false }
syslog-tracing = { version = "0.3", optional = true }
time = { version = "0.3", optional = true }

serde = { version = "1.0", features = ["derive"] }
json5 = "1.3"
thiserror = "2.0"
base64 = "0.22"

clap = { version = "4.5", features = ["wrap_help", "suggestions"] }
cfg-if = "1"
qrcode = { version = "0.14", default-features = false, optional = true }
sysexits = "0.13"
build-time = "0.1"
directories = "6.0"
rpassword = "7.3"
libc = { version = "0.2", features = ["extra_traits"] }
rand = "0.10"

futures = "0.3"
tokio = { version = "1", features = ["rt", "signal"] }

ipnet = { version = "2.10", optional = true }
reqwest = { version = "0.13", features = ["blocking"], optional = true }

mimalloc = { version = "0.1", default-features = false, optional = true }
tcmalloc = { version = "0.3", optional = true }
jemallocator = { version = "0.5", optional = true }
snmalloc-rs = { version = "0.3", optional = true }
rpmalloc = { version = "0.2", optional = true }

shadowsocks-service = { version = "1.24.0", path = "./crates/shadowsocks-service", default-features = false }

windows-service = { version = "0.8", optional = true }

[target.'cfg(unix)'.dependencies]
xdg = "3.0"

[dev-dependencies]
byteorder = "1.5"
env_logger = "0.11"
byte_string = "1.0"
tokio = { version = "1", features = ["net", "time", "macros", "io-util"] }

[lints.clippy]
uninlined_format_args = "allow"


================================================
FILE: Cross-centos.toml
================================================
[build.env]
passthrough = ["RUSTFLAGS"]

# WARN: GCC 4.8.2 doesn't support <stdatomic.h>
[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main-centos"
# GCC 4.8.2 doesn't support ACLE
# https://github.com/briansmith/ring/issues/1728
# [target.aarch64-unknown-linux-gnu]
# image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main-centos"


================================================
FILE: Cross.toml
================================================
[build]
# dockerfile = "./docker/linux-cross/Dockerfile"
# pre-build = [
#     "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable",
#     ". $HOME/.cargo/env",
#     "cargo install --force --locked bindgen-cli && mv $HOME/.cargo/bin/bindgen /usr/bin",
#     "rm -rf $HOME/.cargo"
# ]
# pre-build = [
#     "apt update",
#     "apt install --assume-yes --no-install-recommends build-essential llvm-8-dev libclang-8-dev clang-8",
# ]

[build.env]
passthrough = ["RUSTFLAGS"]

# MIPS targets are dropped to Tier 3
# https://github.com/rust-lang/compiler-team/issues/648
# FIXME: build-std with sequence is supported only on git
[target.mips-unknown-linux-gnu]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mips-unknown-linux-musl]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mips64-unknown-linux-gnuabi64]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mips64-unknown-linux-muslabi64]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mips64el-unknown-linux-gnuabi64]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mips64el-unknown-linux-muslabi64]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mipsel-unknown-linux-gnu]
build-std = ["std", "panic_abort", "proc_macro"]
[target.mipsel-unknown-linux-musl]
build-std = ["std", "panic_abort", "proc_macro"]


================================================
FILE: Dockerfile
================================================
FROM --platform=$BUILDPLATFORM rust:1.94.0-alpine3.22 AS builder

ARG TARGETARCH

RUN set -x \
    && apk add --no-cache musl-dev

WORKDIR /root/shadowsocks-rust

ADD . .

RUN case "$TARGETARCH" in \
    "386") \
        RUST_TARGET="i686-unknown-linux-musl" \
        MUSL="i686-linux-musl" \
        SHA512="5047afc68170a2910895db2dfa448227e71a984bfa2130a1bc946fd1015d722b80b15e4abf90c64300815aa84fe781cc8b8a72f10174f9dce96169e035911880" \
    ;; \
    "amd64") \
        RUST_TARGET="x86_64-unknown-linux-musl" \
        MUSL="x86_64-linux-musl" \
        SHA512="52abd1a56e670952116e35d1a62e048a9b6160471d988e16fa0e1611923dd108a581d2e00874af5eb04e4968b1ba32e0eb449a1f15c3e4d5240ebe09caf5a9f3" \
    ;; \
    "arm64") \
        RUST_TARGET="aarch64-unknown-linux-musl" \
        MUSL="aarch64-linux-musl" \
        SHA512="8695ff86979cdf30fbbcd33061711f5b1ebc3c48a87822b9ca56cde6d3a22abd4dab30fdcd1789ac27c6febbaeb9e5bde59d79d66552fae53d54cc1377a19272" \
    ;; \
    *) \
        echo "Doesn't support $TARGETARCH architecture" \
        exit 1 \
    ;; \
    esac \
    && wget "https://github.com/AaronChen0/musl-cc-mirror/releases/download/2021-09-23/$MUSL-cross.tgz" \
    && ( echo "$SHA512" "$MUSL-cross.tgz" | sha512sum -c ) \
    && tar -xzf "$MUSL-cross.tgz" -C /root/ \
    && PATH="/root/$MUSL-cross/bin:$PATH" \
    && CC=/root/$MUSL-cross/bin/$MUSL-gcc \
    && echo "CC=$CC" \
    && rustup target add "$RUST_TARGET" \
    && RUSTFLAGS="-C linker=$CC" CC=$CC cargo build --target "$RUST_TARGET" --release --features "full" \
    && mv target/$RUST_TARGET/release/ss* target/release/

FROM alpine:3.23 AS sslocal

# NOTE: Please be careful to change the path of these binaries, refer to #1149 for more information.
COPY --from=builder /root/shadowsocks-rust/target/release/sslocal /usr/bin/
COPY --from=builder /root/shadowsocks-rust/examples/config.json /etc/shadowsocks-rust/
COPY --from=builder /root/shadowsocks-rust/docker/docker-entrypoint.sh /usr/bin/

ENTRYPOINT [ "docker-entrypoint.sh" ]
CMD [ "sslocal", "--log-without-time", "-c", "/etc/shadowsocks-rust/config.json" ]

FROM alpine:3.23 AS ssserver

COPY --from=builder /root/shadowsocks-rust/target/release/ssserver /usr/bin/
COPY --from=builder /root/shadowsocks-rust/examples/config.json /etc/shadowsocks-rust/
COPY --from=builder /root/shadowsocks-rust/docker/docker-entrypoint.sh /usr/bin/

ENTRYPOINT [ "docker-entrypoint.sh" ]

CMD [ "ssserver", "--log-without-time", "-a", "nobody", "-c", "/etc/shadowsocks-rust/config.json" ]

================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2017 Y. T. CHUNG <zonyitoo@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


================================================
FILE: Makefile
================================================
PREFIX ?= /usr/local/bin
TARGET ?= debug

.PHONY: all build install uninstall clean
all: build

build:
ifeq (${TARGET}, release)
	cargo build --release --features "full"
else
	cargo build --features "full"
endif

install:
	install -d ${DESTDIR}${PREFIX}
	install -m 755 target/${TARGET}/sslocal ${DESTDIR}${PREFIX}/sslocal
	install -m 755 target/${TARGET}/ssserver ${DESTDIR}${PREFIX}/ssserver
	install -m 755 target/${TARGET}/ssurl ${DESTDIR}${PREFIX}/ssurl
	install -m 755 target/${TARGET}/ssmanager ${DESTDIR}${PREFIX}/ssmanager
	install -m 755 target/${TARGET}/ssservice ${DESTDIR}${PREFIX}/ssservice

uninstall:
	rm ${DESTDIR}${PREFIX}/sslocal
	rm ${DESTDIR}${PREFIX}/ssserver
	rm ${DESTDIR}${PREFIX}/ssurl
	rm ${DESTDIR}${PREFIX}/ssmanager
	rm ${DESTDIR}${PREFIX}/ssservice

clean:
	cargo clean


================================================
FILE: README.md
================================================
# shadowsocks

[![License](https://img.shields.io/github/license/zonyitoo/shadowsocks-rust.svg)](https://github.com/zonyitoo/shadowsocks-rust)
[![Build & Test](https://github.com/shadowsocks/shadowsocks-rust/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/shadowsocks/shadowsocks-rust/actions/workflows/build-and-test.yml)
[![Build MSRV](https://github.com/shadowsocks/shadowsocks-rust/actions/workflows/build-msrv.yml/badge.svg)](https://github.com/shadowsocks/shadowsocks-rust/actions/workflows/build-msrv.yml)
[![Build Releases](https://github.com/shadowsocks/shadowsocks-rust/actions/workflows/build-release.yml/badge.svg?event=push)](https://github.com/shadowsocks/shadowsocks-rust/actions/workflows/build-release.yml)
[![Build Nightly Releases](https://github.com/shadowsocks/shadowsocks-rust/actions/workflows/build-nightly-release.yml/badge.svg)](https://github.com/shadowsocks/shadowsocks-rust/actions/workflows/build-nightly-release.yml)
[![Gurubase](https://img.shields.io/badge/Gurubase-Ask%20shadowsocks%20Guru-006BFF)](https://gurubase.io/g/shadowsocks)

[![crates.io](https://img.shields.io/crates/v/shadowsocks-rust.svg)](https://crates.io/crates/shadowsocks-rust)
[![Release](https://img.shields.io/github/release/shadowsocks/shadowsocks-rust.svg)](https://github.com/shadowsocks/shadowsocks-rust/releases)
[![shadowsocks-rust](https://img.shields.io/archlinux/v/extra/x86_64/shadowsocks-rust)](https://archlinux.org/packages/extra/x86_64/shadowsocks-rust/)
[![aur shadowsocks-rust-git](https://img.shields.io/aur/version/shadowsocks-rust-git)](https://aur.archlinux.org/packages/shadowsocks-rust-git)
[![NixOS](https://img.shields.io/badge/NixOS-shadowsocks--rust-blue?logo=nixos)](https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/sh/shadowsocks-rust/package.nix)
[![snap shadowsocks-rust](https://snapcraft.io/shadowsocks-rust/badge.svg)](https://snapcraft.io/shadowsocks-rust)
[![homebrew shadowsocks-rust](https://img.shields.io/homebrew/v/shadowsocks-rust)](https://formulae.brew.sh/formula/shadowsocks-rust#default)
[![MacPorts shadowsocks-rust](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fports.macports.org%2Fapi%2Fv1%2Fports%2Fshadowsocks-rust%2F&query=%24.version&label=macports)](https://ports.macports.org/port/shadowsocks-rust/)

This is a port of [shadowsocks](https://github.com/shadowsocks/shadowsocks).

shadowsocks is a fast tunnel proxy that helps you bypass firewalls.

| Library                                                                 | Description                                                                                                                                                                                                                                                 |
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [**shadowsocks**](https://crates.io/crates/shadowsocks)                 | [![crates.io](https://img.shields.io/crates/v/shadowsocks.svg)](https://crates.io/crates/shadowsocks) [![docs.rs](https://img.shields.io/docsrs/shadowsocks)](https://docs.rs/shadowsocks) shadowsocks core protocol                                        |
| [**shadowsocks-service**](https://crates.io/crates/shadowsocks-service) | [![crates.io](https://img.shields.io/crates/v/shadowsocks-service.svg)](https://crates.io/crates/shadowsocks-service) [![docs.rs](https://img.shields.io/docsrs/shadowsocks-service)](https://docs.rs/shadowsocks-service) Services for serving shadowsocks |
| [**shadowsocks-rust**](https://crates.io/crates/shadowsocks-rust)       | [![crates.io](https://img.shields.io/crates/v/shadowsocks-rust.svg)](https://crates.io/crates/shadowsocks-rust) Binaries running common shadowsocks services                                                                                                |

Related Projects:

- [spyophobia/shadowsocks-gtk-rs](https://github.com/spyophobia/shadowsocks-gtk-rs) A GUI on Linux for `sslocal` using GTK, [discussion](https://github.com/shadowsocks/shadowsocks-rust/issues/664)
- [honwen/openwrt-shadowsocks-rust](https://github.com/honwen/openwrt-shadowsocks-rust) OpenWRT solution for `sslocal`, [discussion](https://github.com/honwen/openwrt-shadowsocks-rust)
- [cg31/shadowsocks-windows-gui-rust](https://github.com/cg31/shadowsocks-windows-gui-rust) Windows GUI client, [discussion](https://github.com/shadowsocks/shadowsocks-rust/issues/375)

## Build & Install

### Optional Features

- `hickory-dns` - Uses [`hickory-resolver`](https://crates.io/crates/hickory-resolver) as DNS resolver instead of `tokio`'s builtin.

- `local-http` - Allow using HTTP protocol for `sslocal`

  - `local-http-native-tls` - Support HTTPS with [`native-tls`](https://crates.io/crates/native-tls)

  - `local-http-rustls` - Support HTTPS with [`rustls`](https://crates.io/crates/rustls)

- `local-tunnel` - Allow using tunnel protocol for `sslocal`

- `local-socks4` - Allow using SOCKS4/4a protocol for `sslocal`

- `local-redir` - Allow using redir (transparent proxy) protocol for `sslocal`

- `local-dns` - Allow using dns protocol for `sslocal`, serves as a DNS server proxying queries to local or remote DNS servers by ACL rules

- `local-fake-dns` - FakeDNS, allocating an IP address for each individual Query from a specific IP pool

- `local-tun` - [TUN](https://en.wikipedia.org/wiki/TUN/TAP) interface support for `sslocal`

- `local-online-config` - [SIP008](https://shadowsocks.org/doc/sip008.html) Online Configuration Delivery

- `stream-cipher` - Enable deprecated stream ciphers. WARN: stream ciphers are UNSAFE!

- `aead-cipher-extra` - Enable non-standard AEAD ciphers

- `aead-cipher-2022` - Enable AEAD-2022 ciphers ([SIP022](https://github.com/shadowsocks/shadowsocks-org/issues/196))

- `aead-cipher-2022-extra` - Enable AEAD-2022 extra ciphers (non-standard ciphers)

#### Memory Allocators

This project uses system (libc) memory allocator (Rust's default). But it also allows you to use other famous allocators by features:

- `jemalloc` - Uses [jemalloc](http://jemalloc.net/) as global memory allocator
- `mimalloc` - Uses [mi-malloc](https://microsoft.github.io/mimalloc/) as global memory allocator
- `tcmalloc` - Uses [TCMalloc](https://google.github.io/tcmalloc/overview.html) as global memory allocator. It tries to link system-wide tcmalloc by default, use vendored from source with `tcmalloc-vendored`.
- `snmalloc` - Uses [snmalloc](https://github.com/microsoft/snmalloc) as global memory allocator
- `rpmalloc` - Uses [rpmalloc](https://github.com/mjansson/rpmalloc) as global memory allocator

### **crates.io**

Install from [crates.io](https://crates.io/crates/shadowsocks-rust):

```bash
# Install from crates.io
cargo install shadowsocks-rust
```

then you can find `sslocal` and `ssserver` in `$CARGO_HOME/bin`.

### **Install using Homebrew**

For macOS and Linux, you can install it using [Homebrew](https://brew.sh/):

```bash
brew install shadowsocks-rust
```

### **Install using snap**

```bash
# Install from snapstore
snap install shadowsocks-rust

# List services
snap services shadowsocks-rust

# Enable and start shadowsocks-rust.sslocal-daemon snap service
snap start --enable shadowsocks-rust.sslocal-daemon

# Show generated systemd service status
systemctl status snap.shadowsocks-rust.sslocal-daemon.service

# Override generated systemd service (configure startup options)
systemctl edit snap.shadowsocks-rust.sslocal-daemon.service

## NOTE: you can pass args to sslocal:
##  [Service]
##  ExecStart=
##  ExecStart=/usr/bin/snap run shadowsocks-rust.sslocal-daemon -b "127.0.0.1:1080" --server-url "ss://...."

# Restart generated systemd service to apply changes
systemctl restart snap.shadowsocks-rust.sslocal-daemon.service

# ... and show service status
systemctl status snap.shadowsocks-rust.sslocal-daemon.service
```

Default configuration file path probably is `/var/snap/shadowsocks-rust/common/etc/shadowsocks-rust/config.json`.

### **Download release**

Download static-linked build [here](https://github.com/shadowsocks/shadowsocks-rust/releases).

- Most of them are built with [cross](https://github.com/cross-rs/cross). Build environment details could be found in its README, such as glibc's version.
- `x86_64-apple-darwin`, `aarch64-apple-darwin` are built in github's `macos-latest` image. Information could be found in [here](https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners).
- `x86_64-pc-windows-msvc` is built in github's `windows-latest` image. Information could be found in [here](https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners).

### **Docker**

This project provided Docker images for the `linux/i386` and `linux/amd64` and `linux/arm64/v8` architectures.

> :warning: **Docker containers do not have access to IPv6 by default**: Make sure to disable IPv6 Route in the client or [enable IPv6 access to docker containers](https://docs.docker.com/config/daemon/ipv6/#use-ipv6-for-the-default-bridge-network).

#### Pull from GitHub Container Registry

Docker will pull the image of the appropriate architecture from our [GitHub Packages](https://github.com/orgs/shadowsocks/packages?repo_name=shadowsocks-rust).

```bash
docker pull ghcr.io/shadowsocks/sslocal-rust:latest
docker pull ghcr.io/shadowsocks/ssserver-rust:latest
```

#### Build on the local machine(Optional)

If you want to build the Docker image yourself, you need to use the [BuildX](https://docs.docker.com/buildx/working-with-buildx/).

```bash
docker buildx build -t shadowsocks/ssserver-rust:latest -t shadowsocks/ssserver-rust:v1.15.2 --target ssserver .
docker buildx build -t shadowsocks/sslocal-rust:latest -t shadowsocks/sslocal-rust:v1.15.2 --target sslocal .
```

#### Run the container

You need to mount the configuration file into the container and create an external port map for the container to connect to it.

```bash
docker run --name sslocal-rust \
  --restart always \
  -p 1080:1080/tcp \
  -v /path/to/config.json:/etc/shadowsocks-rust/config.json \
  -dit ghcr.io/shadowsocks/sslocal-rust:latest

docker run --name ssserver-rust \
  --restart always \
  -p 8388:8388/tcp \
  -p 8388:8388/udp \
  -v /path/to/config.json:/etc/shadowsocks-rust/config.json \
  -dit ghcr.io/shadowsocks/ssserver-rust:latest
```

### **Deploy to Kubernetes**

This project provided yaml manifests for deploying to Kubernetes.

You can leverage k8s Service to expose traffic outside, like LoadBalancer or NodePort which gains more fine-grained compared with fixed host or port.

For a more interesting use case, you can use a Ingress(Istio, nginx, etc.) which routes the matched traffic to shadowsocks along with the real web service.

#### Using `kubectl`

`kubectl apply -f https://github.com/shadowsocks/shadowsocks-rust/raw/master/k8s/shadowsocks-rust.yaml`

You can change the config via editing the ConfigMap named `shadowsocks-rust`.

For more fine-grained control, use `helm`.

#### Using `helm`

`helm install my-release k8s/chart -f my-values.yaml`

Below is the common default values you can change:

```yaml
# This is the shadowsocks config which will be mount to /etc/shadowocks-rust.
# You can put arbitrary yaml here, and it will be translated to json before mounting.
servers:
- server: "::"
  server_port: 8388
  service_port: 80 # the k8s service port, default to server_port
  password: mypassword
  method: aes-256-gcm
  fast_open: true
  mode: tcp_and_udp
  # plugin: v2ray-plugin
  # plugin_opts: server;tls;host=github.com

# Whether to download v2ray and xray plugin.
downloadPlugins: false

# Name of the ConfigMap with config.json configuration for shadowsocks-rust.
configMapName: ""

service:
  # Change to LoadBalancer if you are behind a cloud provider like aws, gce, or tke.
  type: ClusterIP

# Bind shadowsocks port port to host, i.e., we can use host:port to access shawdowsocks server.
hostPort: false

replicaCount: 1

image:
  repository: ghcr.io/shadowsocks/ssserver-rust
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: "latest"
```

### **Build from source**

Use cargo to build. NOTE: **RAM >= 2GiB**

```bash
cargo build --release
```

Then `sslocal` and `ssserver` will appear in `./target/(debug|release)/`, it works similarly as the two binaries in the official ShadowSocks' implementation.

```bash
make install TARGET=release
```

Then `sslocal`, `ssserver`, `ssmanager` and `ssurl` will be installed to `/usr/local/bin` (variable PREFIX).

For Windows users, if you have encountered any problem in building, check and discuss in [#102](https://github.com/shadowsocks/shadowsocks-rust/issues/102).

### **target-cpu optimization**

If you are building for your current CPU platform (for example, build and run on your personal computer), it is recommended to set `target-cpu=native` feature to let `rustc` generate and optimize code for the CPU running the compiler.

```bash
export RUSTFLAGS="-C target-cpu=native"
```

### **Build standalone binaries**

Requirements:

- Docker

```bash
./build/build-release
```

Then `sslocal`, `ssserver`, `ssmanager`, `ssservice` and `ssurl` will be packaged in

- `./build/shadowsocks-${VERSION}-stable.x86_64-unknown-linux-musl.tar.xz`
- `./build/shadowsocks-${VERSION}-stable.x86_64-pc-windows-gnu.zip`

Read `Cargo.toml` for more details.

For Linux with low GLIBC versions, set `CROSS_CONFIG` to CentOS based image:

```bash
export CROSS_CONFIG=Cross-centos.toml
```

## Getting Started

Generate a safe and secured password for a specific encryption method (`aes-128-gcm` in the example) with:

```bash
ssservice genkey -m "aes-128-gcm"
```

Create a ShadowSocks' configuration file. Example

```jsonc
{
    "server": "my_server_ip",
    "server_port": 8388,
    "password": "rwQc8qPXVsRpGx3uW+Y3Lj4Y42yF9Bs0xg1pmx8/+bo=",
    "method": "aes-256-gcm",
    // ONLY FOR `sslocal`
    // Delete these lines if you are running `ssserver` or `ssmanager`
    "local_address": "127.0.0.1",
    "local_port": 1080
}
```

Detailed explanation of the configuration file could be found in [shadowsocks' documentation](https://github.com/shadowsocks/shadowsocks/wiki). (Link to original project, not maintained anymore !)

> :warning: For snap installations, configuration file is most probably located in `/var/snap/shadowsocks-rust/common/etc/shadowsocks-rust/config.json` (see <https://github.com/shadowsocks/shadowsocks-rust/issues/621> / <https://github.com/shadowsocks/shadowsocks-rust/issues/1146>)

In shadowsocks-rust, we also have an extended configuration file format, which is able to define more than one server. You can also disable individual servers.

```jsonc
{
    "servers": [
        {
            "server": "127.0.0.1",
            "server_port": 8388,
            "password": "rwQc8qPXVsRpGx3uW+Y3Lj4Y42yF9Bs0xg1pmx8/+bo=",
            "method": "aes-256-gcm",
            "timeout": 7200
        },
        {
            "server": "127.0.0.1",
            "server_port": 8389,
            "password": "/dliNXn5V4jg6vBW4MnC1I8Jljg9x7vSihmk6UZpRBM=",
            "method": "chacha20-ietf-poly1305"
        },
        {
            "disabled": true,
            "server": "eg.disable.me",
            "server_port": 8390,
            "password": "mGvbWWay8ueP9IHnV5F1uWGN2BRToiVCAWJmWOTLU24=",
            "method": "chacha20-ietf-poly1305"
        }
    ],
    // ONLY FOR `sslocal`
    // Delete these lines if you are running `ssserver` or `ssmanager`
    "local_port": 1080,
    "local_address": "127.0.0.1"
}
```

`sslocal` automatically selects the best server with the lowest latency and the highest availability.

Start Shadowsocks client and server with:

```bash
sslocal -c config.json
ssserver -c config.json
```

If you Build it with Cargo:

```bash
cargo run --bin sslocal -- -c config.json
cargo run --bin ssserver -- -c config.json
```

List all available arguments with `-h`.

## Usage

Start local client with configuration file

```bash
# Read local client configuration from file
sslocal -c /path/to/shadowsocks.json
```

### Socks5 Local client

```bash
# Pass all parameters via command line
sslocal -b "127.0.0.1:1080" -s "[::1]:8388" -m "aes-256-gcm" -k "hello-kitty" --plugin "v2ray-plugin" --plugin-opts "server;tls;host=github.com"

# Pass server with SIP002 URL
sslocal -b "127.0.0.1:1080" --server-url "ss://YWVzLTI1Ni1nY206cGFzc3dvcmQ@127.0.0.1:8388/?plugin=v2ray-plugin%3Bserver%3Btls%3Bhost%3Dgithub.com"
```

### HTTP Local client

```bash
sslocal -b "127.0.0.1:3128" --protocol http -s "[::1]:8388" -m "aes-256-gcm" -k "hello-kitty"
```

All parameters are the same as Socks5 client, except `--protocol http`.

### Tunnel Local client

```bash
# Set 127.0.0.1:8080 as the target for forwarding to
sslocal --protocol tunnel -b "127.0.0.1:3128" -f "127.0.0.1:8080" -s "[::1]:8388" -m "aes-256-gcm" -k "hello-kitty"
```

- `--protocol tunnel` enables local client Tunnel mode
- `-f "127.0.0.1:8080` sets the tunnel target address

### Transparent Proxy Local client

**NOTE**: It currently only supports

- Linux (with `iptables` targets `REDIRECT` and `TPROXY`)
- BSDs (with `pf`), such as OS X 10.10+, FreeBSD, ...

```bash
sslocal -b "127.0.0.1:60080" --protocol redir -s "[::1]:8388" -m "aes-256-gcm" -k "hello-kitty" --tcp-redir "redirect" --udp-redir "tproxy"
```

Redirects connections with `iptables` configurations to the port that `sslocal` is listening on.

- `--protocol redir` enables local client Redir mode
- (optional) `--tcp-redir` sets TCP mode to `REDIRECT` (Linux)
- (optional) `--udp-redir` sets UDP mode to `TPROXY` (Linux)

### Tun interface client

**NOTE**: It currently only supports

- Linux, Android
- macOS, iOS
- Windows

#### Linux

Create a Tun interface with name `tun0`

```bash
ip tuntap add mode tun tun0
ifconfig tun0 inet 10.255.0.1 netmask 255.255.255.0 up
```

Start `sslocal` with `--protocol tun` and binds to `tun0`

```bash
sslocal --protocol tun -s "[::1]:8388" -m "aes-256-gcm" -k "hello-kitty" --outbound-bind-interface lo0 --tun-interface-name tun0
```

#### macOS

```bash
sslocal --protocol tun -s "[::1]:8388" -m "aes-256-gcm" -k "hello-kitty" --outbound-bind-interface lo0 --tun-interface-address 10.255.0.1/24
```

It will create a Tun interface with address `10.255.0.1` and netmask `255.255.255.0`.

#### Windows

Download `wintun.dll` from [Wintun](https://www.wintun.net/), and place it in the folder with shadowsocks' runnable binaries, or in the system PATH.

```powershell
sslocal --protocol tun -s "[::1]:8388" -m "aes-256-gcm" -k "hello-kitty" --outbound-bind-interface "Ethernet 0" --tun-interface-name "shadowsocks"
```

### Local client for Windows Service

Compile it by enabling `--features "winservice"` (not included in the default build):

```bash
cargo build --release --bin "sswinservice" --features "winservice"
```

Install it as a Windows Service (PowerShell):

```powershell
New-Service -Name "shadowsocks-local-service" `
            -DisplayName "Shadowsocks Local Service" `
            -BinaryPathName "<Path\to>\sswinservice.exe local -c <Path\to>\local_config.json"
```

There are other ways to install `sswinservice` as a Windows Service, for example, the `sc` command.

As you may have noticed that the `-BinaryPathName` contains not only just the `sswinservice.exe`, but `local -c local_config.json`. These command line parameters will be used as the default parameter when the Windows Service starts. You can also start the service with customized parameters.

Learn more from [Microsoft's Document](https://learn.microsoft.com/en-us/dotnet/framework/windows-services/introduction-to-windows-service-applications).

The `sswinservice`'s parameter works exactly the same as `ssservice`. It supports `local`, `server` and `manager` subcommands.

### Server

```bash
# Read server configuration from file
ssserver -c /path/to/shadowsocks.json

# Pass all parameters via command line
ssserver -s "[::]:8388" -m "aes-256-gcm" -k "hello-kitty" --plugin "v2ray-plugin" --plugin-opts "server;tls;host=github.com"
```

### Server Manager

Supported [Manage Multiple Users](https://github.com/shadowsocks/shadowsocks/wiki/Manage-Multiple-Users) API:

- `add` - Starts a server instance
- `remove` - Deletes an existing server instance
- `list` - Lists all current running servers
- `ping` - Lists all servers' statistic data

NOTE: `stat` command is not supported. Because servers are running in the same process with the manager itself.

```bash
# Start it just with --manager-address command line parameter
ssmanager --manager-address "127.0.0.1:6100"

# For *nix system, manager can bind to unix socket address
ssmanager --manager-address "/tmp/shadowsocks-manager.sock"

# You can also provide a configuration file
#
# `manager_address` key must be provided in the configuration file
ssmanager -c /path/to/shadowsocks.json

# Create one server by UDP
echo 'add: {"server_port":8388,"password":"hello-kitty"}' | nc -u '127.0.0.1' '6100'

# Close one server by unix socket
echo 'remove: {"server_port":8388}' | nc -Uu '/tmp/shadowsocks-manager.sock'
```

For manager UI, check more details in the [shadowsocks-manager](https://github.com/shadowsocks/shadowsocks-manager) project.

Example configuration:

```jsonc
{
    // Required option
    // Address that ssmanager is listening on
    "manager_address": "127.0.0.1",
    "manager_port": 6100,

    // Or bind to a Unix Domain Socket
    "manager_address": "/tmp/shadowsocks-manager.sock",

    "servers": [
        // These servers will be started automatically when ssmanager is started
    ],

    // Outbound socket binds to this IP address
    // For choosing different network interface on the same machine
    "local_address": "xxx.xxx.xxx.xxx",

    // Other options that may be passed directly to new servers
}
```

## Configuration

```jsonc
{
    // LOCAL: Listen address. This is exactly the same as `locals[0]`
    // SERVER: Bind address for remote sockets, mostly used for choosing interface
    //         Don't set it if you don't know what's this for.
    "local_address": "127.0.0.1",
    "local_port": 1080,

    // Extended multiple local configuration
    "locals": [
        {
            // Basic configuration, a SOCKS5 local server
            "local_address": "127.0.0.1",
            "local_port": 1080,
            // OPTIONAL. Setting the `mode` for this specific local server instance.
            // If not set, it will derive from the outer `mode`
            "mode": "tcp_and_udp",
            // OPTIONAL. Authentication configuration file
            // Configuration file document could be found in the next section.
            "socks5_auth_config_path": "/path/to/auth.json",
            // OPTIONAL. Instance specific ACL
            "acl": "/path/to/acl/file.acl",
            // OPTIONAL. macOS launchd activate socket
            "launchd_tcp_socket_name": "TCPListener",
            "launchd_udp_socket_name": "UDPListener"
        },
        {
            // SOCKS5, SOCKS4/4a local server
            "protocol": "socks",
            // Listen address
            "local_address": "127.0.0.1",
            "local_port": 1081,
            // OPTIONAL. Enables UDP relay
            "mode": "tcp_and_udp",
            // OPTIONAL. Customizing the UDP's binding address. Depending on `mode`, if
            // - TCP is enabled, then SOCKS5's UDP Association command will return this address
            // - UDP is enabled, then SOCKS5's UDP server will listen to this address.
            "local_udp_address": "127.0.0.1",
            "local_udp_port": 2081,
            // OPTIONAL. macOS launchd activate socket
            "launchd_tcp_socket_name": "TCPListener",
            "launchd_udp_socket_name": "UDPListener"
        },
        {
            // Tunnel local server (feature = "local-tunnel")
            "protocol": "tunnel",
            // Listen address
            "local_address": "127.0.0.1",
            "local_port": 5353,
            // Forward address, the target of this tunnel
            // In this example, this will build a `127.0.0.1:5353` -> `8.8.8.8:53` tunnel
            "forward_address": "8.8.8.8",
            "forward_port": 53,
            // OPTIONAL. Customizing whether to start TCP and UDP tunnel
            "mode": "tcp_only",
            // OPTIONAL. macOS launchd activate socket
            "launchd_tcp_socket_name": "TCPListener",
            "launchd_udp_socket_name": "UDPListener"
        },
        {
            // HTTP local server (feature = "local-http")
            "protocol": "http",
            // Listen address
            "local_address": "127.0.0.1",
            "local_port": 3128,
            // OPTIONAL. macOS launchd activate socket
            "launchd_tcp_socket_name": "TCPListener",
            // OPTIONAL. Authentication configuration file
            // Configuration file document could be found in the next section.
            "http_auth_config_path": "/path/to/auth.json",
        },
        {
            // DNS local server (feature = "local-dns")
            // This DNS works like China-DNS, it will send requests to `local_dns` and `remote_dns` and choose by ACL rules
            "protocol": "dns",
            // Listen address
            "local_address": "127.0.0.1",
            "local_port": 53,
            // OPTIONAL. DNS local server uses `tcp_and_udp` mode by default
            "mode": "udp_only",
            // Local DNS address, DNS queries will be sent directly to this address
            "local_dns_address": "114.114.114.114",
            // OPTIONAL. Local DNS's port, 53 by default
            "local_dns_port": 53,
            // Remote DNS address, DNS queries will be sent through ssserver to this address
            "remote_dns_address": "8.8.8.8",
            // OPTIONAL. Remote DNS's port, 53 by default
            "remote_dns_port": 53,
            // OPTIONAL. dns client cache size for fetching dns queries.
            "client_cache_size": 5,
            // OPTIONAL. macOS launchd activate socket
            "launchd_tcp_socket_name": "TCPListener",
            "launchd_udp_socket_name": "UDPListener"
        },
        {
            // Tun local server (feature = "local-tun")
            "protocol": "tun",
            // Tun interface name
            "tun_interface_name": "tun0",
            // Tun interface address
            //
            // It has to be a host address in CIDR form
            "tun_interface_address": "10.255.0.1/24"
        },
        {
            // Transparent Proxy (redir) local server (feature = "local-redir")
            "protocol": "redir",
            // OPTIONAL: TCP type, may be different between platforms
            // Linux/Android: redirect (default), tproxy
            // FreeBSD/OpenBSD: pf (default), ipfw
            // NetBSD/macOS/Solaris: pf (default), ipfw
            "tcp_redir": "tproxy",
            // OPTIONAL: UDP type, may be different between platforms
            // Linux/Android: tproxy (default)
            // FreeBSD/OpenBSD: pf (default)
            "udp_redir": "tproxy"
        },
        {
            // FakeDNS local server (feature = "local-fake-dns")
            // FakeDNS is a DNS server that allocates an IPv4 / IPv6 address in a specific pool for each queries.
            // Subsequence requests from the other local interfaces that the target addresses includes those allocated IP addresses,
            // will be substituted back to their original domain name addresses.
            // This feature is useful mostly for transparent proxy, which will allow the proxied domain names to be resolved remotely.
            "protocol": "fake-dns",
            // Listen address
            "local_address": "127.0.0.1",
            "local_port": 10053,
            // IPv4 address pool (for A records)
            "fake_dns_ipv4_network": "10.255.0.0/16",
            // IPv6 address pool (for AAAA records)
            "fake_dns_ipv6_network": "fdf2:e786:ab40:9d2f::/64",
            // Persistent storage for all allocated DNS records
            "fake_dns_database_path": "/var/shadowsocks/fakedns.db",
            // OPTIONAL: Record expire duration in seconds, 10s by default
            "fake_dns_record_expire_duration": 10
        }
    ],

    // Server configuration
    // listen on :: for dual stack support, no need add [] around.
    "server": "::",
    // Change to use your custom port number
    "server_port": 8388,
    "method": "aes-256-gcm",
    "password": "your-password",
    "plugin": "v2ray-plugin",
    "plugin_opts": "mode=quic;host=github.com",
    "plugin_args": [
        // Each line is an argument passed to "plugin"
        "--verbose"
    ],
    "plugin_mode": "tcp_and_udp", // SIP003u, default is "tcp_only"
    // Server: TCP socket timeout in seconds.
    // Client: TCP connection timeout in seconds.
    // Omit this field if you don't have specific needs.
    "timeout": 7200,

    // Extended multiple server configuration
    // LOCAL: Choosing the best server to connect dynamically
    // SERVER: Creating multiple servers in one process
    "servers": [
        {
            // Fields are the same as the single server's configuration

            // Individual servers can be disabled
            // "disabled": true,
            "address": "0.0.0.0",
            "port": 8389,
            "method": "aes-256-gcm",
            "password": "your-password",
            "plugin": "...",
            "plugin_opts": "...",
            "plugin_args": [],
            "plugin_mode": "...",
            "timeout": 7200,

            // Customized weight for local server's balancer
            //
            // Weight must be in [0, 1], default is 1.0.
            // The higher weight, the server may rank higher.
            "tcp_weight": 1.0,
            "udp_weight": 1.0,

            // OPTIONAL. Instance specific ACL
            "acl": "/path/to/acl/file.acl",
        },
        {
            // Same key as basic format "server" and "server_port"
            "server": "0.0.0.0",
            "server_port": 8388,
            "method": "chacha20-ietf-poly1305",
            // Read the actual password from environment variable PASSWORD_FROM_ENV
            "password": "${PASSWORD_FROM_ENV}"
        },
        {
            // AEAD-2022
            "server": "::",
            "server_port": 8390,
            "method": "2022-blake3-aes-256-gcm",
            "password": "3SYJ/f8nmVuzKvKglykRQDSgg10e/ADilkdRWrrY9HU=",
            // For Server (OPTIONAL)
            // Support multiple users with Extensible Identity Header
            // https://github.com/Shadowsocks-NET/shadowsocks-specs/blob/main/2022-2-shadowsocks-2022-extensible-identity-headers.md
            "users": [
                {
                    "name": "username",
                    // User's password must have the same length as server's password
                    "password": "4w0GKJ9U3Ox7CIXGU4A3LDQAqP6qrp/tUi/ilpOR9p4="
                }
            ],
            // For Client (OPTIONAL)
            // If EIH enabled, then "password" should have the following format: iPSK:iPSK:iPSK:uPSK
            // - iPSK is one of the middle relay servers' PSK, for the last `ssserver`, it must be server's PSK ("password")
            // - uPSK is the user's PSK ("password")
            // Example:
            // "password": "3SYJ/f8nmVuzKvKglykRQDSgg10e/ADilkdRWrrY9HU=:4w0GKJ9U3Ox7CIXGU4A3LDQAqP6qrp/tUi/ilpOR9p4="
        },
        {
            "...": "Any other fields",

            // Some optional fields for this specific server

            // Outbound socket options
            // Linux Only (SO_MARK)
            "outbound_fwmark": 255,
            // FreeBSD only (SO_USER_COOKIE)
            "outbound_user_cookie": 255,
            // `SO_BINDTODEVICE` (Linux), `IP_BOUND_IF` (BSD), `IP_UNICAST_IF` (Windows) socket option for outbound sockets
            "outbound_bind_interface": "eth1",
            // Outbound socket bind() to this IP (choose a specific interface)
            "outbound_bind_addr": "11.22.33.44",
            // Outbound UDP socket allows IP fragmentation (default false)
            "outbound_udp_allow_fragmentation": false,
        }
    ],

    // Global configurations for UDP associations
    "udp_timeout": 300, // Timeout for UDP associations (in seconds), 5 minutes by default
    "udp_max_associations": 512, // Maximum UDP associations to be kept in one server, unlimited by default

    // Options for Manager
    "manager_address": "127.0.0.1", // Could be a path to UNIX socket, /tmp/shadowsocks-manager.sock
    "manager_port": 5300, // Not needed for UNIX socket

    // DNS server's address for resolving domain names
    // For *NIX and Windows, it uses system's configuration by default
    //
    // Value could be IP address of DNS server, for example, "8.8.8.8".
    // DNS client will automatically request port 53 with both TCP and UDP protocol.
    //
    // - system, uses system provided API (`getaddrinfo` on *NIX)
    //
    // It also allows some pre-defined well-known public DNS servers:
    // - google (TCP, UDP)
    // - cloudflare (TCP, UDP)
    // - cloudflare_tls (TLS), enable by feature "dns-over-tls"
    // - cloudflare_https (HTTPS), enable by feature "dns-over-https"
    // - quad9 (TCP, UDP)
    // - quad9_tls (TLS), enable by feature "dns-over-tls"
    //
    // The field is only effective if feature "hickory-dns" is enabled.
    "dns": "google",
    // Configure `cache_size` for "hickory-dns" ResolverOpts. Set to "0" to disable DNS cache.
    "dns_cache_size": 0,

    // Mode, could be one of the
    // - tcp_only
    // - tcp_and_udp
    // - udp_only
    "mode": "tcp_only",

    // TCP_NODELAY
    "no_delay": false,

    // Enables `SO_KEEPALIVE` and set `TCP_KEEPIDLE`, `TCP_KEEPINTVL` to the specified seconds
    "keep_alive": 15,

    // Soft and Hard limit of file descriptors on *NIX systems
    "nofile": 10240,

    // Try to resolve domain name to IPv6 (AAAA) addresses first
    "ipv6_first": false,
    // Set IPV6_V6ONLY for all IPv6 listener sockets
    // Only valid for locals and servers listening on `::`
    "ipv6_only": false,

    // Outbound socket options
    // Linux Only (SO_MARK)
    "outbound_fwmark": 255,
    // FreeBSD only (SO_USER_COOKIE)
    "outbound_user_cookie": 255,
    // `SO_BINDTODEVICE` (Linux), `IP_BOUND_IF` (BSD), `IP_UNICAST_IF` (Windows) socket option for outbound sockets
    "outbound_bind_interface": "eth1",
    // Outbound socket bind() to this IP (choose a specific interface)
    "outbound_bind_addr": "11.22.33.44",
    // Outbound UDP socket allows IP fragmentation (default false)
    "outbound_udp_allow_fragmentation": false,

    // Balancer customization
    "balancer": {
        // MAX Round-Trip-Time (RTT) of servers
        // The timeout seconds of each individual checks
        "max_server_rtt": 5,
        // Interval seconds between each check
        "check_interval": 10,
        // Interval seconds between each check for the best server
        // Optional. Specify to enable shorter checking interval for the best server only.
        "check_best_interval": 5
    },

    // SIP008 Online Configuration Delivery
    // https://shadowsocks.org/doc/sip008.html
    "online_config": {
        "config_url": "https://path-to-online-sip008-configuration",
        // Optional. Seconds between each update to config_url. Default to 3600s
        "update_interval": 3600,
        // Optional. Whitelist of plugins (RECOMMENDED for all users)
        // SECURITY: To avoid executing untrusted commands loaded from config_url
        "allowed_plugins": [
            "v2ray-plugin"
        ]
    },

    // Service configurations
    // Logger configuration
    "log": {
        // Default log level to use, if not overridden by `writers`, default is `0`
        // Equivalent to `-v` command line option
        "level": 1,
        // Default log format to use, if not overridden by `writers`
        "format": {
            // Euiqvalent to `--log-without-time`, default is `false`
            "without_time": false,
        },
        // Advanced logging configuration for configuring multiple writers
        // A console writer will be configured by default.
        // Set this to empty array `[]` to disable logging completely
        "writers": [
            {
                // Configure a console writer
                // The inner fields are optional, if not set, it will use the default values
                // To minimally configure a console writer, simply write `"console": {}`.
                "console": {
                    "level": 2,
                    "format": {
                        "without_time": false,
                    }
                }
            },
            {
                // Configure a file writer, useful when running as a Windows Service
                "file": {
                    // `level` and `format` can also be set here, if not set, it will use the default values
                    
                    // Required. Directory to store log files
                    "directory": "/var/log/shadowsocks-rust",
                    // Optional. Log rotation frequency, must be one of the following:
                    // - never (default): This will result in log file located at `directory/prefix.suffix`
                    // - daily: A new log file in the format of `directory/prefix.yyyy-MM-dd.suffix` will be created daily
                    // - hourly: A new log file in the format of `directory/prefix.yyyy-MM-dd-HH.suffix` will be created hourly
                    "rotation": "never",
                    // Optional. Prefix of log file, default is one of `sslocal`, `ssserver`, `ssmanager` depending on the service being run.
                    "prefix": "shadowsocks-rust",
                    // Optional. Suffix of log file, default is `log`
                    "suffix": "log",
                    // Optional. If set, keeps the last N log files
                    "max_files": 5
                }
            },
            {
                // Configure a syslog writer, only supported on *nix system
                "syslog": {
                    // `level` and `format` can also be set here, if not set, it will use the default values

                    // Optional. Set the "identity" when calling openlog(). Use current service name by default.
                    "identity": "identity_name",
                    // Optional. Set the "facility" when calling openlog(). 1 (user-level messages) by default. See RFC5424.
                    "facility": 1
                }
            }
        ]
    },
    // Runtime configuration
    "runtime": {
        // `single_thread` or `multi_thread`
        "mode": "multi_thread",
        // Worker threads that are used in multi-thread runtime
        "worker_count": 10
    }
}
```

### SOCKS5 Authentication Configuration

The configuration file is set by `socks5_auth_config_path` in `locals`.

```jsonc
{
    // Password/Username Authentication (RFC1929)
    "password": {
        "users": [
            {
                "user_name": "USERNAME in UTF-8",
                "password": "PASSWORD in UTF-8"
            }
        ]
    }
}
```

### HTTP Authentication Configuration

The configuration file is set by `http_auth_config_path` in `locals`.

```jsonc
{
    // Basic Authentication (RFC9110)
    "basic": {
        "users": [
            {
                "user_name": "USERNAME in UTF-8",
                "password": "PASSWORD in UTF-8"
            }
        ]
    }
}
```

### Environment Variables

- `SS_SERVER_PASSWORD`: A default password for servers that created from command line argument (`--server-addr`)
- `SS_SYSTEM_DNS_RESOLVER_FORCE_BUILTIN`: `"system"` DNS resolver force use system's builtin (`getaddrinfo` in *NIX)

## Supported Ciphers

### AEAD 2022 Ciphers

- `2022-blake3-aes-128-gcm`, `2022-blake3-aes-256-gcm`
- `2022-blake3-chacha20-poly1305`, `2022-blake3-chacha8-poly1305`

These Ciphers require `"password"` to be a Base64 string of key that have **exactly the same length** of Cipher's Key Size. It is recommended to use `ssservice genkey -m "METHOD_NAME"` to generate a secured and safe key.

### AEAD Ciphers

- `chacha20-ietf-poly1305`
- `aes-128-gcm`, `aes-256-gcm`

### Stream Ciphers

- `plain` or `none` (No encryption, only used for debugging or with plugins that ensure transport security)

<details><summary>Deprecated</summary>
<p>

- `table`
- `aes-128-cfb`, `aes-128-cfb1`, `aes-128-cfb8`, `aes-128-cfb128`
- `aes-192-cfb`, `aes-192-cfb1`, `aes-192-cfb8`, `aes-192-cfb128`
- `aes-256-cfb`, `aes-256-cfb1`, `aes-256-cfb8`, `aes-256-cfb128`
- `aes-128-ctr`
- `aes-192-ctr`
- `aes-256-ctr`
- `camellia-128-cfb`, `camellia-128-cfb1`, `camellia-128-cfb8`, `camellia-128-cfb128`
- `camellia-192-cfb`, `camellia-192-cfb1`, `camellia-192-cfb8`, `camellia-192-cfb128`
- `camellia-256-cfb`, `camellia-256-cfb1`, `camellia-256-cfb8`, `camellia-256-cfb128`
- `rc4-md5`
- `chacha20-ietf`

</p>
</details>

## ACL

`sslocal`, `ssserver`, and `ssmanager` support ACL file with syntax like [shadowsocks-libev](https://github.com/shadowsocks/shadowsocks-libev). Some examples could be found in [here](https://github.com/shadowsocks/shadowsocks-libev/tree/master/acl).

### Available sections

- For local servers (`sslocal`, `ssredir`, ...)
  - Modes:
    - `[bypass_all]` - ACL runs in `WhiteList` mode. Bypasses all addresses except those matching any rules.
    - `[proxy_all]` - ACL runs in `BlackList` mode. Proxies all addresses except those matching any rules. (default)
  - Rules:
    - `[bypass_list]` - Rules for connecting directly
    - `[proxy_list]` - Rules for connecting through proxies
- For remote servers (`ssserver`)
  - Modes:
    - `[reject_all]` - ACL runs in `WhiteList` mode. Rejects all clients except those matching any rules.
    - `[accept_all]` - ACL runs in `BlackList` mode. Accepts all clients except those matching any rules. (default)
    - `[outbound_block_all]` - Outbound ACL runs in `WhiteList` mode. Blocks all outbound addresses except those matching any rules.
    - `[outbound_allow_all]` - Outbound ACL runs in `BlackList` mode. Allows all outbound addresses except those matching any rules. (default)
  - Rules:
    - `[white_list]` - Rules for accepted clients
    - `[black_list]` - Rules for rejected clients
    - `[outbound_block_list]` - Rules for blocking outbound addresses.
    - `[outbound_allow_list]` - Rules for allowing outbound addresses.

### Example

```ini
# SERVERS
# For ssserver, accepts requests from all clients by default
[accept_all]

# Blocks these clients
[black_list]
1.2.3.4
127.0.0.1/8

# Disallow these outbound addresses
[outbound_block_list]
127.0.0.1/8
::1
# Using regular expression
^[a-z]{5}\.baidu\.com
# Match exactly
|baidu.com
# Match with subdomains
||google.com
# An internationalized domain name should be converted to punycode
# |☃-⌘.com - WRONG
|xn----dqo34k.com
# ||джpумлатест.bрфa - WRONG
||xn--p-8sbkgc5ag7bhce.xn--ba-lmcq

# CLIENTS
# For sslocal, ..., bypasses all targets by default
[bypass_all]

# Proxy these addresses
[proxy_list]
||google.com
8.8.8.8
```

## Useful Tools

1. `ssurl` is for encoding and decoding ShadowSocks URLs (SIP002). Example:

  ```plain
  ss://YWVzLTI1Ni1jZmI6cGFzc3dvcmQ@127.0.0.1:8388/?plugin=obfs-local%3Bobfs%3Dhttp%3Bobfs-host%3Dwww.baidu.com
  ```

## Notes

It supports the following features:

- [x] SOCKS5 CONNECT command
- [x] SOCKS5 UDP ASSOCIATE command (partial)
- [x] SOCKS4/4a CONNECT command
- [x] Various crypto algorithms
- [x] Load balancing (multiple servers) and server delay checking
- [x] [SIP004](https://github.com/shadowsocks/shadowsocks-org/issues/30) AEAD ciphers
- [x] [SIP003](https://github.com/shadowsocks/shadowsocks-org/issues/28) Plugins
- [x] [SIP003u](https://github.com/shadowsocks/shadowsocks-org/issues/180) Plugin with UDP support
- [x] [SIP002](https://github.com/shadowsocks/shadowsocks-org/issues/27) Extension ss URLs
- [x] [SIP022](https://github.com/shadowsocks/shadowsocks-org/issues/196) AEAD 2022 ciphers
- [x] HTTP Proxy Supports ([RFC 7230](http://tools.ietf.org/html/rfc7230) and [CONNECT](https://tools.ietf.org/html/draft-luotonen-web-proxy-tunneling-01))
- [x] Defend against replay attacks, [shadowsocks/shadowsocks-org#44](https://github.com/shadowsocks/shadowsocks-org/issues/44)
- [x] Manager APIs, supporting [Manage Multiple Users](https://github.com/shadowsocks/shadowsocks/wiki/Manage-Multiple-Users)
- [x] ACL (Access Control List)
- [x] Support HTTP/HTTPS Proxy protocol

## TODO

- [x] Documentation
- [x] Extend configuration format
- [x] Improved logging format (waiting for the new official log crate)
- [x] Support more ciphers without depending on `libcrypto` (waiting for an acceptable Rust crypto lib implementation)
- [x] Windows support.
- [x] Build with stable `rustc` ~~(blocking by `crypto2`)~~.
- [x] Support HTTP Proxy protocol
- [x] AEAD ciphers. (proposed in [SIP004](https://github.com/shadowsocks/shadowsocks-org/issues/30), still under discussion)
- [x] Choose server based on delay #152

## License

[The MIT License (MIT)](https://opensource.org/licenses/MIT)

Copyright (c) 2014 Y. T. CHUNG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

## Stargazers over time

[![Stargazers over time](https://starchart.cc/shadowsocks/shadowsocks-rust.svg)](https://starchart.cc/shadowsocks/shadowsocks-rust)


================================================
FILE: acl/genacl_proxy_gfw_bypass_china_ip.py
================================================
#!/usr/bin/env python3

from urllib import request, parse
import logging
import sys
import json
from datetime import datetime

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

GFW_TRANSLATED_URL = "https://raw.githubusercontent.com/NateScarlet/gfwlist.acl/master/gfwlist.acl.json"
CHINA_IP_LIST_URL = "https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt"
CUSTOM_BYPASS = [
    "127.0.0.1",
    "10.0.0.0/8",
    "172.16.0.0/12",
    "192.168.0.0/16",
    "fd00::/8",
]
CUSTOM_PROXY = [

]


def fetch_url_content(url):
    logger.info("FETCHING {}".format(url))
    r = request.urlopen(url)
    return r.read()


def write_gfw_list(fp):
    gfw_json = fetch_url_content(GFW_TRANSLATED_URL)
    gfw_obj = json.loads(gfw_json)
    for line in gfw_obj["blacklist"]:
        fp.write(line.encode("utf-8"))
        fp.write(b"\n")


def write_china_ip(fp):
    china_ip_list = fetch_url_content(CHINA_IP_LIST_URL)
    fp.write(china_ip_list)
    fp.write(b"\n")


try:
    output_file_path = sys.argv[1]
except:
    output_file_path = "shadowsocks.acl"

logger.info("WRITING {}".format(output_file_path))

with open(output_file_path, 'wb') as fp:
    now = datetime.now()

    fp.write(b"# Generated by genacl.py\n")
    fp.write("# Time: {}\n".format(now.isoformat()).encode("utf-8"))
    fp.write(b"\n")

    fp.write(b"[proxy_all]\n")
    fp.write(b"\n[proxy_list]\n")
    write_gfw_list(fp)
    fp.write(b"\n[bypass_list]\n")
    write_china_ip(fp)

    if len(CUSTOM_BYPASS) > 0:
        logger.info("CUSTOM_BYPASS {} lines".format(len(CUSTOM_BYPASS)))
        fp.write(b"\n[bypass_list]\n")
        for a in CUSTOM_BYPASS:
            fp.write(a.encode("utf-8"))
            fp.write(b"\n")

    if len(CUSTOM_PROXY) > 0:
        logger.info("CUSTOM_PROXY {} lines".format(len(CUSTOM_PROXY)))
        fp.write(b"\n[proxy_list]\n")
        for a in CUSTOM_PROXY:
            fp.write(a.encode("utf-8"))
            fp.write(b"\n")

logger.info("DONE")


================================================
FILE: appveyor.yml
================================================
environment:
  SSL_CERT_FILE: "C:\\OpenSSL\\cacert.pem"

  matrix:
    - TARGET: x86_64-pc-windows-msvc
      BITS: 64
      MSYS2: 1
      OPENSSL_DIR: C:\OpenSSL-Win64
      RUST_BACKTRACE: 1
    # - TARGET: i686-pc-windows-gnu
    #   BITS: 32
    #   OPENSSL_DIR: C:\OpenSSL-Win32
    #   MSYS2: 1
    #   SODIUM_BUILD_STATIC: yes
    #   RUST_BACKTRACE: 1
install:
  # Install Rust
  - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
  - rustup-init.exe -y --default-host %TARGET%
  - set PATH=%PATH%;%USERPROFILE%\.cargo\bin
  - if defined MSYS2 set PATH=C:\msys64\mingw%BITS%\bin;%PATH%

  # Run tests
  - rustc -V
  - cargo -V

build: false

test_script:
  - cargo test --no-fail-fast

cache:
  - target
  - C:\Users\appveyor\.cargo\registry


================================================
FILE: bin/sslocal.rs
================================================
//! This is a binary running in the local environment
//!
//! You have to provide all needed configuration attributes via command line parameters,
//! or you could specify a configuration file. The format of configuration file is defined
//! in mod `config`.

use std::process::ExitCode;

use clap::Command;
use shadowsocks_rust::service::local;

fn main() -> ExitCode {
    let mut app = Command::new("shadowsocks")
        .version(shadowsocks_rust::VERSION)
        .about("A fast tunnel proxy that helps you bypass firewalls. (https://shadowsocks.org)");
    app = local::define_command_line_options(app);

    let matches = app.get_matches();
    local::main(&matches)
}


================================================
FILE: bin/ssmanager.rs
================================================
//! This is a binary running in the server environment
//!
//! You have to provide all needed configuration attributes via command line parameters,
//! or you could specify a configuration file. The format of configuration file is defined
//! in mod `config`.
//!
//! *It should be notice that the extended configuration file is not suitable for the server
//! side.*

use std::process::ExitCode;

use clap::Command;
use shadowsocks_rust::service::manager;

fn main() -> ExitCode {
    let mut app = Command::new("shadowsocks")
        .version(shadowsocks_rust::VERSION)
        .about("A fast tunnel proxy that helps you bypass firewalls. (https://shadowsocks.org)");
    app = manager::define_command_line_options(app);

    let matches = app.get_matches();
    manager::main(&matches)
}


================================================
FILE: bin/ssserver.rs
================================================
//! This is a binary running in the server environment
//!
//! You have to provide all needed configuration attributes via command line parameters,
//! or you could specify a configuration file. The format of configuration file is defined
//! in mod `config`.
//!
//! *It should be notice that the extended configuration file is not suitable for the server
//! side.*

use std::process::ExitCode;

use clap::Command;
use shadowsocks_rust::service::server;

fn main() -> ExitCode {
    let mut app = Command::new("shadowsocks")
        .version(shadowsocks_rust::VERSION)
        .about("A fast tunnel proxy that helps you bypass firewalls. (https://shadowsocks.org)");
    app = server::define_command_line_options(app);

    let matches = app.get_matches();
    server::main(&matches)
}


================================================
FILE: bin/ssservice.rs
================================================
//! This is a binary running in both local and server environment
//!
//! You have to provide all needed configuration attributes via command line parameters,
//! or you could specify a configuration file. The format of configuration file is defined
//! in mod `config`.
//!
//! *It should be notice that the extended configuration file is not suitable for the server
//! side.*

use std::{env, path::Path, process::ExitCode};

use clap::Command;
use shadowsocks_rust::service::{genkey, local, manager, server};

fn main() -> ExitCode {
    let app = Command::new("shadowsocks")
        .version(shadowsocks_rust::VERSION)
        .about("A fast tunnel proxy that helps you bypass firewalls. (https://shadowsocks.org)");

    // Allow running `ssservice` as symlink of `sslocal`, `ssserver` and `ssmanager`
    if let Some(program_path) = env::args().next()
        && let Some(program_name) = Path::new(&program_path).file_name()
    {
        match program_name.to_str() {
            Some("sslocal") => return local::main(&local::define_command_line_options(app).get_matches()),
            Some("ssserver") => return server::main(&server::define_command_line_options(app).get_matches()),
            Some("ssmanager") => return manager::main(&manager::define_command_line_options(app).get_matches()),
            _ => {}
        }
    }

    let matches = app
        .subcommand_required(true)
        .subcommand(local::define_command_line_options(Command::new("local")).about("Shadowsocks Local service"))
        .subcommand(server::define_command_line_options(Command::new("server")).about("Shadowsocks Server service"))
        .subcommand(
            manager::define_command_line_options(Command::new("manager")).about("Shadowsocks Server Manager service"),
        )
        .subcommand(
            genkey::define_command_line_options(Command::new("genkey"))
                .about("Generate shadowsocks encryption key for method"),
        )
        .get_matches();

    match matches.subcommand() {
        Some(("local", matches)) => local::main(matches),
        Some(("server", matches)) => server::main(matches),
        Some(("manager", matches)) => manager::main(matches),
        Some(("genkey", matches)) => genkey::main(matches),
        _ => unreachable!("expecting a subcommand"),
    }
}


================================================
FILE: bin/ssurl.rs
================================================
//! SIP002 and SIP008 URL Schemes
//!
//! SS-URI = "ss://" userinfo "@" hostname ":" port [ "/" ] [ "?" plugin ] [ "#" tag ]
//! userinfo = websafe-base64-encode-utf8(method  ":" password)

use std::process::ExitCode;

use clap::{Arg, ArgAction, Command, ValueHint};
use qrcode::{QrCode, types::Color};

use shadowsocks_service::{
    config::{Config, ConfigType, ServerInstanceConfig},
    shadowsocks::config::ServerConfig,
};

/// shadowsocks version
const VERSION: &str = env!("CARGO_PKG_VERSION");

const BLACK: &str = "\x1b[40m  \x1b[0m";
const WHITE: &str = "\x1b[47m  \x1b[0m";

fn print_qrcode(encoded: &str) {
    let qrcode = QrCode::new(encoded.as_bytes()).unwrap();

    for _ in 0..qrcode.width() + 2 {
        print!("{WHITE}");
    }
    println!();

    for y in 0..qrcode.width() {
        print!("{WHITE}");
        for x in 0..qrcode.width() {
            let color = match qrcode[(x, y)] {
                Color::Light => WHITE,
                Color::Dark => BLACK,
            };

            print!("{color}");
        }
        println!("{WHITE}");
    }

    for _ in 0..qrcode.width() + 2 {
        print!("{WHITE}");
    }
    println!();
}

fn encode(filename: &str, need_qrcode: bool) {
    let config = Config::load_from_file(filename, ConfigType::Server).unwrap();

    for svr in config.server {
        let encoded = svr.config.to_url();

        println!("{encoded}");

        if need_qrcode {
            let encoded = svr.config.to_qrcode_url();
            print_qrcode(&encoded);
        }
    }
}

fn decode(encoded: &str, need_qrcode: bool) {
    let svrconfig = ServerConfig::from_url(encoded).unwrap();

    let mut config = Config::new(ConfigType::Server);
    config.server.push(ServerInstanceConfig::with_server_config(svrconfig));

    println!("{config}");

    if need_qrcode {
        print_qrcode(encoded);
    }
}

#[cfg(feature = "utility-url-outline")]
fn decode_outline(remote: &str, need_qrcode: bool) {
    // Protect from using http and other non-ssconf links in reqwest call
    if !remote.starts_with("ssconf") {
        println!("Incorrect link format");
        return;
    }

    let url = remote.replace("ssconf", "https");
    let svrconfig = ServerConfig::from_url(reqwest::blocking::get(url).unwrap().text().unwrap().as_str()).unwrap();

    let mut config = Config::new(ConfigType::Server);
    config.server.push(ServerInstanceConfig::with_server_config(svrconfig));

    println!("{config}");

    if need_qrcode {
        print_qrcode(remote);
    }
}

fn main() -> ExitCode {
    let mut app = Command::new("ssurl")
        .version(VERSION)
        .about("Encode and decode ShadowSocks URL")
        .arg(
            Arg::new("ENCODE_CONFIG_PATH")
                .short('e')
                .long("encode")
                .action(ArgAction::Set)
                .value_hint(ValueHint::FilePath)
                .conflicts_with("DECODE_CONFIG_PATH")
                .required_unless_present_any(["DECODE_CONFIG_PATH", "OUTLINE_CONFIG_URL"])
                .help("Encode the server configuration in the provided JSON file"),
        )
        .arg(
            Arg::new("DECODE_CONFIG_PATH")
                .short('d')
                .long("decode")
                .action(ArgAction::Set)
                .value_hint(ValueHint::FilePath)
                .required_unless_present_any(["ENCODE_CONFIG_PATH", "OUTLINE_CONFIG_URL"])
                .help("Decode the server configuration from the provided ShadowSocks URL"),
        )
        .arg(
            Arg::new("QRCODE")
                .short('c')
                .long("qrcode")
                .action(ArgAction::SetTrue)
                .help("Generate the QRCode with the provided configuration"),
        );

    if cfg!(feature = "utility-url-outline") {
        app = app.arg(
            Arg::new("OUTLINE_CONFIG_URL")
                .short('o')
                .long("outline")
                .value_hint(ValueHint::Url)
                .required_unless_present_any(["ENCODE_CONFIG_PATH", "DECODE_CONFIG_PATH"])
                .help("Fetch and decode config from ssconf URL used by Outline"),
        );
    }

    let matches = app.get_matches();

    let need_qrcode = matches.get_flag("QRCODE");

    if let Some(file) = matches.get_one::<String>("ENCODE_CONFIG_PATH") {
        encode(file, need_qrcode);
        return ExitCode::SUCCESS;
    }

    if let Some(encoded) = matches.get_one::<String>("DECODE_CONFIG_PATH") {
        decode(encoded, need_qrcode);
        return ExitCode::SUCCESS;
    }

    #[cfg(feature = "utility-url-outline")]
    if let Some(remote) = matches.get_one::<String>("OUTLINE_CONFIG_URL") {
        decode_outline(remote, need_qrcode);
        return ExitCode::SUCCESS;
    }

    println!("Use -h for more detail");
    ExitCode::FAILURE
}


================================================
FILE: bin/sswinservice.rs
================================================
use std::{
    ffi::OsString,
    future::Future,
    sync::atomic::{AtomicU32, Ordering},
    time::Duration,
};

use clap::Command;
use log::{error, info};
use shadowsocks_rust::{
    error::ShadowsocksResult,
    service::{local, manager, server},
};
use tokio::{runtime::Runtime, sync::oneshot};
use windows_service::{
    define_windows_service,
    service::{ServiceControl, ServiceControlAccept, ServiceExitCode, ServiceState, ServiceStatus, ServiceType},
    service_control_handler::{self, ServiceControlHandlerResult, ServiceStatusHandle},
    service_dispatcher,
};

const SERVICE_NAME: &str = "ssservice";
const SERVICE_EXIT_CODE_ARGUMENT_ERROR: u32 = 100;
const SERVICE_EXIT_CODE_EXITED_UNEXPECTEDLY: u32 = 101;
const SERVICE_EXIT_CODE_CREATE_FAILED: u32 = 102;

#[inline]
fn set_service_status(
    handle: &ServiceStatusHandle,
    current_state: ServiceState,
    exit_code: ServiceExitCode,
    wait_hint: Duration,
) -> Result<(), windows_service::Error> {
    static SERVICE_STATE_CHECKPOINT: AtomicU32 = AtomicU32::new(0);

    let next_status = ServiceStatus {
        service_type: ServiceType::OWN_PROCESS,
        current_state,
        controls_accepted: if current_state == ServiceState::StartPending {
            ServiceControlAccept::empty()
        } else {
            ServiceControlAccept::STOP
        },
        exit_code,
        checkpoint: if matches!(current_state, ServiceState::Running | ServiceState::Stopped) {
            SERVICE_STATE_CHECKPOINT.fetch_add(1, Ordering::AcqRel)
        } else {
            0
        },
        wait_hint,
        process_id: None,
    };
    handle.set_service_status(next_status)
}

fn handle_create_service_result<F>(
    status_handle: ServiceStatusHandle,
    create_service_result: ShadowsocksResult<(Runtime, F)>,
    stop_receiver: oneshot::Receiver<()>,
) -> Result<(), windows_service::Error>
where
    F: Future<Output = ShadowsocksResult>,
{
    match create_service_result {
        Ok((runtime, main_fut)) => {
            // Successfully create runtime and future

            // Report running state
            set_service_status(
                &status_handle,
                ServiceState::Running,
                ServiceExitCode::Win32(0),
                Duration::default(),
            )?;

            // Run it right now.
            let exited_by_ctrl = runtime.block_on(async move {
                tokio::pin!(main_fut);
                tokio::pin!(stop_receiver);

                loop {
                    tokio::select! {
                        _ = stop_receiver => {
                            break true;
                        }
                        exit_code = main_fut => {
                            info!("service exited unexpectedly with code: {:?}", exit_code);
                            break false;
                        }
                    }
                }
            });

            // Report stopped state
            set_service_status(
                &status_handle,
                ServiceState::Stopped,
                if exited_by_ctrl {
                    ServiceExitCode::Win32(0)
                } else {
                    ServiceExitCode::ServiceSpecific(SERVICE_EXIT_CODE_EXITED_UNEXPECTEDLY)
                },
                Duration::default(),
            )?;
        }
        Err(err) => {
            error!("failed to create service, exit code: {:?}", err.exit_code());

            // Report running state
            set_service_status(
                &status_handle,
                ServiceState::Stopped,
                ServiceExitCode::ServiceSpecific(SERVICE_EXIT_CODE_CREATE_FAILED),
                Duration::default(),
            )?;
        }
    }

    Ok(())
}

fn service_main(arguments: Vec<OsString>) -> Result<(), windows_service::Error> {
    // Create a Oneshot channel for receiving Stop event
    let (stop_sender, stop_receiver) = oneshot::channel();

    let mut stop_sender_opt = Some(stop_sender);
    let event_handler = move |control_event| -> ServiceControlHandlerResult {
        match control_event {
            ServiceControl::Stop => {
                if let Some(stop_sender) = stop_sender_opt.take() {
                    let _ = stop_sender.send(());
                }
                ServiceControlHandlerResult::NoError
            }
            ServiceControl::Interrogate => ServiceControlHandlerResult::NoError,
            _ => ServiceControlHandlerResult::NotImplemented,
        }
    };

    // Register system service event handler
    let status_handle = service_control_handler::register(SERVICE_NAME, event_handler)?;

    // Report SERVICE_START_PENDING
    // https://learn.microsoft.com/en-us/windows/win32/services/writing-a-servicemain-function
    set_service_status(
        &status_handle,
        ServiceState::StartPending,
        ServiceExitCode::Win32(0),
        Duration::from_secs(30),
    )?;

    let app = Command::new("shadowsocks service")
        .version(shadowsocks_rust::VERSION)
        .about("A fast tunnel proxy that helps you bypass firewalls. (https://shadowsocks.org)");

    let app = app
        .subcommand_required(true)
        .subcommand(local::define_command_line_options(Command::new("local")).about("Shadowsocks Local service"))
        .subcommand(server::define_command_line_options(Command::new("server")).about("Shadowsocks Server service"))
        .subcommand(
            manager::define_command_line_options(Command::new("manager")).about("Shadowsocks Server Manager service"),
        );

    let matches_result = if arguments.len() <= 1 {
        app.try_get_matches()
    } else {
        app.try_get_matches_from(arguments)
    };

    let matches = match matches_result {
        Ok(m) => m,
        Err(err) => {
            error!("failed to parse command line arguments, error: {}", err);
            set_service_status(
                &status_handle,
                ServiceState::Stopped,
                ServiceExitCode::ServiceSpecific(SERVICE_EXIT_CODE_ARGUMENT_ERROR),
                Duration::default(),
            )?;
            return Err(windows_service::Error::LaunchArgumentsNotSupported);
        }
    };

    match matches.subcommand() {
        Some(("local", matches)) => handle_create_service_result(status_handle, local::create(matches), stop_receiver),
        Some(("server", matches)) => {
            handle_create_service_result(status_handle, server::create(matches), stop_receiver)
        }
        Some(("manager", matches)) => {
            handle_create_service_result(status_handle, manager::create(matches), stop_receiver)
        }
        _ => Err(windows_service::Error::LaunchArgumentsNotSupported),
    }
}

fn service_entry(arguments: Vec<OsString>) {
    if let Err(err) = service_main(arguments) {
        error!("service main exited with error: {}", err);
    }
}

define_windows_service!(ffi_service_entry, service_entry);

fn main() -> Result<(), windows_service::Error> {
    service_dispatcher::start(SERVICE_NAME, ffi_service_entry)?;
    Ok(())
}


================================================
FILE: build/README.md
================================================
## Build Standalone Binaries

### Build with `cross`

- Install [`cross`](https://github.com/rust-embedded/cross)

```bash
cargo install cross
```

- Build with cross

```bash
cross build --target x86_64-unknown-linux-musl
```

### Predefined build routines

- `build-release`: Build binaries with `cross` and packages outputs into `release` folder
- `build-host-release`: Build binaries with host's Rust toolchain. *NIX shell script
- `build-host-release.ps1`: Build binaries with host's Rust toolchain. PowerShell script


================================================
FILE: build/build-host-release
================================================
#!/bin/bash

BUILD_TARGET=""
BUILD_FEATURES=()
while getopts "t:f:" opt; do
    case $opt in
        t)
            BUILD_TARGET=$OPTARG
            ;;
        f)
            BUILD_FEATURES+=($OPTARG)
            ;;
        ?)
            echo "Usage: $(basename $0) [-t <target-triple>] [-f <feature>]"
            ;;
    esac
done

BUILD_FEATURES+=${BUILD_EXTRA_FEATURES}

ROOT_DIR=$( cd $( dirname $0 ) && pwd )
VERSION=$(grep -E '^version' "${ROOT_DIR}/../Cargo.toml" | awk '{print $3}' | sed 's/"//g')
HOST_TRIPLE=$(rustc -Vv | grep 'host:' | awk '{print $2}')

echo "Started build release ${VERSION} for ${HOST_TRIPLE} (target: ${BUILD_TARGET}) with features \"${BUILD_FEATURES}\"..."

if [[ "${BUILD_TARGET}" != "" ]]; then
    if [[ "${BUILD_FEATURES}" != "" ]]; then
        cargo build --release --features "${BUILD_FEATURES}" --target "${BUILD_TARGET}"
    else
        cargo build --release --target "${BUILD_TARGET}"
    fi
else
    if [[ "${BUILD_FEATURES}" != "" ]]; then
        cargo build --release --features "${BUILD_FEATURES}"
    else
        cargo build --release
    fi
fi

if [[ "$?" != "0" ]]; then
    exit 1;
fi

if [[ "${BUILD_TARGET}" == "" ]]; then
    BUILD_TARGET=$HOST_TRIPLE
fi

RELEASE_FOLDER="${ROOT_DIR}/release"
RELEASE_PACKAGE_NAME="shadowsocks-v${VERSION}.${BUILD_TARGET}"

mkdir -p "${RELEASE_FOLDER}"

# Into release folder
if [[ "${BUILD_TARGET}" != "" ]]; then
    cd "${ROOT_DIR}/../target/${BUILD_TARGET}/release"
else
    cd "${ROOT_DIR}/../target/release"
fi

TARGET_SUFFIX=""
if [[ "${BUILD_TARGET}" == *"-windows-"* ]]; then
    TARGET_SUFFIX=".exe"
fi

TARGETS=("sslocal${TARGET_SUFFIX}" "ssserver${TARGET_SUFFIX}" "ssurl${TARGET_SUFFIX}" "ssmanager${TARGET_SUFFIX}" "ssservice${TARGET_SUFFIX}")

if [ -e "sswinservice${TARGET_SUFFIX}" ]; then
    TARGETS+=("sswinservice${TARGET_SUFFIX}")
fi

if [[ "${BUILD_TARGET}" == *"-windows-"* ]]; then
    # For Windows, use zip

    RELEASE_PACKAGE_FILE_NAME="${RELEASE_PACKAGE_NAME}.zip"
    RELEASE_PACKAGE_FILE_PATH="${RELEASE_FOLDER}/${RELEASE_PACKAGE_FILE_NAME}"
    zip "${RELEASE_PACKAGE_FILE_PATH}" "${TARGETS[@]}"

    if [[ $? != "0" ]]; then
        exit 1
    fi

    # Checksum
    cd "${RELEASE_FOLDER}"
    shasum -a 256 "${RELEASE_PACKAGE_FILE_NAME}" > "${RELEASE_PACKAGE_FILE_NAME}.sha256"
else
    # For others, Linux, OS X, uses tar.xz

    # For Darwin, .DS_Store and other related files should be ignored
    if [[ "$(uname -s)" == "Darwin" ]]; then
        export COPYFILE_DISABLE=1
    fi

    RELEASE_PACKAGE_FILE_NAME="${RELEASE_PACKAGE_NAME}.tar.xz"
    RELEASE_PACKAGE_FILE_PATH="${RELEASE_FOLDER}/${RELEASE_PACKAGE_FILE_NAME}"
    tar -cJf "${RELEASE_PACKAGE_FILE_PATH}" "${TARGETS[@]}"

    if [[ $? != "0" ]]; then
        exit 1
    fi

    # Checksum
    cd "${RELEASE_FOLDER}"
    shasum -a 256 "${RELEASE_PACKAGE_FILE_NAME}" > "${RELEASE_PACKAGE_FILE_NAME}.sha256"
fi

echo "Finished build release ${RELEASE_PACKAGE_FILE_PATH}"


================================================
FILE: build/build-host-release.ps1
================================================
#!pwsh
<#
    OpenSSL is already installed on windows-latest virtual environment.
    If you need OpenSSL, consider install it by:

    choco install openssl
#>
param(
    [Parameter(HelpMessage = "extra features")]
    [Alias('f')]
    [string]$Features
)

$ErrorActionPreference = "Stop"

$TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | ForEach-Object { $_.Matches.Value }).split()[-1]

Write-Host "Started building release for ${TargetTriple} ..."

if ([string]::IsNullOrEmpty($Features)) {
    cargo build --release
}
else {
    cargo build --release --features "${Features}"
}

if (!$?) {
    exit $LASTEXITCODE
}

$Version = (Select-String -Pattern '^version *= *"([^"]*)"$' -Path "${PSScriptRoot}\..\Cargo.toml" | ForEach-Object { $_.Matches.Value }).split()[-1]
$Version = $Version -replace '"'

$PackageReleasePath = "${PSScriptRoot}\release"
$PackageName = "shadowsocks-v${Version}.${TargetTriple}.zip"
$PackagePath = "${PackageReleasePath}\${PackageName}"
$ReleaseBuildPath = "${PSScriptRoot}\..\target\release"

Write-Host $Version
Write-Host $PackageReleasePath
Write-Host $PackageName
Write-Host $PackagePath
Write-Host $ReleaseBuildPath

Push-Location $ReleaseBuildPath

$ProgressPreference = "SilentlyContinue"
New-Item "${PackageReleasePath}" -ItemType Directory -ErrorAction SilentlyContinue
$CompressParam = @{
    LiteralPath     = "sslocal.exe", "ssserver.exe", "ssurl.exe", "ssmanager.exe", "ssservice.exe"
    DestinationPath = "${PackagePath}"
}
if ([System.IO.File]::Exists("$ReleaseBuildPath\sswinservice.exe")) {
    $CompressParam.LiteralPath += "sswinservice.exe"
}
Compress-Archive @CompressParam

Write-Host "Created release packet ${PackagePath}"

$PackageChecksumPath = "${PackagePath}.sha256"
$PackageHash = (Get-FileHash -Path "${PackagePath}" -Algorithm SHA256).Hash
"${PackageHash}  ${PackageName}" | Out-File -FilePath "${PackageChecksumPath}"

Write-Host "Created release packet checksum ${PackageChecksumPath}"

Pop-Location


================================================
FILE: build/build-release
================================================
#!/bin/bash

CUR_DIR=$( cd $( dirname $0 ) && pwd )
VERSION=$(grep -E '^version' ${CUR_DIR}/../Cargo.toml | awk '{print $3}' | sed 's/"//g')

## Disable macos ACL file
if [[ "$(uname -s)" == "Darwin" ]]; then
    export COPYFILE_DISABLE=1
fi

targets=()
features=()
use_upx=false
use_nightly=false
cargo_flags=""

while getopts "t:f:unZ:" opt; do
    case $opt in
        t)
            targets+=($OPTARG)
            ;;
        f)
            features+=($OPTARG)
            ;;
        u)
            use_upx=true
            ;;
        n)
            use_nightly=true
            ;;
        Z)
            cargo_flags="-Z $OPTARG"
            ;;
        ?)
            echo "Usage: $(basename $0) [-t <target-triple>] [-f features] [-u] [-n]"
            ;;
    esac
done

features+=${EXTRA_FEATURES}

if [[ "${#targets[@]}" == "0" ]]; then
    echo "Specifying compile target with -t <target-triple>"
    exit 1
fi

if [[ "${use_upx}" = true ]]; then
    if [[ -z "$upx" ]] && command -v upx &> /dev/null; then
        upx="upx -9"
    fi

    if [[ "x$upx" == "x" ]]; then
        echo "Couldn't find upx in PATH, consider specifying it with variable \$upx"
        exit 1
    fi
fi

build_command="cross"
if [[ "${use_nightly}" = true ]]; then
    build_command="$build_command +nightly"
fi


function build() {
    cd "$CUR_DIR/.."

    TARGET=$1

    RELEASE_DIR="target/${TARGET}/release"
    TARGET_FEATURES="${features[@]}"

    if [[ "${TARGET_FEATURES}" != "" ]]; then
        echo "* Building ${TARGET} package ${VERSION} with features \"${TARGET_FEATURES}\" ..."

        $build_command build --target "${TARGET}" \
                             --features "${TARGET_FEATURES}" \
                             --release \
                             ${cargo_flags}
    else
        echo "* Building ${TARGET} package ${VERSION} ..."

        $build_command build --target "${TARGET}" \
                             --release \
                             ${cargo_flags}
    fi

    if [[ $? != "0" ]]; then
        exit 1
    fi

    PKG_DIR="${CUR_DIR}/release"
    mkdir -p "${PKG_DIR}"

    if [[ "$TARGET" == *"-linux-"* || "$TARGET" == *"-freebsd" || "$TARGET" == *"-netbsd" ]]; then
        PKG_NAME="shadowsocks-v${VERSION}.${TARGET}.tar.xz"
        PKG_PATH="${PKG_DIR}/${PKG_NAME}"

        cd ${RELEASE_DIR}

        if [[ "${use_upx}" = true ]]; then
            # Enable upx for MIPS.
            $upx sslocal ssserver ssurl ssmanager ssservice #>/dev/null
        fi

        echo "* Packaging XZ in ${PKG_PATH} ..."
        tar -cJf ${PKG_PATH} \
            "sslocal" \
            "ssserver" \
            "ssurl" \
            "ssmanager" \
            "ssservice"

        if [[ $? != "0" ]]; then
            exit 1
        fi

        cd "${PKG_DIR}"
        shasum -a 256 "${PKG_NAME}" > "${PKG_NAME}.sha256"
    elif [[ "$TARGET" == *"-windows-"* ]]; then
        PKG_NAME="shadowsocks-v${VERSION}.${TARGET}.zip"
        PKG_PATH="${PKG_DIR}/${PKG_NAME}"

        echo "* Packaging ZIP in ${PKG_PATH} ..."
        cd ${RELEASE_DIR}

        sswinservice=""
        if [ -e "sswinservice.exe" ]; then
            sswinservice="sswinservice.exe"
        fi

        zip ${PKG_PATH} \
            "sslocal.exe" \
            "ssserver.exe" \
            "ssurl.exe" \
            "ssmanager.exe" \
            "ssservice.exe" \
            "${sswinservice}"

        if [[ $? != "0" ]]; then
            exit 1
        fi

        cd "${PKG_DIR}"
        shasum -a 256 "${PKG_NAME}" > "${PKG_NAME}.sha256"
    fi

    echo "* Done build package ${PKG_NAME}"
}

for target in "${targets[@]}"; do
    build "$target";
done


================================================
FILE: cargo-publish.sh
================================================
#!/bin/bash -e

set -x

ROOT_DIR=$(dirname $0)
cd ${ROOT_DIR:?}

package_ordered="crates/shadowsocks crates/shadowsocks-service ."

## dry-run
cargo check

for p in ${package_ordered:?}; do
    cargo update -p shadowsocks
    cargo update -p shadowsocks-service
    #echo "====> dry-run publish $p"
    #cargo publish --verbose --locked --dry-run --manifest-path "${p:?}/Cargo.toml"
    echo "====> publishing $p"
    cargo publish --verbose --locked --manifest-path "${p:?}/Cargo.toml"

    # this seems to be enough time to let crates.io update
    sleep 10
done


================================================
FILE: clippy.toml
================================================
msrv = "1.88"


================================================
FILE: configs/genipset.py
================================================
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import sys
import time


APNIC_DELEGATED_LATEST = "https://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest"


def get_apnic_delegated():
    from urllib import request

    u = request.urlopen(APNIC_DELEGATED_LATEST)
    return u.read().decode('utf-8')


def generate_ipset(content, name, location_set, type_set, output_file):

    if 'ipv4' in type_set:
        cidr_trans = {}
        for i in range(0, 32):
            cidr_trans[2 ** (32 - i - 1)] = i + 1

    for line in content.splitlines():
        if line.startswith('#'):
            continue

        splits = line.split('|')
        if len(splits) == 7:
            '''
            This is a Record with 7 fields
            '''

            registry, cc, type_, start, value, _, _ = splits
            if registry != 'apnic':
                continue

            if cc in location_set and type_ in type_set:

                if type_ == 'ipv4':
                    '''
                    In the case of IPv4 address the count of hosts for this range. This count does not have to represent a CIDR range.

                    But. It seems that it is always a CIDR range in this particular file.
                    '''
                    mask = cidr_trans[int(value)]
                    output_file.write(
                        'add {} {}/{} -exist\n'.format(name, start, mask))

                elif type_ == 'ipv6':
                    '''
                    In the case of an IPv6 address the value will be the CIDR prefix length from the ‘first address’ value of <start>.
                    '''
                    output_file.write(
                        'add {} {}/{} -exist\n'.format(name, start, value))


if __name__ == '__main__':
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument('--name', '-n', help='Name of ipset',
                        type=str, required=True)
    parser.add_argument('--location', '-l', help='Location to be filtered, like CN',
                        nargs='+', type=str, required=True)
    parser.add_argument('--address-type', '-t', help='Address type, like ipv4, ipv6',
                        nargs='+', type=str, required=True, choices=['ipv4', 'ipv6'])
    parser.add_argument(
        '--output', '-o', help='Output file, default to stdout', type=str, required=False)

    args = parser.parse_args()

    name = args.name
    location_set = set(args.location)
    type_set = set(args.address_type)

    start_time = time.time()
    data = get_apnic_delegated()

    if hasattr(args, 'output'):
        with open(args.output, 'w') as fp:
            generate_ipset(data, name, location_set, type_set, fp)
    else:
        generate_ipset(data, name, location_set, type_set, sys.stdout)


================================================
FILE: configs/iptables_mixed.sh
================================================
#!/bin/bash

iptables-save | grep -v shadowsocks- | iptables-restore
ip6tables-save | grep -v shadowsocks- | ip6tables-restore

### IPv4 RULES

# Create chnip ipset
ipset create chnip hash:net family inet -exist
ipset restore < /usr/local/etc/chnip.ipset

# Create gfwlist ipset
ipset create gfwlist hash:ip family inet timeout 7200 -exist
ipset create bypasslist hash:ip family inet timeout 7200 -exist

SHADOWSOCKS_REDIR_IP=0.0.0.0
SHADOWSOCKS_REDIR_PORT=60080

readonly IPV4_RESERVED_IPADDRS="\
0/8 \
10/8 \
100.64/10 \
127/8 \
169.254/16 \
172.16/12 \
192/24 \
192.0.2.0/24 \
192.88.99/24 \
192.168/16 \
198.18/15 \
198.51.100/24 \
203.0.113/24 \
224/4 \
240/4 \
255.255.255.255/32 \
"

## TCP
# NAT PREROUTING
iptables -t nat -N shadowsocks-nat
# Skip LoopBack, Reserved
for addr in ${IPV4_RESERVED_IPADDRS}; do
   iptables -t nat -A shadowsocks-nat -d "${addr}" -j RETURN
done
# Bypass sslocal's outbound data
iptables -t nat -A shadowsocks-nat -m mark --mark 0xff/0xff -j RETURN
iptables -t nat -A shadowsocks-nat -m owner --uid-owner shadowsocks -j RETURN
# Proxy gfwlist
iptables -t nat -A shadowsocks-nat -m set --match-set gfwlist dst -p tcp -j REDIRECT --to-ports ${SHADOWSOCKS_REDIR_PORT}
# Bypass CN IPs
iptables -t nat -A shadowsocks-nat -m set --match-set chnip dst -p tcp -j RETURN
iptables -t nat -A shadowsocks-nat -m set --match-set bypasslist dst -p tcp -j RETURN
# Redirect TCP to 60080
iptables -t nat -A shadowsocks-nat -p tcp -j REDIRECT --to-ports ${SHADOWSOCKS_REDIR_PORT}
# Local TCP -> shadowsocks-nat
iptables -t nat -A OUTPUT -p tcp -j shadowsocks-nat
# LAN TCP -> shadowsocks-nat
iptables -t nat -A PREROUTING -p tcp -j shadowsocks-nat

## UDP
# Strategy Route
ip -4 rule del fwmark 0x1 table 803
ip -4 rule add fwmark 0x1 table 803
ip -4 route del local 0.0.0.0/0 dev lo table 803
ip -4 route add local 0.0.0.0/0 dev lo table 803

# TPROXY for LAN
iptables -t mangle -N shadowsocks-tproxy
# Skip LoopBack, Reserved
for addr in ${IPV4_RESERVED_IPADDRS}; do
   iptables -t mangle -A shadowsocks-tproxy -d "${addr}" -j RETURN
done

# Bypass sslocal's outbound data
iptables -t mangle -A shadowsocks-tproxy -m mark --mark 0xff/0xff -j RETURN
# Proxy gfwlist
iptables -t mangle -A shadowsocks-tproxy -m set --match-set gfwlist dst -p udp -j TPROXY --on-ip ${SHADOWSOCKS_REDIR_IP} --on-port ${SHADOWSOCKS_REDIR_PORT} --tproxy-mark 0x01/0x01
# Bypass CN IPs
iptables -t mangle -A shadowsocks-tproxy -m set --match-set chnip dst -p udp -j RETURN
iptables -t mangle -A shadowsocks-tproxy -m set --match-set bypasslist dst -p udp -j RETURN
# TPROXY UDP to 60080
iptables -t mangle -A shadowsocks-tproxy -p udp -j TPROXY --on-ip ${SHADOWSOCKS_REDIR_IP} --on-port ${SHADOWSOCKS_REDIR_PORT} --tproxy-mark 0x01/0x01

# TPROXY for Local
iptables -t mangle -N shadowsocks-tproxy-mark
# Skip LoopBack, Reserved
for addr in ${IPV4_RESERVED_IPADDRS}; do
   iptables -t mangle -A shadowsocks-tproxy-mark -d "${addr}" -j RETURN
done

# Bypass sslocal's outbound data
iptables -t mangle -A shadowsocks-tproxy-mark -m mark --mark 0xff/0xff -j RETURN
iptables -t mangle -A shadowsocks-tproxy-mark -m owner --uid-owner shadowsocks -j RETURN
# Proxy gfwlist
iptables -t mangle -A shadowsocks-tproxy-mark -m set --match-set gfwlist dst -j MARK --set-xmark 0x01/0xffffffff
# Bypass CN IPs
iptables -t mangle -A shadowsocks-tproxy-mark -m set --match-set chnip dst -j RETURN
# Set MARK and reroute
iptables -t mangle -A shadowsocks-tproxy-mark -p udp -j MARK --set-xmark 0x01/0xffffffff
#iptables -t mangle -A shadowsocks-tproxy-mark -p tcp -j MARK --set-xmark 1

# Apply TPROXY to LAN
iptables -t mangle -A PREROUTING -p udp -j shadowsocks-tproxy
#iptables -t mangle -A PREROUTING -p udp -m addrtype ! --src-type LOCAL ! --dst-type LOCAL -j shadowsocks-tproxy
# Apply TPROXY for Local
iptables -t mangle -A OUTPUT -p udp -j shadowsocks-tproxy-mark
#iptables -t mangle -A OUTPUT -p udp -m addrtype --src-type LOCAL ! --dst-type LOCAL -j shadowsocks-tproxy-mark

# DIVERT rules
# For optimizing TCP
# iptables -t mangle -N shadowsocks-divert
# iptables -t mangle -A shadowsocks-divert -j MARK --set-mark 1
# iptables -t mangle -A shadowsocks-divert -j ACCEPT
# iptables -t mangle -I PREROUTING -p tcp -m socket -j shadowsocks-divert

### IPv6 RULES

# Create chnip6 ipset
ipset create chnip6 hash:net family inet6 -exist
ipset restore < /usr/local/etc/chnip6.ipset

# Create gfwlist6 ipset
ipset create gfwlist6 hash:ip family inet6 timeout 7200 -exist
ipset create bypasslist6 hash:ip family inet6 timeout 7200 -exist

SHADOWSOCKS6_REDIR_IP=::
SHADOWSOCKS6_REDIR_PORT=60081

readonly IPV6_RESERVED_IPADDRS="\
::/128 \
::1/128 \
::ffff:0:0/96 \
::ffff:0:0:0/96 \
64:ff9b::/96 \
100::/64 \
2001::/32 \
2001:20::/28 \
2001:db8::/32 \
2002::/16 \
fc00::/7 \
fe80::/10 \
ff00::/8 \
"

## TCP
# NAT PREROUTING
ip6tables -t nat -N shadowsocks-nat
# Skip LoopBack, Reserved
for addr in ${IPV6_RESERVED_IPADDRS}; do
   ip6tables -t nat -A shadowsocks-nat -d "${addr}" -j RETURN
done
# Bypass sslocal's outbound data
ip6tables -t nat -A shadowsocks-nat -m mark --mark 0xff/0xff -j RETURN
ip6tables -t nat -A shadowsocks-nat -m owner --uid-owner shadowsocks -j RETURN
# Proxy gfwlist6
ip6tables -t nat -A shadowsocks-nat -m set --match-set gfwlist6 dst -p tcp -j REDIRECT --to-ports ${SHADOWSOCKS6_REDIR_PORT}
# Bypass CN IPs
ip6tables -t nat -A shadowsocks-nat -m set --match-set chnip6 dst -p tcp -j RETURN
ip6tables -t nat -A shadowsocks-nat -m set --match-set bypasslist6 dst -p tcp -j RETURN
# Redirect TCP to 60081
ip6tables -t nat -A shadowsocks-nat -p tcp -j REDIRECT --to-ports ${SHADOWSOCKS6_REDIR_PORT}
# Local TCP -> shadowsocks-nat
ip6tables -t nat -A OUTPUT -p tcp -j shadowsocks-nat
# LAN TCP -> shadowsocks-nat
ip6tables -t nat -A PREROUTING -p tcp -j shadowsocks-nat

## UDP
# Strategy Route
ip -6 rule del fwmark 0x1 table 803
ip -6 rule add fwmark 0x1 table 803
ip -6 route del local ::/0 dev lo table 803
ip -6 route add local ::/0 dev lo table 803

# TPROXY for LAN
ip6tables -t mangle -N shadowsocks-tproxy
# Skip LoopBack, Reserved
for addr in ${IPV6_RESERVED_IPADDRS}; do
   ip6tables -t mangle -A shadowsocks-tproxy -d "${addr}" -j RETURN
done

# Bypass sslocal's outbound data
ip6tables -t mangle -A shadowsocks-tproxy -m mark --mark 0xff/0xff -j RETURN
# Proxy gfwlist6
ip6tables -t mangle -A shadowsocks-tproxy -m set --match-set gfwlist6 dst -p udp -j TPROXY --on-ip ${SHADOWSOCKS6_REDIR_IP} --on-port ${SHADOWSOCKS6_REDIR_PORT} --tproxy-mark 0x01/0x01
# Bypass CN IPs
ip6tables -t mangle -A shadowsocks-tproxy -m set --match-set chnip6 dst -p udp -j RETURN
ip6tables -t mangle -A shadowsocks-tproxy -m set --match-set bypasslist6 dst -p udp -j RETURN
# TPROXY UDP to 60081
ip6tables -t mangle -A shadowsocks-tproxy -p udp -j TPROXY --on-ip ${SHADOWSOCKS6_REDIR_IP} --on-port ${SHADOWSOCKS6_REDIR_PORT} --tproxy-mark 0x01/0x01

# TPROXY for Local
ip6tables -t mangle -N shadowsocks-tproxy-mark
# Skip LoopBack, Reserved
for addr in ${IPV6_RESERVED_IPADDRS}; do
   ip6tables -t mangle -A shadowsocks-tproxy-mark -d "${addr}" -j RETURN
done

# Bypass sslocal's outbound data
ip6tables -t mangle -A shadowsocks-tproxy-mark -m mark --mark 0xff/0xff -j RETURN
ip6tables -t mangle -A shadowsocks-tproxy-mark -m owner --uid-owner shadowsocks -j RETURN
# Proxy gfwlist6
ip6tables -t mangle -A shadowsocks-tproxy-mark -m set --match-set gfwlist6 dst -j MARK --set-xmark 0x01/0xffffffff
# Bypass CN IPs
ip6tables -t mangle -A shadowsocks-tproxy-mark -m set --match-set chnip6 dst -j RETURN
# Set MARK and reroute
ip6tables -t mangle -A shadowsocks-tproxy-mark -p udp -j MARK --set-xmark 0x01/0xffffffff
#ip6tables -t mangle -A shadowsocks-tproxy-mark -p tcp -j MARK --set-xmark 1

# Apply TPROXY to LAN
ip6tables -t mangle -A PREROUTING -p udp -j shadowsocks-tproxy
#ip6tables -t mangle -A PREROUTING -p udp -m addrtype ! --src-type LOCAL ! --dst-type LOCAL -j shadowsocks-tproxy
# Apply TPROXY for Local
ip6tables -t mangle -A OUTPUT -p udp -j shadowsocks-tproxy-mark
#ip6tables -t mangle -A OUTPUT -p udp -m addrtype --src-type LOCAL ! --dst-type LOCAL -j shadowsocks-tproxy-mark

# DIVERT rules
# For optimizing TCP
# ip6tables -t mangle -N shadowsocks-divert
# ip6tables -t mangle -A shadowsocks-divert -j MARK --set-mark 1
# ip6tables -t mangle -A shadowsocks-divert -j ACCEPT
# ip6tables -t mangle -I PREROUTING -p tcp -m socket -j shadowsocks-divert


================================================
FILE: configs/iptables_tproxy.sh
================================================
#!/bin/bash

iptables-save | grep -v shadowsocks- | iptables-restore
ip6tables-save | grep -v shadowsocks- | ip6tables-restore

### IPv4 RULES

# Create chnip ipset
ipset create chnip hash:net family inet -exist
ipset restore < /usr/local/etc/chnip.ipset

# Create gfwlist ipset
ipset create gfwlist hash:ip family inet timeout 7200 -exist
ipset create bypasslist hash:ip family inet timeout 7200 -exist

SHADOWSOCKS_REDIR_IP=0.0.0.0
SHADOWSOCKS_REDIR_PORT=60080

readonly IPV4_RESERVED_IPADDRS="\
0/8 \
10/8 \
100.64/10 \
127/8 \
169.254/16 \
172.16/12 \
192/24 \
192.0.2.0/24 \
192.88.99/24 \
192.168/16 \
198.18/15 \
198.51.100/24 \
203.0.113/24 \
224/4 \
240/4 \
255.255.255.255/32 \
"

## TCP+UDP
# Strategy Route
ip -4 rule del fwmark 0x1 table 803
ip -4 rule add fwmark 0x1 table 803
ip -4 route del local 0.0.0.0/0 dev lo table 803
ip -4 route add local 0.0.0.0/0 dev lo table 803

# TPROXY for LAN
iptables -t mangle -N shadowsocks-tproxy
# Skip LoopBack, Reserved
for addr in ${IPV4_RESERVED_IPADDRS}; do
   iptables -t mangle -A shadowsocks-tproxy -d "${addr}" -j RETURN
done

# Bypass LAN data
iptables -t mangle -A shadowsocks-tproxy -m addrtype --dst-type LOCAL -j RETURN
# Bypass sslocal's outbound data
iptables -t mangle -A shadowsocks-tproxy -m mark --mark 0xff/0xff -j RETURN
# UDP: Proxy gfwlist
iptables -t mangle -A shadowsocks-tproxy -m set --match-set gfwlist dst -p udp -j TPROXY --on-ip ${SHADOWSOCKS_REDIR_IP} --on-port ${SHADOWSOCKS_REDIR_PORT} --tproxy-mark 0x01/0x01
# UDP: Bypass CN IPs
iptables -t mangle -A shadowsocks-tproxy -m set --match-set chnip dst -p udp -j RETURN
iptables -t mangle -A shadowsocks-tproxy -m set --match-set bypasslist dst -p udp -j RETURN
# UDP: TPROXY UDP to 60080
iptables -t mangle -A shadowsocks-tproxy -p udp -j TPROXY --on-ip ${SHADOWSOCKS_REDIR_IP} --on-port ${SHADOWSOCKS_REDIR_PORT} --tproxy-mark 0x01/0x01
# TCP: Proxy gfwlist
iptables -t mangle -A shadowsocks-tproxy -m set --match-set gfwlist dst -p tcp -j TPROXY --on-ip ${SHADOWSOCKS_REDIR_IP} --on-port ${SHADOWSOCKS_REDIR_PORT} --tproxy-mark 0x01/0x01
# TCP: Bypass CN IPs
iptables -t mangle -A shadowsocks-tproxy -m set --match-set chnip dst -p tcp -j RETURN
iptables -t mangle -A shadowsocks-tproxy -m set --match-set bypasslist dst -p tcp -j RETURN
# TCP: TPROXY TCP to 60080
iptables -t mangle -A shadowsocks-tproxy -p tcp -j TPROXY --on-ip ${SHADOWSOCKS_REDIR_IP} --on-port ${SHADOWSOCKS_REDIR_PORT} --tproxy-mark 0x01/0x01


# TPROXY for Local
iptables -t mangle -N shadowsocks-tproxy-mark
# Skip LoopBack, Reserved
for addr in ${IPV4_RESERVED_IPADDRS}; do
   iptables -t mangle -A shadowsocks-tproxy-mark -d "${addr}" -j RETURN
done

# TCP: conntrack
iptables -t mangle -A shadowsocks-tproxy-mark -p tcp -m conntrack --ctdir REPLY -j RETURN
# Bypass sslocal's outbound data
iptables -t mangle -A shadowsocks-tproxy-mark -m mark --mark 0xff/0xff -j RETURN
iptables -t mangle -A shadowsocks-tproxy-mark -m owner --uid-owner shadowsocks -j RETURN
# Proxy gfwlist
iptables -t mangle -A shadowsocks-tproxy-mark -m set --match-set gfwlist dst -j MARK --set-xmark 0x01/0xffffffff
# Bypass CN IPs
iptables -t mangle -A shadowsocks-tproxy-mark -m set --match-set chnip dst -j RETURN
# UDP: Set MARK and reroute
iptables -t mangle -A shadowsocks-tproxy-mark -p udp -j MARK --set-xmark 0x01/0xffffffff
# TCP: Set MARK and reroute
iptables -t mangle -A shadowsocks-tproxy-mark -p tcp -j MARK --set-xmark 0x01/0xffffffff

# Apply TPROXY to LAN
iptables -t mangle -A PREROUTING -p udp -j shadowsocks-tproxy
iptables -t mangle -A PREROUTING -p tcp -j shadowsocks-tproxy
#iptables -t mangle -A PREROUTING -p udp -m addrtype ! --src-type LOCAL ! --dst-type LOCAL -j shadowsocks-tproxy
# Apply TPROXY for Local
iptables -t mangle -A OUTPUT -p udp -j shadowsocks-tproxy-mark
iptables -t mangle -A OUTPUT -p tcp -j shadowsocks-tproxy-mark
#iptables -t mangle -A OUTPUT -p udp -m addrtype --src-type LOCAL ! --dst-type LOCAL -j shadowsocks-tproxy-mark

# DIVERT rules
# For optimizing TCP
# iptables -t mangle -N shadowsocks-divert
# iptables -t mangle -A shadowsocks-divert -j MARK --set-mark 1
# iptables -t mangle -A shadowsocks-divert -j ACCEPT
# iptables -t mangle -I PREROUTING -p tcp -m socket -j shadowsocks-divert

### IPv6 RULES

# Create chnip6 ipset
ipset create chnip6 hash:net family inet6 -exist
ipset restore < /usr/local/etc/chnip6.ipset

# Create gfwlist6 ipset
ipset create gfwlist6 hash:ip family inet6 timeout 7200 -exist
ipset create bypasslist6 hash:ip family inet6 timeout 7200 -exist

SHADOWSOCKS6_REDIR_IP=::
SHADOWSOCKS6_REDIR_PORT=60081

readonly IPV6_RESERVED_IPADDRS="\
::/128 \
::1/128 \
::ffff:0:0/96 \
::ffff:0:0:0/96 \
64:ff9b::/96 \
100::/64 \
2001::/32 \
2001:20::/28 \
2001:db8::/32 \
2002::/16 \
fc00::/7 \
fe80::/10 \
ff00::/8 \
"

## TCP+UDP
# Strategy Route
ip -6 rule del fwmark 0x1 table 803
ip -6 rule add fwmark 0x1 table 803
ip -6 route del local ::/0 dev lo table 803
ip -6 route add local ::/0 dev lo table 803

# TPROXY for LAN
ip6tables -t mangle -N shadowsocks-tproxy
# Skip LoopBack, Reserved
for addr in ${IPV6_RESERVED_IPADDRS}; do
   ip6tables -t mangle -A shadowsocks-tproxy -d "${addr}" -j RETURN
done

# Bypass LAN data
ip6tables -t mangle -A shadowsocks-tproxy -m addrtype --dst-type LOCAL -j RETURN
# Bypass sslocal's outbound data
ip6tables -t mangle -A shadowsocks-tproxy -m mark --mark 0xff/0xff -j RETURN
# UDP: Proxy gfwlist6
ip6tables -t mangle -A shadowsocks-tproxy -m set --match-set gfwlist6 dst -p udp -j TPROXY --on-ip ${SHADOWSOCKS6_REDIR_IP} --on-port ${SHADOWSOCKS6_REDIR_PORT} --tproxy-mark 0x01/0x01
# UDP: Bypass CN IPs
ip6tables -t mangle -A shadowsocks-tproxy -m set --match-set chnip6 dst -p udp -j RETURN
ip6tables -t mangle -A shadowsocks-tproxy -m set --match-set bypasslist6 dst -p udp -j RETURN
# UDP: TPROXY UDP to 60081
ip6tables -t mangle -A shadowsocks-tproxy -p udp -j TPROXY --on-ip ${SHADOWSOCKS6_REDIR_IP} --on-port ${SHADOWSOCKS6_REDIR_PORT} --tproxy-mark 0x01/0x01
# TCP: Proxy gfwlist6
ip6tables -t mangle -A shadowsocks-tproxy -m set --match-set gfwlist6 dst -p tcp -j TPROXY --on-ip ${SHADOWSOCKS6_REDIR_IP} --on-port ${SHADOWSOCKS6_REDIR_PORT} --tproxy-mark 0x01/0x01
# TCP: Bypass CN IPs
ip6tables -t mangle -A shadowsocks-tproxy -m set --match-set chnip6 dst -p tcp -j RETURN
ip6tables -t mangle -A shadowsocks-tproxy -m set --match-set bypasslist6 dst -p tcp -j RETURN
# TCP: TPROXY UDP to 60081
ip6tables -t mangle -A shadowsocks-tproxy -p tcp -j TPROXY --on-ip ${SHADOWSOCKS6_REDIR_IP} --on-port ${SHADOWSOCKS6_REDIR_PORT} --tproxy-mark 0x01/0x01

# TPROXY for Local
ip6tables -t mangle -N shadowsocks-tproxy-mark
# Skip LoopBack, Reserved
for addr in ${IPV6_RESERVED_IPADDRS}; do
   ip6tables -t mangle -A shadowsocks-tproxy-mark -d "${addr}" -j RETURN
done

# TCP: conntrack
ip6tables -t mangle -A shadowsocks-tproxy-mark -p tcp -m conntrack --ctdir REPLY -j RETURN
# Bypass sslocal's outbound data
ip6tables -t mangle -A shadowsocks-tproxy-mark -m mark --mark 0xff/0xff -j RETURN
ip6tables -t mangle -A shadowsocks-tproxy-mark -m owner --uid-owner shadowsocks -j RETURN
# Proxy gfwlist6
ip6tables -t mangle -A shadowsocks-tproxy-mark -m set --match-set gfwlist6 dst -j MARK --set-xmark 0x01/0xffffffff
# Bypass CN IPs
ip6tables -t mangle -A shadowsocks-tproxy-mark -m set --match-set chnip6 dst -j RETURN
# Set MARK and reroute
ip6tables -t mangle -A shadowsocks-tproxy-mark -p udp -j MARK --set-xmark 0x01/0xffffffff
ip6tables -t mangle -A shadowsocks-tproxy-mark -p tcp -j MARK --set-xmark 0x01/0xffffffff

# Apply TPROXY to LAN
ip6tables -t mangle -A PREROUTING -p udp -j shadowsocks-tproxy
ip6tables -t mangle -A PREROUTING -p tcp -j shadowsocks-tproxy
#ip6tables -t mangle -A PREROUTING -p udp -m addrtype ! --src-type LOCAL ! --dst-type LOCAL -j shadowsocks-tproxy
# Apply TPROXY for Local
ip6tables -t mangle -A OUTPUT -p udp -j shadowsocks-tproxy-mark
ip6tables -t mangle -A OUTPUT -p tcp -j shadowsocks-tproxy-mark
#ip6tables -t mangle -A OUTPUT -p udp -m addrtype --src-type LOCAL ! --dst-type LOCAL -j shadowsocks-tproxy-mark

# DIVERT rules
# For optimizing TCP
# ip6tables -t mangle -N shadowsocks-divert
# ip6tables -t mangle -A shadowsocks-divert -j MARK --set-mark 1
# ip6tables -t mangle -A shadowsocks-divert -j ACCEPT


================================================
FILE: configs/log4rs.yaml
================================================
refresh_rate: 30 seconds
appenders:
  stdout:
    kind: console
    encoder:
      pattern: "{d} {h({l}):<5} {m}{n}"
  file:
    kind: rolling_file
    path: shadowsocks.log
    encoder:
      kind: pattern
      pattern: "{d} {h({l}):<5} {m}{n}"
    policy:
      trigger:
        kind: size
        limit: 10 mb
      roller:
        kind: fixed_window
        pattern: shadowsocks.{}.log
        count: 5
root:
  level: info
  appenders:
    - stdout
    - file


================================================
FILE: configs/org.shadowsocks.shadowsocks-rust.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Disabled</key>
        <false/>

        <key>Label</key>
        <string>org.shadowsocks.shadowsocks-rust</string>

        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/bin/sslocal</string>
            <string>-c</string>
            <string>/usr/local/etc/shadowsocks.json</string>
        </array>

        <key>RunAtLoad</key>
        <true/>

        <key>KeepAlive</key>
        <dict>
            <key>NetworkState</key>
            <true/>
        </dict>

        <key>WorkingDirectory</key>
        <string>/</string>

        <key>StandardErrorPath</key>
        <string>/tmp/shadowsocks-rust.stderr.log</string>

        <key>StandardOutPath</key>
        <string>/tmp/shadowsocks-rust.stdout.log</string>

        <key>SoftResourceLimits</key>
        <dict>
            <key>NumberOfFiles</key>
            <integer>10240</integer>
        </dict>
    </dict>
</plist>


================================================
FILE: configs/shadowsocks.procd.sh
================================================
#!/bin/sh /etc/rc.common

START=30

USE_PROCD=1

EXTRA_COMMANDS="set_firewall destroy"
EXTRA_HELP=<<EOF
	set_firewall Set firewall (iptable) rules
	destroy Remove all resources (ipset, firewall rules, ...)
EOF

set_firewall() {
    uci add firewall include
    uci rename 'firewall.@include[-1]=shadowsocks'
    uci set 'firewall.@include[-1].path=/usr/local/etc/iptables_mixed.include'
    uci set 'firewall.@include[-1].type=script'
    uci set 'firewall.@include[-1].reload=1'
    uci commit firewall

    # Initialize iptables rules
    /etc/init.d/firewall restart
}

destroy() {
    ipset destroy chnip
    ipset destroy gfwlist
    ipset destroy bypasslist
    ipset destroy chnip6
    ipset destroy gfwlist6
    ipset destroy bypasslist6

    uci delete 'firewall.shadowsocks'
    uci commit firewall

    # Delete iptables rules
    /etc/init.d/firewall restart

    # Delete strategy route rules
    ip -4 rule del fwmark 0x1 table 803
    ip -4 route del local 0.0.0.0/0 dev lo table 803
    ip -6 rule del fwmark 0x1 table 803
    ip -6 route del local ::/0 dev lo table 803
}

start_service() {
    SHADOWSOCKS_CAPABILITIES_CONFIG_PATH="/etc/capabilities/shadowsocks.json"
    SHADOWSOCKS_LOG_FILE_PATH="/var/log/shadowsocks"

    mkdir -p ${SHADOWSOCKS_LOG_FILE_PATH}
    if id "shadowsocks" &>/dev/null; then
        chown shadowsocks:shadowsocks -R ${SHADOWSOCKS_LOG_FILE_PATH}
    fi

    SHADOWSOCKS_CONFIG_PATH="/usr/local/etc/shadowsocks.json"
    SHADOWSOCKS_EXECUTABLE="/usr/local/bin/sslocal"
    SHADOWSOCKS_PARAMETERS="-c ${SHADOWSOCKS_CONFIG_PATH} --log-without-time --udp-max-associations 4192 --outbound-fwmark 255"
    SHADOWSOCKS_COMMAND="${SHADOWSOCKS_EXECUTABLE} ${SHADOWSOCKS_PARAMETERS}"

    procd_open_instance shadowsocks
    procd_set_param env RUST_BACKTRACE=1
    procd_set_param env NO_COLOR=1

    procd_set_param file ${SHADOWSOCKS_CONFIG_PATH}
    procd_set_param respawn
    procd_set_param reload_signal USR1
    procd_set_param limits nofile="10240 10240"
    procd_set_param limits core="unlimited"
    procd_set_param stdout 1
    procd_set_param stderr 1

    if id "shadowsocks" &>/dev/null; then
        if [ -x /sbin/ujail -a -e ${SHADOWSOCKS_CAPABILITIES_CONFIG_PATH} ]; then
            procd_add_jail shadowsocks requirejail
            procd_add_jail_mount ${SHADOWSOCKS_CONFIG_PATH}
            procd_set_param user shadowsocks
            procd_set_param group shadowsocks
            procd_set_param capabilities ${SHADOWSOCKS_CAPABILITIES_CONFIG_PATH}
            procd_set_param no_new_privs 1
            procd_set_param command ${SHADOWSOCKS_COMMAND}
        else
            procd_set_param user root
            procd_set_param command /usr/sbin/capsh --caps="cap_setpcap,cap_setuid,cap_setgid+ep cap_net_admin,cap_net_raw,cap_net_bind_service+eip" --keep=1 \
                                    --user="shadowsocks" --addamb="cap_net_admin,cap_net_raw,cap_net_bind_service" \
                                    --shell="${SHADOWSOCKS_EXECUTABLE}" -- ${SHADOWSOCKS_PARAMETERS}
        fi
    else
        procd_set_param user root
        procd_set_param command ${SHADOWSOCKS_COMMAND}
    fi

    SHADOWSOCKS6_CONFIG_PATH="/usr/local/etc/shadowsocks6.json"
    SHADOWSOCKS6_EXECUTABLE="/usr/local/bin/sslocal"
    SHADOWSOCKS6_PARAMETERS="-c ${SHADOWSOCKS6_CONFIG_PATH} --log-without-time --udp-max-associations 4192 --outbound-fwmark 255"
    SHADOWSOCKS6_COMMAND="${SHADOWSOCKS6_EXECUTABLE} ${SHADOWSOCKS6_PARAMETERS}"

    procd_set_param pidfile /var/run/shadowsocks.pid
    procd_close_instance

    procd_open_instance shadowsocks6
    procd_set_param env RUST_BACKTRACE=1
    procd_set_param env NO_COLOR=1

    procd_set_param file ${SHADOWSOCKS6_CONFIG_PATH}
    procd_set_param respawn
    procd_set_param reload_signal USR1
    procd_set_param limits nofile="10240 10240"
    procd_set_param limits core="unlimited"
    procd_set_param stdout 1
    procd_set_param stderr 1

    if id "shadowsocks" &>/dev/null; then
        if [ -x /sbin/ujail -a -e ${SHADOWSOCKS_CAPABILITIES_CONFIG_PATH} ]; then
            procd_add_jail shadowsocks6 requirejail
            procd_add_jail_mount ${SHADOWSOCKS6_CONFIG_PATH}
            procd_set_param user shadowsocks
            procd_set_param group shadowsocks
            procd_set_param capabilities ${SHADOWSOCKS_CAPABILITIES_CONFIG_PATH}
            procd_set_param no_new_privs 1
            procd_set_param command ${SHADOWSOCKS6_COMMAND}
        else
            procd_set_param user root
            procd_set_param command /usr/sbin/capsh --caps="cap_setpcap,cap_setuid,cap_setgid+ep cap_net_admin,cap_net_raw,cap_net_bind_service+eip" --keep=1 \
                                    --user="shadowsocks" --addamb="cap_net_admin,cap_net_raw,cap_net_bind_service" \
                                    --shell="${SHADOWSOCKS6_EXECUTABLE}" -- ${SHADOWSOCKS6_PARAMETERS}
        fi
    else
        procd_set_param user root
        procd_set_param command ${SHADOWSOCKS6_COMMAND}
    fi

    procd_set_param pidfile /var/run/shadowsocks6.pid
    procd_close_instance

    echo 'Started shadowsocks service'
}

service_stopped() {
    echo 'Stopped shadowsocks service'
}

service_triggers() {
    #procd_add_reload_interface_trigger "pppoe-wan"
    procd_add_interface_trigger "interface.*" "pppoe-wan" /etc/init.d/shadowsocks restart
}


================================================
FILE: crates/shadowsocks/Cargo.toml
================================================
[package]
name = "shadowsocks"
version = "1.24.0"
authors = ["Shadowsocks Contributors"]
description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls."
repository = "https://github.com/shadowsocks/shadowsocks-rust"
readme = "README.md"
documentation = "https://docs.rs/shadowsocks-core"
keywords = ["shadowsocks", "proxy", "socks", "socks5", "firewall"]
license = "MIT"
edition = "2024"
rust-version = "1.88"

[badges]
maintenance = { status = "passively-maintained" }

[features]
default = ["hickory-dns", "aead-cipher"]

# Uses Hickory-DNS instead of tokio's builtin DNS resolver
hickory-dns = ["hickory-resolver", "arc-swap", "notify"]
# Hickory-DNS was renamed from Trust-DNS, keep compatibility.
trust-dns = ["hickory-dns"]

# Enable Stream Cipher Protocol
# WARN: Stream Cipher Protocol is proved to be insecure
# https://github.com/shadowsocks/shadowsocks-rust/issues/373
# Users should always avoid using these ciphers in practice
stream-cipher = ["shadowsocks-crypto/v1-stream", "shadowsocks-crypto/ring"]

# Enable AEAD ciphers
aead-cipher = ["shadowsocks-crypto/v1-aead", "shadowsocks-crypto/ring"]

# Enable extra AEAD ciphers
# WARN: These non-standard AEAD ciphers are not officially supported by shadowsocks community
aead-cipher-extra = ["aead-cipher", "shadowsocks-crypto/v1-aead-extra"]

aead-cipher-2022 = [
    "shadowsocks-crypto/v2",
    "shadowsocks-crypto/ring",
    "rand",
    "aes",
    "lru_time_cache",
] # Enable AEAD 2022
# Enable AEAD 2022 with extra ciphers
aead-cipher-2022-extra = ["aead-cipher-2022", "shadowsocks-crypto/v2-extra"]

# Enable detection against replay attack
security-replay-attack-detect = ["bloomfilter"]

[dependencies]
log = "0.4"

libc = "~0.2.141"
bytes = "1.7"
cfg-if = "1"
byte_string = "1.0"
base64 = "0.22"
url = "2.5"
spin = { version = "0.10", features = ["std"] }
pin-project = "1.1"
bloomfilter = { version = "3.0.0", optional = true }
thiserror = "2.0"
rand = { version = "0.10", optional = true }
lru_time_cache = { version = "0.11", optional = true }

serde = { version = "1.0", features = ["derive"] }
serde_urlencoded = "0.7"
serde_json = "1.0"
percent-encoding = "2.1"

futures = "0.3"
trait-variant = "0.1"
dynosaur = "0.3.0"
sealed = "0.6"

socket2 = { version = "0.6", features = ["all"] }
tokio = { version = "1.9.0", features = [
    "io-util",
    "macros",
    "net",
    "parking_lot",
    "process",
    "rt",
    "sync",
    "time",
] }

hickory-resolver = { version = "0.25", optional = true }
arc-swap = { version = "1.7", optional = true }
notify = { version = "8.0", optional = true }

aes = { version = "0.8", optional = true }
blake3 = "1.5"
shadowsocks-crypto = { version = "0.6.0", default-features = false }

[target.'cfg(any(windows, target_os = "linux", target_os = "android", target_os = "freebsd", target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos"))'.dependencies]
tokio-tfo = "0.4.3"

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = [
    "Win32_Foundation",
    "Win32_NetworkManagement_IpHelper",
    "Win32_NetworkManagement_Ndis",
    "Win32_Networking_WinSock",
    "Win32_System_IO",
] }

[target.'cfg(unix)'.dependencies]
sendfd = { version = "0.4", features = ["tokio"] }

[dev-dependencies]
env_logger = "0.11"

[lints.clippy]
uninlined_format_args = "allow"


================================================
FILE: crates/shadowsocks/LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2017 Y. T. CHUNG <zonyitoo@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


================================================
FILE: crates/shadowsocks/README.md
================================================
# shadowsocks

[![License](https://img.shields.io/github/license/zonyitoo/shadowsocks-rust.svg)](https://github.com/zonyitoo/shadowsocks-rust)
[![crates.io](https://img.shields.io/crates/v/shadowsocks.svg)](https://crates.io/crates/shadowsocks)
[![docs.rs](https://img.shields.io/docsrs/shadowsocks)](https://docs.rs/shadowsocks)

This is a port of [shadowsocks](https://github.com/shadowsocks/shadowsocks).

shadowsocks is a fast tunnel proxy that helps you bypass firewalls.


================================================
FILE: crates/shadowsocks/src/config.rs
================================================
//! Configuration

#[cfg(unix)]
use std::path::PathBuf;
use std::{
    collections::HashMap,
    fmt::{self, Debug, Display},
    net::SocketAddr,
    str::{self, FromStr},
    sync::Arc,
    time::Duration,
};

use base64::Engine as _;
use byte_string::ByteStr;
use bytes::Bytes;
use cfg_if::cfg_if;
use log::{error, warn};
use thiserror::Error;
use url::{self, Url};

#[cfg(any(feature = "stream-cipher", feature = "aead-cipher"))]
use crate::crypto::v1::openssl_bytes_to_key;
use crate::{crypto::CipherKind, plugin::PluginConfig, relay::socks5::Address};

const USER_KEY_BASE64_ENGINE: base64::engine::GeneralPurpose = base64::engine::GeneralPurpose::new(
    &base64::alphabet::STANDARD,
    base64::engine::GeneralPurposeConfig::new()
        .with_encode_padding(true)
        .with_decode_padding_mode(base64::engine::DecodePaddingMode::Indifferent),
);

#[cfg(feature = "aead-cipher-2022")]
const AEAD2022_PASSWORD_BASE64_ENGINE: base64::engine::GeneralPurpose = base64::engine::GeneralPurpose::new(
    &base64::alphabet::STANDARD,
    base64::engine::GeneralPurposeConfig::new()
        .with_encode_padding(true)
        .with_decode_padding_mode(base64::engine::DecodePaddingMode::Indifferent),
);

const URL_PASSWORD_BASE64_ENGINE: base64::engine::GeneralPurpose = base64::engine::GeneralPurpose::new(
    &base64::alphabet::URL_SAFE,
    base64::engine::GeneralPurposeConfig::new()
        .with_encode_padding(false)
        .with_decode_padding_mode(base64::engine::DecodePaddingMode::Indifferent),
);

/// Shadowsocks server type
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum ServerType {
    /// Running as a local service
    Local,

    /// Running as a shadowsocks server
    Server,
}

impl ServerType {
    /// Check if it is `Local`
    pub fn is_local(self) -> bool {
        self == Self::Local
    }

    /// Check if it is `Server`
    pub fn is_server(self) -> bool {
        self == Self::Server
    }
}

/// Server mode
#[derive(Clone, Copy, Debug)]
pub enum Mode {
    TcpOnly = 0x01,
    TcpAndUdp = 0x03,
    UdpOnly = 0x02,
}

impl Mode {
    /// Check if UDP is enabled
    pub fn enable_udp(self) -> bool {
        matches!(self, Self::UdpOnly | Self::TcpAndUdp)
    }

    /// Check if TCP is enabled
    pub fn enable_tcp(self) -> bool {
        matches!(self, Self::TcpOnly | Self::TcpAndUdp)
    }

    /// Merge with another Mode
    pub fn merge(&self, mode: Self) -> Self {
        let me = *self as u8;
        let fm = mode as u8;
        match me | fm {
            0x01 => Self::TcpOnly,
            0x02 => Self::UdpOnly,
            0x03 => Self::TcpAndUdp,
            _ => unreachable!(),
        }
    }

    /// String representation of Mode
    pub fn as_str(&self) -> &'static str {
        match *self {
            Self::TcpOnly => "tcp_only",
            Self::TcpAndUdp => "tcp_and_udp",
            Self::UdpOnly => "udp_only",
        }
    }
}

impl fmt::Display for Mode {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str(self.as_str())
    }
}

impl FromStr for Mode {
    type Err = ();

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "tcp_only" => Ok(Self::TcpOnly),
            "tcp_and_udp" => Ok(Self::TcpAndUdp),
            "udp_only" => Ok(Self::UdpOnly),
            _ => Err(()),
        }
    }
}

struct ModeVisitor;

impl serde::de::Visitor<'_> for ModeVisitor {
    type Value = Mode;

    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
        formatter.write_str("Mode")
    }

    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        match v.parse::<Mode>() {
            Ok(m) => Ok(m),
            Err(_) => Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(v), &self)),
        }
    }

    fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        self.visit_str::<E>(v.as_str())
    }

    fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        match str::from_utf8(v) {
            Ok(v) => self.visit_str(v),
            Err(_) => Err(serde::de::Error::invalid_value(serde::de::Unexpected::Bytes(v), &self)),
        }
    }

    fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        match String::from_utf8(v) {
            Ok(v) => self.visit_string(v),
            Err(e) => Err(serde::de::Error::invalid_value(
                serde::de::Unexpected::Bytes(&e.into_bytes()),
                &self,
            )),
        }
    }
}

impl<'de> serde::Deserialize<'de> for Mode {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_string(ModeVisitor)
    }
}

impl serde::Serialize for Mode {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

/// Server's weight
///
/// Commonly for using in balancer
#[derive(Debug, Clone)]
pub struct ServerWeight {
    tcp_weight: f32,
    udp_weight: f32,
}

impl Default for ServerWeight {
    fn default() -> Self {
        Self::new()
    }
}

impl ServerWeight {
    /// Creates a default weight for server, which will have 1.0 for both TCP and UDP
    pub fn new() -> Self {
        Self {
            tcp_weight: 1.0,
            udp_weight: 1.0,
        }
    }

    /// Weight for TCP balancer
    pub fn tcp_weight(&self) -> f32 {
        self.tcp_weight
    }

    /// Set weight for TCP balancer in `[0, 1]`
    pub fn set_tcp_weight(&mut self, weight: f32) {
        assert!((0.0..=1.0).contains(&weight));
        self.tcp_weight = weight;
    }

    /// Weight for UDP balancer
    pub fn udp_weight(&self) -> f32 {
        self.udp_weight
    }

    /// Set weight for UDP balancer in `[0, 1]`
    pub fn set_udp_weight(&mut self, weight: f32) {
        assert!((0.0..=1.0).contains(&weight));
        self.udp_weight = weight;
    }
}

/// Server's user
#[derive(Clone)]
pub struct ServerUser {
    name: String,
    key: Bytes,
    identity_hash: Bytes,
}

impl Debug for ServerUser {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_struct("ServerUser")
            .field("name", &self.name)
            .field("key", &USER_KEY_BASE64_ENGINE.encode(&self.key))
            .field("identity_hash", &ByteStr::new(&self.identity_hash))
            .finish()
    }
}

impl ServerUser {
    /// Create a user
    pub fn new<N, K>(name: N, key: K) -> Self
    where
        N: Into<String>,
        K: Into<Bytes>,
    {
        let name = name.into();
        let key = key.into();

        let hash = blake3::hash(&key);
        let identity_hash = Bytes::from(hash.as_bytes()[0..16].to_owned());

        Self {
            name,
            key,
            identity_hash,
        }
    }

    /// Create a user from encoded key
    pub fn with_encoded_key<N>(name: N, key: &str) -> Result<Self, ServerUserError>
    where
        N: Into<String>,
    {
        let key = USER_KEY_BASE64_ENGINE.decode(key)?;
        Ok(Self::new(name, key))
    }

    /// Name of the user
    pub fn name(&self) -> &str {
        self.name.as_str()
    }

    /// Encryption key of user
    pub fn key(&self) -> &[u8] {
        self.key.as_ref()
    }

    /// Get Base64 encoded key of user
    pub fn encoded_key(&self) -> String {
        USER_KEY_BASE64_ENGINE.encode(&self.key)
    }

    /// User's identity hash
    ///
    /// https://github.com/Shadowsocks-NET/shadowsocks-specs/blob/main/2022-2-shadowsocks-2022-extensible-identity-headers.md
    pub fn identity_hash(&self) -> &[u8] {
        self.identity_hash.as_ref()
    }

    /// User's identity hash
    ///
    /// https://github.com/Shadowsocks-NET/shadowsocks-specs/blob/main/2022-2-shadowsocks-2022-extensible-identity-headers.md
    pub fn clone_identity_hash(&self) -> Bytes {
        self.identity_hash.clone()
    }
}

/// ServerUser related errors
#[derive(Debug, Clone, Error)]
pub enum ServerUserError {
    /// Invalid User key encoding
    #[error("{0}")]
    InvalidKeyEncoding(#[from] base64::DecodeError),
}

/// Server multi-users manager
#[derive(Clone, Debug)]
pub struct ServerUserManager {
    users: HashMap<Bytes, Arc<ServerUser>>,
}

impl ServerUserManager {
    /// Create a new manager
    pub fn new() -> Self {
        Self { users: HashMap::new() }
    }

    /// Add a new user
    pub fn add_user(&mut self, user: ServerUser) {
        self.users.insert(user.clone_identity_hash(), Arc::new(user));
    }

    /// Get user by hash key
    pub fn get_user_by_hash(&self, user_hash: &[u8]) -> Option<&ServerUser> {
        self.users.get(user_hash).map(AsRef::as_ref)
    }

    /// Get user by hash key cloned
    pub fn clone_user_by_hash(&self, user_hash: &[u8]) -> Option<Arc<ServerUser>> {
        self.users.get(user_hash).cloned()
    }

    /// Number of users
    pub fn user_count(&self) -> usize {
        self.users.len()
    }

    /// Iterate users
    pub fn users_iter(&self) -> impl Iterator<Item = &ServerUser> {
        self.users.values().map(|v| v.as_ref())
    }
}

impl Default for ServerUserManager {
    fn default() -> Self {
        Self::new()
    }
}

/// The source of the ServerConfig
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum ServerSource {
    Default,       //< Default source, created in code
    Configuration, //< Created from configuration
    CommandLine,   //< Created from command line
    OnlineConfig,  //< Created from online configuration (SIP008)
}

/// Errors when creating a new ServerConfig
#[derive(Debug, Clone, Error)]
pub enum ServerConfigError {
    /// Invalid base64 encoding of password
    #[error("invalid key encoding for {0}, {1}")]
    InvalidKeyEncoding(CipherKind, base64::DecodeError),

    /// Invalid user key encoding
    #[error("invalid iPSK encoding for {0}, {1}")]
    InvalidUserKeyEncoding(CipherKind, base64::DecodeError),

    /// Key length mismatch
    #[error("invalid key length for {0}, expecting {1} bytes, but found {2} bytes")]
    InvalidKeyLength(CipherKind, usize, usize),

    /// User Key (ipsk) length mismatch
    #[error("invalid user key length for {0}, expecting {1} bytes, but found {2} bytes")]
    InvalidUserKeyLength(CipherKind, usize, usize),
}

/// Configuration for a server
#[derive(Clone, Debug)]
pub struct ServerConfig {
    /// Server address
    addr: ServerAddr,
    /// Encryption password (key)
    password: String,
    /// Encryption type (method)
    method: CipherKind,
    /// Encryption key
    enc_key: Box<[u8]>,
    /// Handshake timeout (connect)
    timeout: Option<Duration>,

    /// Extensible Identity Headers (AEAD-2022)
    ///
    /// For client, assemble EIH headers
    identity_keys: Arc<Vec<Bytes>>,

    /// Extensible Identity Headers (AEAD-2022)
    ///
    /// For server, support multi-users with EIH
    user_manager: Option<Arc<ServerUserManager>>,

    /// Plugin config
    plugin: Option<PluginConfig>,
    /// Plugin address
    plugin_addr: Option<ServerAddr>,

    /// Remark (Profile Name), normally used as an identifier of this erver
    remarks: Option<String>,
    /// ID (SIP008) is a random generated UUID
    id: Option<String>,

    /// Mode
    mode: Mode,

    /// Weight
    weight: ServerWeight,

    /// Source
    source: ServerSource,
}

#[inline]
fn make_derived_key(method: CipherKind, password: &str, enc_key: &mut [u8]) -> Result<(), ServerConfigError> {
    #[cfg(feature = "aead-cipher-2022")]
    if method.is_aead_2022() {
        // AEAD 2022 password is a base64 form of enc_key
        match AEAD2022_PASSWORD_BASE64_ENGINE.decode(password) {
            Ok(v) => {
                if v.len() != enc_key.len() {
                    return Err(ServerConfigError::InvalidKeyLength(method, enc_key.len(), v.len()));
                }
                enc_key.copy_from_slice(&v);
            }
            Err(err) => {
                return Err(ServerConfigError::InvalidKeyEncoding(method, err));
            }
        }

        return Ok(());
    }

    cfg_if! {
        if #[cfg(any(feature = "stream-cipher", feature = "aead-cipher"))] {
            let _ = method;
            openssl_bytes_to_key(password.as_bytes(), enc_key);

            Ok(())
        } else {
            // No default implementation.
            let _ = password;
            let _ = enc_key;
            unreachable!("{method} don't know how to make a derived key");
        }
    }
}

/// Check if method supports Extended Identity Header
///
/// https://github.com/Shadowsocks-NET/shadowsocks-specs/blob/main/2022-2-shadowsocks-2022-extensible-identity-headers.md
#[cfg(feature = "aead-cipher-2022")]
#[inline]
pub fn method_support_eih(method: CipherKind) -> bool {
    matches!(
        method,
        CipherKind::AEAD2022_BLAKE3_AES_128_GCM | CipherKind::AEAD2022_BLAKE3_AES_256_GCM
    )
}

#[allow(clippy::type_complexity)]
fn password_to_keys<P>(method: CipherKind, password: P) -> Result<(String, Box<[u8]>, Vec<Bytes>), ServerConfigError>
where
    P: Into<String>,
{
    let password = password.into();

    match method {
        CipherKind::NONE => {
            // NONE method's key length is 0
            debug_assert_eq!(method.key_len(), 0);

            if !password.is_empty() {
                warn!(
                    "method \"none\" doesn't need a password, which should be set as an empty String, but password.len() = {}",
                    password.len()
                );
            }

            return Ok((password, Vec::new().into_boxed_slice(), Vec::new()));
        }

        #[cfg(feature = "stream-cipher")]
        CipherKind::SS_TABLE => {
            // TABLE cipher doesn't need key derivation.
            // Reference implementation: shadowsocks-libev, shadowsocks (Python)
            let enc_key = password.clone().into_bytes().into_boxed_slice();
            return Ok((password, enc_key, Vec::new()));
        }

        #[allow(unreachable_patterns)]
        _ => {}
    }

    #[cfg(feature = "aead-cipher-2022")]
    if method_support_eih(method) {
        // Extensible Identity Headers
        // iPSK1:iPSK2:iPSK3:...:uPSK

        let mut identity_keys = Vec::new();

        let mut split_iter = password.rsplit(':');

        let upsk = split_iter.next().expect("uPSK");

        let mut enc_key = vec![0u8; method.key_len()].into_boxed_slice();
        make_derived_key(method, upsk, &mut enc_key)?;

        for ipsk in split_iter {
            match USER_KEY_BASE64_ENGINE.decode(ipsk) {
                Ok(v) => {
                    // Double check identity key's length
                    match method {
                        CipherKind::AEAD2022_BLAKE3_AES_128_GCM => {
                            // AES-128
                            if v.len() != 16 {
                                return Err(ServerConfigError::InvalidUserKeyLength(method, 16, v.len()));
                            }
                        }
                        CipherKind::AEAD2022_BLAKE3_AES_256_GCM => {
                            // AES-256
                            if v.len() != 32 {
                                return Err(ServerConfigError::InvalidUserKeyLength(method, 32, v.len()));
                            }
                        }
                        _ => unreachable!("{} doesn't support EIH", method),
                    }
                    identity_keys.push(Bytes::from(v));
                }
                Err(err) => {
                    return Err(ServerConfigError::InvalidUserKeyEncoding(method, err));
                }
            }
        }

        identity_keys.reverse();

        return Ok((upsk.to_owned(), enc_key, identity_keys));
    }

    let mut enc_key = vec![0u8; method.key_len()].into_boxed_slice();
    make_derived_key(method, &password, &mut enc_key)?;

    Ok((password, enc_key, Vec::new()))
}

impl ServerConfig {
    /// Create a new `ServerConfig`
    pub fn new<A, P>(addr: A, password: P, method: CipherKind) -> Result<Self, ServerConfigError>
    where
        A: Into<ServerAddr>,
        P: Into<String>,
    {
        let (password, enc_key, identity_keys) = password_to_keys(method, password)?;

        Ok(Self {
            addr: addr.into(),
            password,
            method,
            enc_key,
            identity_keys: Arc::new(identity_keys),
            user_manager: None,
            timeout: None,
            plugin: None,
            plugin_addr: None,
            remarks: None,
            id: None,
            mode: Mode::TcpAndUdp, // Server serves TCP & UDP by default
            weight: ServerWeight::new(),
            source: ServerSource::Default,
        })
    }

    /// Set encryption method
    pub fn set_method<P>(&mut self, method: CipherKind, password: P) -> Result<(), ServerConfigError>
    where
        P: Into<String>,
    {
        self.method = method;

        let (password, enc_key, identity_keys) = password_to_keys(method, password)?;

        self.password = password;
        self.enc_key = enc_key;
        self.identity_keys = Arc::new(identity_keys);

        Ok(())
    }

    /// Set plugin
    pub fn set_plugin(&mut self, p: PluginConfig) {
        self.plugin = Some(p);
    }

    /// Set server addr
    pub fn set_addr<A>(&mut self, a: A)
    where
        A: Into<ServerAddr>,
    {
        self.addr = a.into();
    }

    /// Get server address
    pub fn addr(&self) -> &ServerAddr {
        &self.addr
    }

    /// Get encryption key
    pub fn key(&self) -> &[u8] {
        self.enc_key.as_ref()
    }

    /// Get password
    pub fn password(&self) -> &str {
        self.password.as_str()
    }

    /// Get identity keys (Client)
    pub fn identity_keys(&self) -> &[Bytes] {
        &self.identity_keys
    }

    /// Clone identity keys (Client)
    pub fn clone_identity_keys(&self) -> Arc<Vec<Bytes>> {
        self.identity_keys.clone()
    }

    /// Set user manager, enable Server's multi-user support with EIH
    pub fn set_user_manager(&mut self, user_manager: ServerUserManager) {
        self.user_manager = Some(Arc::new(user_manager));
    }

    /// Get user manager (Server)
    pub fn user_manager(&self) -> Option<&ServerUserManager> {
        self.user_manager.as_deref()
    }

    /// Clone user manager (Server)
    pub fn clone_user_manager(&self) -> Option<Arc<ServerUserManager>> {
        self.user_manager.clone()
    }

    /// Get method
    pub fn method(&self) -> CipherKind {
        self.method
    }

    /// Get plugin
    pub fn plugin(&self) -> Option<&PluginConfig> {
        self.plugin.as_ref()
    }

    /// Set plugin address
    pub fn set_plugin_addr(&mut self, a: ServerAddr) {
        self.plugin_addr = Some(a);
    }

    /// Get plugin address
    pub fn plugin_addr(&self) -> Option<&ServerAddr> {
        self.plugin_addr.as_ref()
    }

    /// Get server's TCP external address
    pub fn tcp_external_addr(&self) -> &ServerAddr {
        if let Some(plugin) = self.plugin()
            && plugin.plugin_mode.enable_tcp()
        {
            return self.plugin_addr.as_ref().unwrap_or(&self.addr);
        }
        &self.addr
    }

    /// Get server's UDP external address
    pub fn udp_external_addr(&self) -> &ServerAddr {
        if let Some(plugin) = self.plugin()
            && plugin.plugin_mode.enable_udp()
        {
            return self.plugin_addr.as_ref().unwrap_or(&self.addr);
        }
        &self.addr
    }

    /// Set timeout
    pub fn set_timeout(&mut self, timeout: Duration) {
        self.timeout = Some(timeout);
    }

    /// Timeout
    pub fn timeout(&self) -> Option<Duration> {
        self.timeout
    }

    /// Get server's remark
    pub fn remarks(&self) -> Option<&str> {
        self.remarks.as_ref().map(AsRef::as_ref)
    }

    /// Set server's remark
    pub fn set_remarks<S>(&mut self, remarks: S)
    where
        S: Into<String>,
    {
        self.remarks = Some(remarks.into());
    }

    /// Get server's ID (SIP008)
    pub fn id(&self) -> Option<&str> {
        self.id.as_ref().map(AsRef::as_ref)
    }

    /// Set server's ID (SIP008)
    pub fn set_id<S>(&mut self, id: S)
    where
        S: Into<String>,
    {
        self.id = Some(id.into())
    }

    /// Get server's `Mode`
    pub fn mode(&self) -> Mode {
        self.mode
    }

    /// Set server's `Mode`
    pub fn set_mode(&mut self, mode: Mode) {
        self.mode = mode;
    }

    /// Get server's balancer weight
    pub fn weight(&self) -> &ServerWeight {
        &self.weight
    }

    /// Set server's balancer weight
    pub fn set_weight(&mut self, weight: ServerWeight) {
        self.weight = weight;
    }

    /// Get server's source
    pub fn source(&self) -> ServerSource {
        self.source
    }

    /// Set server's source
    pub fn set_source(&mut self, source: ServerSource) {
        self.source = source;
    }

    /// Get URL for QRCode
    /// ```plain
    /// ss:// + base64(method:password@host:port)
    /// ```
    pub fn to_qrcode_url(&self) -> String {
        let param = format!("{}:{}@{}", self.method(), self.password(), self.addr());
        format!("ss://{}", URL_PASSWORD_BASE64_ENGINE.encode(param))
    }

    /// Get [SIP002](https://github.com/shadowsocks/shadowsocks-org/issues/27) URL
    pub fn to_url(&self) -> String {
        cfg_if! {
            if #[cfg(feature = "aead-cipher-2022")] {
                let user_info = if !self.method().is_aead_2022() {
                    let user_info = format!("{}:{}", self.method(), self.password());
                    URL_PASSWORD_BASE64_ENGINE.encode(user_info)
                } else {
                    format!("{}:{}", self.method(), percent_encoding::utf8_percent_encode(self.password(), percent_encoding::NON_ALPHANUMERIC))
                };
            } else {
                let mut user_info = format!("{}:{}", self.method(), self.password());
                user_info = URL_PASSWORD_BASE64_ENGINE.encode(&user_info)
            }
        }

        let mut url = format!("ss://{}@{}", user_info, self.addr());
        if let Some(c) = self.plugin() {
            let mut plugin = c.plugin.clone();
            if let Some(ref opt) = c.plugin_opts {
                plugin += ";";
                plugin += opt;
            }

            url += "/?plugin=";
            for c in percent_encoding::utf8_percent_encode(&plugin, percent_encoding::NON_ALPHANUMERIC) {
                url.push_str(c);
            }
        }

        if let Some(remark) = self.remarks() {
            url += "#";
            for c in percent_encoding::utf8_percent_encode(remark, percent_encoding::NON_ALPHANUMERIC) {
                url.push_str(c);
            }
        }

        url
    }

    /// Parse from [SIP002](https://github.com/shadowsocks/shadowsocks-org/issues/27) URL
    ///
    /// Extended formats:
    ///
    /// 1. QRCode URL supported by shadowsocks-android, https://github.com/shadowsocks/shadowsocks-android/issues/51
    /// 2. Plain userinfo:password format supported by go2-shadowsocks2
    pub fn from_url(encoded: &str) -> Result<Self, UrlParseError> {
        let parsed = Url::parse(encoded).map_err(UrlParseError::from)?;

        if parsed.scheme() != "ss" {
            return Err(UrlParseError::InvalidScheme);
        }

        let user_info = parsed.username();
        if user_info.is_empty() {
            // This maybe a QRCode URL, which is ss://BASE64-URL-ENCODE(pass:encrypt@hostname:port)

            let encoded = match parsed.host_str() {
                Some(e) => e,
                None => return Err(UrlParseError::MissingHost),
            };

            let mut decoded_body = match URL_PASSWORD_BASE64_ENGINE.decode(encoded) {
                Ok(b) => match String::from_utf8(b) {
                    Ok(b) => b,
                    Err(..) => return Err(UrlParseError::InvalidServerAddr),
                },
                Err(err) => {
                    error!("failed to parse legacy ss://ENCODED with Base64, err: {}", err);
                    return Err(UrlParseError::InvalidServerAddr);
                }
            };

            decoded_body.insert_str(0, "ss://");
            // Parse it like ss://method:password@host:port
            return Self::from_url(&decoded_body);
        }

        let (method, pwd) = match parsed.password() {
            Some(password) => {
                // Plain method:password without base64 encoded

                let m = match percent_encoding::percent_decode_str(user_info).decode_utf8() {
                    Ok(m) => m,
                    Err(err) => {
                        error!("failed to parse percent-encoded method in userinfo, err: {}", err);
                        return Err(UrlParseError::InvalidAuthInfo);
                    }
                };

                let p = match percent_encoding::percent_decode_str(password).decode_utf8() {
                    Ok(m) => m,
                    Err(err) => {
                        error!("failed to parse percent-encoded password in userinfo, err: {}", err);
                        return Err(UrlParseError::InvalidAuthInfo);
                    }
                };

                (m, p)
            }
            None => {
                // userinfo is not required to be percent encoded, but some implementation did.
                // If the base64 library have padding = added to the encoded string, then it will become %3D.

                let decoded_user_info = match percent_encoding::percent_decode_str(user_info).decode_utf8() {
                    Ok(m) => m,
                    Err(err) => {
                        error!("failed to parse percent-encoded userinfo, err: {}", err);
                        return Err(UrlParseError::InvalidAuthInfo);
                    }
                };

                // reborrow to fit AsRef<[u8]>
                let decoded_user_info: &str = &decoded_user_info;

                // Some implementation, like outline,
                // or those with Python (base64 in Python will still have '=' padding for URL safe encode)
                let account = match URL_PASSWORD_BASE64_ENGINE.decode(decoded_user_info) {
                    Ok(account) => match String::from_utf8(account) {
                        Ok(ac) => ac,
                        Err(..) => return Err(UrlParseError::InvalidAuthInfo),
                    },
                    Err(err) => {
                        error!("failed to parse UserInfo with Base64, err: {}", err);
                        return Err(UrlParseError::InvalidUserInfo);
                    }
                };

                let mut sp2 = account.splitn(2, ':');
                let (m, p) = match (sp2.next(), sp2.next()) {
                    (Some(m), Some(p)) => (m, p),
                    _ => return Err(UrlParseError::InvalidUserInfo),
                };

                (m.to_owned().into(), p.to_owned().into())
            }
        };

        let host = match parsed.host_str() {
            Some(host) => host,
            None => return Err(UrlParseError::MissingHost),
        };

        let port = parsed.port().unwrap_or(8388);
        let addr = format!("{host}:{port}");

        let addr = match addr.parse::<ServerAddr>() {
            Ok(a) => a,
            Err(err) => {
                error!("failed to parse \"{}\" to ServerAddr, err: {:?}", addr, err);
                return Err(UrlParseError::InvalidServerAddr);
            }
        };

        let method = match method.parse::<CipherKind>() {
            Ok(m) => m,
            Err(err) => {
                error!("failed to parse \"{}\" to CipherKind, err: {:?}", method, err);
                return Err(UrlParseError::InvalidMethod);
            }
        };
        let mut svrconfig = Self::new(addr, pwd, method)?;

        if let Some(q) = parsed.query() {
            let query = match serde_urlencoded::from_bytes::<Vec<(String, String)>>(q.as_bytes()) {
                Ok(q) => q,
                Err(err) => {
                    error!("failed to parse QueryString, err: {}", err);
                    return Err(UrlParseError::InvalidQueryString);
                }
            };

            for (key, value) in query {
                if key != "plugin" {
                    continue;
                }

                let mut vsp = value.splitn(2, ';');
                match vsp.next() {
                    None => {}
                    Some(p) => {
                        let plugin = PluginConfig {
                            plugin: p.to_owned(),
                            plugin_opts: vsp.next().map(ToOwned::to_owned),
                            plugin_args: Vec::new(), // SIP002 doesn't have arguments for plugins
                            plugin_mode: Mode::TcpOnly, // SIP002 doesn't support SIP003u
                        };
                        svrconfig.set_plugin(plugin);
                    }
                }
            }
        }

        if let Some(frag) = parsed.fragment() {
            match percent_encoding::percent_decode_str(frag).decode_utf8() {
                Ok(m) => svrconfig.set_remarks(m),
                Err(..) => svrconfig.set_remarks(frag),
            }
        }

        Ok(svrconfig)
    }

    /// Check if it is a basic format server
    pub fn is_basic(&self) -> bool {
        self.remarks.is_none() && self.id.is_none()
    }
}

/// Shadowsocks URL parsing Error
#[derive(Debug, Clone, Error)]
pub enum UrlParseError {
    #[error("{0}")]
    ParseError(#[from] url::ParseError),
    #[error("URL must have \"ss://\" scheme")]
    InvalidScheme,
    #[error("unknown encryption method")]
    InvalidMethod,
    #[error("invalid user info")]
    InvalidUserInfo,
    #[error("missing host")]
    MissingHost,
    #[error("invalid authentication info")]
    InvalidAuthInfo,
    #[error("invalid server address")]
    InvalidServerAddr,
    #[error("invalid query string")]
    InvalidQueryString,
    #[error("{0}")]
    ServerConfigError(#[from] ServerConfigError),
}

impl FromStr for ServerConfig {
    type Err = UrlParseError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        Self::from_url(s)
    }
}

/// Server address
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ServerAddr {
    /// IP Address
    SocketAddr(SocketAddr),
    /// Domain name address, eg. example.com:8080
    DomainName(String, u16),
}

impl ServerAddr {
    /// Get string representation of domain
    pub fn host(&self) -> String {
        match *self {
            Self::SocketAddr(ref s) => s.ip().to_string(),
            Self::DomainName(ref dm, _) => dm.clone(),
        }
    }

    /// Get port
    pub fn port(&self) -> u16 {
        match *self {
            Self::SocketAddr(ref s) => s.port(),
            Self::DomainName(_, p) => p,
        }
    }
}

/// Parse `ServerAddr` error
#[derive(Debug)]
pub struct ServerAddrError;

impl Display for ServerAddrError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str("invalid ServerAddr")
    }
}

impl FromStr for ServerAddr {
    type Err = ServerAddrError;

    fn from_str(s: &str) -> Result<Self, ServerAddrError> {
        match s.parse::<SocketAddr>() {
            Ok(addr) => Ok(Self::SocketAddr(addr)),
            Err(..) => {
                let mut sp = s.split(':');
                match (sp.next(), sp.next()) {
                    (Some(dn), Some(port)) => {
                        if dn.is_empty() {
                            return Err(ServerAddrError);
                        }
                        match port.parse::<u16>() {
                            Ok(port) => Ok(Self::DomainName(dn.to_owned(), port)),
                            Err(..) => Err(ServerAddrError),
                        }
                    }
                    _ => Err(ServerAddrError),
                }
            }
        }
    }
}

impl Display for ServerAddr {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            Self::SocketAddr(ref a) => write!(f, "{a}"),
            Self::DomainName(ref d, port) => write!(f, "{d}:{port}"),
        }
    }
}

struct ServerAddrVisitor;

impl serde::de::Visitor<'_> for ServerAddrVisitor {
    type Value = ServerAddr;

    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
        formatter.write_str("ServerAddr")
    }

    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        match v.parse::<ServerAddr>() {
            Ok(m) => Ok(m),
            Err(_) => Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(v), &self)),
        }
    }

    fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        self.visit_str::<E>(v.as_str())
    }

    fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        match str::from_utf8(v) {
            Ok(v) => self.visit_str(v),
            Err(_) => Err(serde::de::Error::invalid_value(serde::de::Unexpected::Bytes(v), &self)),
        }
    }

    fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        match String::from_utf8(v) {
            Ok(v) => self.visit_string(v),
            Err(e) => Err(serde::de::Error::invalid_value(
                serde::de::Unexpected::Bytes(&e.into_bytes()),
                &self,
            )),
        }
    }
}

impl<'de> serde::Deserialize<'de> for ServerAddr {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_string(ServerAddrVisitor)
    }
}

impl serde::Serialize for ServerAddr {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.to_string().as_str())
    }
}

impl From<SocketAddr> for ServerAddr {
    fn from(addr: SocketAddr) -> Self {
        Self::SocketAddr(addr)
    }
}

impl<I: Into<String>> From<(I, u16)> for ServerAddr {
    fn from((dname, port): (I, u16)) -> Self {
        Self::DomainName(dname.into(), port)
    }
}

impl From<Address> for ServerAddr {
    fn from(addr: Address) -> Self {
        match addr {
            Address::SocketAddress(sa) => Self::SocketAddr(sa),
            Address::DomainNameAddress(dn, port) => Self::DomainName(dn, port),
        }
    }
}

impl From<&Address> for ServerAddr {
    fn from(addr: &Address) -> Self {
        match *addr {
            Address::SocketAddress(sa) => Self::SocketAddr(sa),
            Address::DomainNameAddress(ref dn, port) => Self::DomainName(dn.clone(), port),
        }
    }
}

impl From<ServerAddr> for Address {
    fn from(addr: ServerAddr) -> Self {
        match addr {
            ServerAddr::SocketAddr(sa) => Self::SocketAddress(sa),
            ServerAddr::DomainName(dn, port) => Self::DomainNameAddress(dn, port),
        }
    }
}

impl From<&ServerAddr> for Address {
    fn from(addr: &ServerAddr) -> Self {
        match *addr {
            ServerAddr::SocketAddr(sa) => Self::SocketAddress(sa),
            ServerAddr::DomainName(ref dn, port) => Self::DomainNameAddress(dn.clone(), port),
        }
    }
}

/// Address for Manager server
#[derive(Debug, Clone)]
pub enum ManagerAddr {
    /// IP address
    SocketAddr(SocketAddr),
    /// Domain name address
    DomainName(String, u16),
    /// Unix socket path
    #[cfg(unix)]
    UnixSocketAddr(PathBuf),
}

/// Error for parsing `ManagerAddr`
#[derive(Debug)]
pub struct ManagerAddrError;

impl Display for ManagerAddrError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str("invalid ManagerAddr")
    }
}

impl FromStr for ManagerAddr {
    type Err = ManagerAddrError;

    fn from_str(s: &str) -> Result<Self, ManagerAddrError> {
        match s.find(':') {
            Some(pos) => {
                // Contains a ':' in address, must be IP:Port or Domain:Port
                match s.parse::<SocketAddr>() {
                    Ok(saddr) => Ok(Self::SocketAddr(saddr)),
                    Err(..) => {
                        // Splits into Domain and Port
                        let (sdomain, sport) = s.split_at(pos);
                        let (sdomain, sport) = (sdomain.trim(), sport[1..].trim());

                        match sport.parse::<u16>() {
                            Ok(port) => Ok(Self::DomainName(sdomain.to_owned(), port)),
                            Err(..) => Err(ManagerAddrError),
                        }
                    }
                }
            }
            #[cfg(unix)]
            None => {
                // Must be a unix socket path
                Ok(Self::UnixSocketAddr(PathBuf::from(s)))
            }
            #[cfg(not(unix))]
            None => Err(ManagerAddrError),
        }
    }
}

impl Display for ManagerAddr {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            Self::SocketAddr(ref saddr) => fmt::Display::fmt(saddr, f),
            Self::DomainName(ref dname, port) => write!(f, "{dname}:{port}"),
            #[cfg(unix)]
            Self::UnixSocketAddr(ref path) => fmt::Display::fmt(&path.display(), f),
        }
    }
}

struct ManagerAddrVisitor;

impl serde::de::Visitor<'_> for ManagerAddrVisitor {
    type Value = ManagerAddr;

    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
        formatter.write_str("ManagerAddr")
    }

    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        match v.parse::<ManagerAddr>() {
            Ok(m) => Ok(m),
            Err(_) => Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(v), &self)),
        }
    }

    fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        self.visit_str::<E>(v.as_str())
    }

    fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        match str::from_utf8(v) {
            Ok(v) => self.visit_str(v),
            Err(_) => Err(serde::de::Error::invalid_value(serde::de::Unexpected::Bytes(v), &self)),
        }
    }

    fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
    where
        E: serde::de::Error,
    {
        match String::from_utf8(v) {
            Ok(v) => self.visit_string(v),
            Err(e) => Err(serde::de::Error::invalid_value(
                serde::de::Unexpected::Bytes(&e.into_bytes()),
                &self,
            )),
        }
    }
}

impl<'de> serde::Deserialize<'de> for ManagerAddr {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_string(ManagerAddrVisitor)
    }
}

impl serde::Serialize for ManagerAddr {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.to_string().as_str())
    }
}

impl From<SocketAddr> for ManagerAddr {
    fn from(addr: SocketAddr) -> Self {
        Self::SocketAddr(addr)
    }
}

impl<'a> From<(&'a str, u16)> for ManagerAddr {
    fn from((dname, port): (&'a str, u16)) -> Self {
        Self::DomainName(dname.to_owned(), port)
    }
}

impl From<(String, u16)> for ManagerAddr {
    fn from((dname, port): (String, u16)) -> Self {
        Self::DomainName(dname, port)
    }
}

#[cfg(unix)]
impl From<PathBuf> for ManagerAddr {
    fn from(p: PathBuf) -> Self {
        Self::UnixSocketAddr(p)
    }
}

/// Policy for handling replay attack requests
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
pub enum ReplayAttackPolicy {
    /// Default strategy based on protocol
    ///
    /// SIP022 (AEAD-2022): Reject
    /// SIP004 (AEAD): Ignore
    /// Stream: Ignore
    #[default]
    Default,
    /// Ignore it completely
    Ignore,
    /// Try to detect replay attack and warn about it
    Detect,
    /// Try to detect replay attack and reject the
Download .txt
gitextract_1sakp8po/

├── .circleci/
│   └── config.yml
├── .dockerignore
├── .github/
│   ├── dependabot.yml
│   └── workflows/
│       ├── build-and-test.yml
│       ├── build-docker-image.yml
│       ├── build-msrv.yml
│       ├── build-nightly-release.yml
│       ├── build-release.yml
│       ├── clippy-check.yml
│       └── deny-check.yml
├── .gitignore
├── .travis.yml
├── Cargo.toml
├── Cross-centos.toml
├── Cross.toml
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── acl/
│   └── genacl_proxy_gfw_bypass_china_ip.py
├── appveyor.yml
├── bin/
│   ├── sslocal.rs
│   ├── ssmanager.rs
│   ├── ssserver.rs
│   ├── ssservice.rs
│   ├── ssurl.rs
│   └── sswinservice.rs
├── build/
│   ├── README.md
│   ├── build-host-release
│   ├── build-host-release.ps1
│   └── build-release
├── cargo-publish.sh
├── clippy.toml
├── configs/
│   ├── genipset.py
│   ├── iptables_mixed.sh
│   ├── iptables_tproxy.sh
│   ├── log4rs.yaml
│   ├── org.shadowsocks.shadowsocks-rust.plist
│   └── shadowsocks.procd.sh
├── crates/
│   ├── shadowsocks/
│   │   ├── Cargo.toml
│   │   ├── LICENSE
│   │   ├── README.md
│   │   ├── src/
│   │   │   ├── config.rs
│   │   │   ├── context.rs
│   │   │   ├── dns_resolver/
│   │   │   │   ├── hickory_dns_resolver.rs
│   │   │   │   ├── mod.rs
│   │   │   │   └── resolver.rs
│   │   │   ├── lib.rs
│   │   │   ├── manager/
│   │   │   │   ├── client.rs
│   │   │   │   ├── datagram.rs
│   │   │   │   ├── error.rs
│   │   │   │   ├── listener.rs
│   │   │   │   ├── mod.rs
│   │   │   │   └── protocol.rs
│   │   │   ├── net/
│   │   │   │   ├── mod.rs
│   │   │   │   ├── option.rs
│   │   │   │   ├── sys/
│   │   │   │   │   ├── mod.rs
│   │   │   │   │   ├── unix/
│   │   │   │   │   │   ├── bsd/
│   │   │   │   │   │   │   ├── freebsd.rs
│   │   │   │   │   │   │   ├── macos.rs
│   │   │   │   │   │   │   ├── mod.rs
│   │   │   │   │   │   │   └── others.rs
│   │   │   │   │   │   ├── linux/
│   │   │   │   │   │   │   └── mod.rs
│   │   │   │   │   │   ├── mod.rs
│   │   │   │   │   │   ├── others.rs
│   │   │   │   │   │   └── uds.rs
│   │   │   │   │   └── windows/
│   │   │   │   │       └── mod.rs
│   │   │   │   ├── tcp.rs
│   │   │   │   └── udp.rs
│   │   │   ├── plugin/
│   │   │   │   ├── mod.rs
│   │   │   │   ├── obfs_proxy.rs
│   │   │   │   └── ss_plugin.rs
│   │   │   ├── relay/
│   │   │   │   ├── mod.rs
│   │   │   │   ├── socks5.rs
│   │   │   │   ├── tcprelay/
│   │   │   │   │   ├── aead.rs
│   │   │   │   │   ├── aead_2022.rs
│   │   │   │   │   ├── crypto_io.rs
│   │   │   │   │   ├── mod.rs
│   │   │   │   │   ├── proxy_listener.rs
│   │   │   │   │   ├── proxy_stream/
│   │   │   │   │   │   ├── client.rs
│   │   │   │   │   │   ├── mod.rs
│   │   │   │   │   │   ├── protocol/
│   │   │   │   │   │   │   ├── mod.rs
│   │   │   │   │   │   │   ├── v1.rs
│   │   │   │   │   │   │   └── v2.rs
│   │   │   │   │   │   └── server.rs
│   │   │   │   │   ├── stream.rs
│   │   │   │   │   └── utils.rs
│   │   │   │   └── udprelay/
│   │   │   │       ├── aead.rs
│   │   │   │       ├── aead_2022.rs
│   │   │   │       ├── compat.rs
│   │   │   │       ├── crypto_io.rs
│   │   │   │       ├── mod.rs
│   │   │   │       ├── options.rs
│   │   │   │       ├── proxy_socket.rs
│   │   │   │       └── stream.rs
│   │   │   └── security/
│   │   │       ├── mod.rs
│   │   │       └── replay/
│   │   │           ├── mod.rs
│   │   │           └── ppbloom.rs
│   │   └── tests/
│   │       ├── tcp.rs
│   │       ├── tcp_tfo.rs
│   │       └── udp.rs
│   └── shadowsocks-service/
│       ├── Cargo.toml
│       ├── README.md
│       └── src/
│           ├── acl/
│           │   ├── mod.rs
│           │   └── sub_domains_tree.rs
│           ├── config.rs
│           ├── dns/
│           │   └── mod.rs
│           ├── lib.rs
│           ├── local/
│           │   ├── context.rs
│           │   ├── dns/
│           │   │   ├── client_cache.rs
│           │   │   ├── config.rs
│           │   │   ├── dns_resolver.rs
│           │   │   ├── mod.rs
│           │   │   ├── server.rs
│           │   │   └── upstream.rs
│           │   ├── fake_dns/
│           │   │   ├── manager.rs
│           │   │   ├── mod.rs
│           │   │   ├── processor.rs
│           │   │   ├── proto.rs
│           │   │   ├── server.rs
│           │   │   ├── tcp_server.rs
│           │   │   └── udp_server.rs
│           │   ├── http/
│           │   │   ├── config.rs
│           │   │   ├── http_client.rs
│           │   │   ├── http_service.rs
│           │   │   ├── http_stream.rs
│           │   │   ├── mod.rs
│           │   │   ├── server.rs
│           │   │   ├── tokio_rt.rs
│           │   │   └── utils.rs
│           │   ├── loadbalancing/
│           │   │   ├── mod.rs
│           │   │   ├── ping_balancer.rs
│           │   │   ├── server_data.rs
│           │   │   └── server_stat.rs
│           │   ├── mod.rs
│           │   ├── net/
│           │   │   ├── mod.rs
│           │   │   ├── tcp/
│           │   │   │   ├── auto_proxy_io.rs
│           │   │   │   ├── auto_proxy_stream.rs
│           │   │   │   ├── listener.rs
│           │   │   │   └── mod.rs
│           │   │   └── udp/
│           │   │       ├── association.rs
│           │   │       ├── listener.rs
│           │   │       └── mod.rs
│           │   ├── online_config/
│           │   │   ├── content_encoding.rs
│           │   │   └── mod.rs
│           │   ├── redir/
│           │   │   ├── mod.rs
│           │   │   ├── redir_ext.rs
│           │   │   ├── server.rs
│           │   │   ├── sys/
│           │   │   │   ├── mod.rs
│           │   │   │   └── unix/
│           │   │   │       ├── bsd_pf.rs
│           │   │   │       ├── mod.rs
│           │   │   │       ├── pfvar_bindgen_freebsd.rs
│           │   │   │       ├── pfvar_bindgen_macos.rs
│           │   │   │       └── pfvar_bindgen_openbsd.rs
│           │   │   ├── tcprelay/
│           │   │   │   ├── mod.rs
│           │   │   │   └── sys/
│           │   │   │       ├── mod.rs
│           │   │   │       ├── unix/
│           │   │   │       │   ├── bsd.rs
│           │   │   │       │   ├── linux.rs
│           │   │   │       │   ├── mod.rs
│           │   │   │       │   └── not_supported.rs
│           │   │   │       └── windows/
│           │   │   │           └── mod.rs
│           │   │   └── udprelay/
│           │   │       ├── mod.rs
│           │   │       └── sys/
│           │   │           ├── mod.rs
│           │   │           ├── unix/
│           │   │           │   ├── freebsd.rs
│           │   │           │   ├── linux.rs
│           │   │           │   ├── macos.rs
│           │   │           │   ├── mod.rs
│           │   │           │   ├── not_supported.rs
│           │   │           │   └── openbsd.rs
│           │   │           └── windows/
│           │   │               └── mod.rs
│           │   ├── socks/
│           │   │   ├── client/
│           │   │   │   ├── mod.rs
│           │   │   │   ├── socks4/
│           │   │   │   │   ├── mod.rs
│           │   │   │   │   └── tcp_client.rs
│           │   │   │   └── socks5/
│           │   │   │       ├── mod.rs
│           │   │   │       ├── tcp_client.rs
│           │   │   │       └── udp_client.rs
│           │   │   ├── config.rs
│           │   │   ├── mod.rs
│           │   │   ├── server/
│           │   │   │   ├── mod.rs
│           │   │   │   ├── server.rs
│           │   │   │   ├── socks4/
│           │   │   │   │   ├── mod.rs
│           │   │   │   │   └── tcprelay.rs
│           │   │   │   └── socks5/
│           │   │   │       ├── mod.rs
│           │   │   │       ├── tcprelay.rs
│           │   │   │       └── udprelay.rs
│           │   │   └── socks4.rs
│           │   ├── tun/
│           │   │   ├── fake_tun.rs
│           │   │   ├── ip_packet.rs
│           │   │   ├── mod.rs
│           │   │   ├── tcp.rs
│           │   │   ├── udp.rs
│           │   │   └── virt_device.rs
│           │   ├── tunnel/
│           │   │   ├── mod.rs
│           │   │   ├── server.rs
│           │   │   ├── tcprelay.rs
│           │   │   └── udprelay.rs
│           │   └── utils.rs
│           ├── manager/
│           │   ├── mod.rs
│           │   └── server.rs
│           ├── net/
│           │   ├── flow.rs
│           │   ├── launch_activate_socket.rs
│           │   ├── mod.rs
│           │   ├── mon_socket.rs
│           │   ├── mon_stream.rs
│           │   ├── packet_window.rs
│           │   └── utils.rs
│           ├── server/
│           │   ├── context.rs
│           │   ├── mod.rs
│           │   ├── server.rs
│           │   ├── tcprelay.rs
│           │   └── udprelay.rs
│           ├── sys/
│           │   ├── mod.rs
│           │   └── unix/
│           │       ├── macos.rs
│           │       └── mod.rs
│           └── utils.rs
├── debian/
│   ├── .gitignore
│   ├── changelog
│   ├── compat
│   ├── config.json
│   ├── control
│   ├── copyright
│   ├── install
│   ├── rules
│   ├── shadowsocks-rust-local@.service
│   ├── shadowsocks-rust-server@.service
│   ├── shadowsocks-rust.default
│   ├── shadowsocks-rust.init
│   ├── shadowsocks-rust.postinst
│   ├── shadowsocks-rust.service
│   └── source/
│       └── format
├── deny.toml
├── docker/
│   ├── Dockerfile.v2ray
│   ├── docker-entrypoint.sh
│   └── linux-cross/
│       └── Dockerfile
├── examples/
│   ├── config.json
│   └── config_ext.json
├── homebrew/
│   └── shadowsocks-rust.rb
├── k8s/
│   ├── chart/
│   │   ├── .helmignore
│   │   ├── Chart.yaml
│   │   ├── templates/
│   │   │   ├── NOTES.txt
│   │   │   ├── _helpers.tpl
│   │   │   ├── config.yaml
│   │   │   ├── deployment.yaml
│   │   │   ├── hpa.yaml
│   │   │   ├── service.yaml
│   │   │   ├── serviceaccount.yaml
│   │   │   └── tests/
│   │   │       └── test-connection.yaml
│   │   └── values.yaml
│   └── shadowsocks-rust.yaml
├── rustfmt.toml
├── selinux/
│   ├── README.md
│   ├── shadowsocks.fc
│   └── shadowsocks.te
├── snap/
│   └── snapcraft.yaml
├── src/
│   ├── allocator/
│   │   └── mod.rs
│   ├── config.rs
│   ├── daemonize/
│   │   ├── daemonize/
│   │   │   ├── error.rs
│   │   │   └── mod.rs
│   │   ├── mod.rs
│   │   └── unix.rs
│   ├── error.rs
│   ├── lib.rs
│   ├── logging/
│   │   ├── log4rs.rs
│   │   ├── mod.rs
│   │   └── tracing.rs
│   ├── monitor/
│   │   ├── mod.rs
│   │   ├── other.rs
│   │   ├── unix.rs
│   │   └── windows.rs
│   ├── password.rs
│   ├── service/
│   │   ├── genkey.rs
│   │   ├── local.rs
│   │   ├── manager.rs
│   │   ├── mod.rs
│   │   └── server.rs
│   ├── sys.rs
│   └── vparser/
│       └── mod.rs
└── tests/
    ├── dns.rs
    ├── http.rs
    ├── socks4.rs
    ├── socks5.rs
    ├── tunnel.rs
    └── udp.rs
Download .txt
Showing preview only (832K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (10153 symbols across 176 files)

FILE: acl/genacl_proxy_gfw_bypass_china_ip.py
  function fetch_url_content (line 26) | def fetch_url_content(url):
  function write_gfw_list (line 32) | def write_gfw_list(fp):
  function write_china_ip (line 40) | def write_china_ip(fp):

FILE: bin/sslocal.rs
  function main (line 12) | fn main() -> ExitCode {

FILE: bin/ssmanager.rs
  function main (line 15) | fn main() -> ExitCode {

FILE: bin/ssserver.rs
  function main (line 15) | fn main() -> ExitCode {

FILE: bin/ssservice.rs
  function main (line 15) | fn main() -> ExitCode {

FILE: bin/ssurl.rs
  constant VERSION (line 17) | const VERSION: &str = env!("CARGO_PKG_VERSION");
  constant BLACK (line 19) | const BLACK: &str = "\x1b[40m  \x1b[0m";
  constant WHITE (line 20) | const WHITE: &str = "\x1b[47m  \x1b[0m";
  function print_qrcode (line 22) | fn print_qrcode(encoded: &str) {
  function encode (line 49) | fn encode(filename: &str, need_qrcode: bool) {
  function decode (line 64) | fn decode(encoded: &str, need_qrcode: bool) {
  function decode_outline (line 78) | fn decode_outline(remote: &str, need_qrcode: bool) {
  function main (line 98) | fn main() -> ExitCode {

FILE: bin/sswinservice.rs
  constant SERVICE_NAME (line 22) | const SERVICE_NAME: &str = "ssservice";
  constant SERVICE_EXIT_CODE_ARGUMENT_ERROR (line 23) | const SERVICE_EXIT_CODE_ARGUMENT_ERROR: u32 = 100;
  constant SERVICE_EXIT_CODE_EXITED_UNEXPECTEDLY (line 24) | const SERVICE_EXIT_CODE_EXITED_UNEXPECTEDLY: u32 = 101;
  constant SERVICE_EXIT_CODE_CREATE_FAILED (line 25) | const SERVICE_EXIT_CODE_CREATE_FAILED: u32 = 102;
  function set_service_status (line 28) | fn set_service_status(
  function handle_create_service_result (line 56) | fn handle_create_service_result<F>(
  function service_main (line 122) | fn service_main(arguments: Vec<OsString>) -> Result<(), windows_service:...
  function service_entry (line 196) | fn service_entry(arguments: Vec<OsString>) {
  function main (line 204) | fn main() -> Result<(), windows_service::Error> {

FILE: configs/genipset.py
  function get_apnic_delegated (line 10) | def get_apnic_delegated():
  function generate_ipset (line 17) | def generate_ipset(content, name, location_set, type_set, output_file):

FILE: crates/shadowsocks-service/src/acl/mod.rs
  type Mode (line 30) | pub enum Mode {
  type Rules (line 38) | struct Rules {
    method fmt (line 47) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    method new (line 88) | fn new(
    method check_address_matched (line 110) | fn check_address_matched(&self, addr: &Address) -> bool {
    method check_ip_matched (line 118) | fn check_ip_matched(&self, addr: &IpAddr) -> bool {
    method check_host_matched (line 143) | fn check_host_matched(&self, host: &str) -> bool {
    method is_ip_empty (line 149) | fn is_ip_empty(&self) -> bool {
    method is_host_empty (line 154) | fn is_host_empty(&self) -> bool {
  type ParsingRules (line 159) | struct ParsingRules {
    method new (line 169) | fn new(name: &'static str) -> Self {
    method add_ipv4_rule (line 180) | fn add_ipv4_rule(&mut self, rule: impl Into<Ipv4Net>) {
    method add_ipv6_rule (line 186) | fn add_ipv6_rule(&mut self, rule: impl Into<Ipv6Net>) {
    method add_regex_rule (line 192) | fn add_regex_rule(&mut self, mut rule: String) {
    method add_set_rule (line 232) | fn add_set_rule(&mut self, rule: &str) -> io::Result<()> {
    method add_set_rule_inner (line 237) | fn add_set_rule_inner(&mut self, rule: &str) -> io::Result<()> {
    method add_tree_rule (line 243) | fn add_tree_rule(&mut self, rule: &str) -> io::Result<()> {
    method add_tree_rule_inner (line 248) | fn add_tree_rule_inner(&mut self, rule: &str) -> io::Result<()> {
    method check_is_ascii (line 254) | fn check_is_ascii<'a>(&self, str: &'a str) -> io::Result<&'a str> {
    method compile_regex (line 266) | fn compile_regex(name: &'static str, regex_rules: Vec<String>) -> io::...
    method into_rules (line 275) | fn into_rules(self) -> io::Result<Rules> {
  type AccessControl (line 339) | pub struct AccessControl {
    method load_from_file (line 351) | pub fn load_from_file<P: AsRef<Path>>(p: P) -> io::Result<Self> {
    method file_path (line 471) | pub fn file_path(&self) -> &Path {
    method check_host_in_proxy_list (line 482) | pub fn check_host_in_proxy_list(&self, host: &str) -> Option<bool> {
    method check_ascii_host_in_proxy_list (line 494) | pub fn check_ascii_host_in_proxy_list(&self, host: &str) -> Option<boo...
    method is_ip_empty (line 508) | pub fn is_ip_empty(&self) -> bool {
    method is_host_empty (line 514) | pub fn is_host_empty(&self) -> bool {
    method check_ip_in_proxy_list (line 519) | pub fn check_ip_in_proxy_list(&self, ip: &IpAddr) -> bool {
    method is_default_in_proxy_list (line 537) | pub fn is_default_in_proxy_list(&self) -> bool {
    method convert_to_ascii (line 546) | fn convert_to_ascii(host: &str) -> Cow<'_, str> {
    method check_target_bypassed (line 555) | pub async fn check_target_bypassed(&self, context: &Context, addr: &Ad...
    method check_client_blocked (line 590) | pub fn check_client_blocked(&self, addr: &SocketAddr) -> bool {
    method check_outbound_blocked (line 607) | pub async fn check_outbound_blocked(&self, context: &Context, outbound...
    method check_outbound_ip_blocked (line 648) | fn check_outbound_ip_blocked(&self, ip: &IpAddr) -> bool {
    method is_outbound_default_blocked (line 662) | fn is_outbound_default_blocked(&self) -> bool {

FILE: crates/shadowsocks-service/src/acl/sub_domains_tree.rs
  type DomainPart (line 7) | struct DomainPart {
    method new (line 13) | fn new() -> Self {
  type SubDomainsTree (line 22) | pub struct SubDomainsTree(HashMap<String, DomainPart>);
    method new (line 31) | pub fn new() -> Self {
    method insert (line 35) | pub fn insert(&mut self, value: &str) {
    method contains (line 56) | pub fn contains(&self, value: &str) -> bool {
    method is_empty (line 71) | pub fn is_empty(&self) -> bool {
  method fmt (line 25) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

FILE: crates/shadowsocks-service/src/config.rs
  type SSDnsConfig (line 90) | enum SSDnsConfig {
  type SSSecurityConfig (line 97) | struct SSSecurityConfig {
  type SSSecurityReplayAttackConfig (line 103) | struct SSSecurityReplayAttackConfig {
  type SSBalancerConfig (line 109) | struct SSBalancerConfig {
  type SSConfig (line 119) | struct SSConfig {
  type SSLocalExtConfig (line 242) | struct SSLocalExtConfig {
  type SSServerUserConfig (line 352) | struct SSServerUserConfig {
  type SSServerExtConfig (line 358) | struct SSServerExtConfig {
  type SSOnlineConfig (line 425) | struct SSOnlineConfig {
  type ConfigType (line 435) | pub enum ConfigType {
    method is_local (line 453) | pub fn is_local(self) -> bool {
    method is_server (line 458) | pub fn is_server(self) -> bool {
    method is_manager (line 463) | pub fn is_manager(self) -> bool {
    method is_online_config (line 469) | pub fn is_online_config(self) -> bool {
  type ManagerServerHost (line 727) | pub enum ManagerServerHost {
  method default (line 735) | fn default() -> Self {
  type Err (line 741) | type Err = Infallible;
  method from_str (line 743) | fn from_str(s: &str) -> Result<Self, Self::Err> {
  type ManagerServerMode (line 753) | pub enum ManagerServerMode {
  type ManagerServerModeError (line 765) | pub struct ManagerServerModeError;
  method fmt (line 768) | fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
  type Err (line 774) | type Err = ManagerServerModeError;
  method from_str (line 776) | fn from_str(s: &str) -> Result<Self, Self::Err> {
  method fmt (line 787) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type ManagerConfig (line 798) | pub struct ManagerConfig {
    method new (line 825) | pub fn new(addr: ManagerAddr) -> Self {
  type ProtocolType (line 847) | pub enum ProtocolType {
    method as_str (line 866) | pub fn as_str(&self) -> &'static str {
    method available_protocols (line 885) | pub fn available_protocols() -> &'static [&'static str] {
  type ProtocolTypeError (line 906) | pub struct ProtocolTypeError;
  method fmt (line 909) | fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
  type Err (line 915) | type Err = ProtocolTypeError;
  method from_str (line 917) | fn from_str(s: &str) -> Result<Self, Self::Err> {
  type LocalConfig (line 939) | pub struct LocalConfig {
    method new (line 1068) | pub fn new(protocol: ProtocolType) -> Self {
    method new_with_addr (line 1137) | pub fn new_with_addr(addr: ServerAddr, protocol: ProtocolType) -> Self {
    method check_integrity (line 1143) | fn check_integrity(&self) -> Result<(), Error> {
    method is_basic (line 1191) | pub fn is_basic(&self) -> bool {
  type DnsConfig (line 1216) | pub enum DnsConfig {
  type SecurityConfig (line 1227) | pub struct SecurityConfig {
  type SecurityReplayAttackConfig (line 1232) | pub struct SecurityReplayAttackConfig {
  type BalancerConfig (line 1238) | pub struct BalancerConfig {
  type LocalFlowStatAddress (line 1250) | pub enum LocalFlowStatAddress {
  type ServerInstanceConfig (line 1260) | pub struct ServerInstanceConfig {
    method with_server_config (line 1277) | pub fn with_server_config(config: ServerConfig) -> Self {
  type LocalInstanceConfig (line 1294) | pub struct LocalInstanceConfig {
    method with_local_config (line 1303) | pub fn with_local_config(config: LocalConfig) -> Self {
  type OnlineConfig (line 1312) | pub struct OnlineConfig {
  type Config (line 1323) | pub struct Config {
    method new (line 1497) | pub fn new(config_type: ConfigType) -> Self {
    method load_from_ssconfig (line 1554) | fn load_from_ssconfig(config: SSConfig, config_type: ConfigType) -> Re...
    method set_dns_formatted (line 2462) | pub fn set_dns_formatted(&mut self, dns: &str) -> Result<(), Error> {
    method parse_dns_nameservers (line 2496) | fn parse_dns_nameservers(&mut self, nameservers: &str) -> Result<DnsCo...
    method parse_dns_nameservers (line 2580) | fn parse_dns_nameservers(&mut self, _nameservers: &str) -> Result<DnsC...
    method load_from_str (line 2585) | pub fn load_from_str(s: &str, config_type: ConfigType) -> Result<Self,...
    method load_from_json_str (line 2591) | pub fn load_from_json_str(s: &str, config_type: ConfigType) -> Result<...
    method load_from_file (line 2597) | pub fn load_from_file<P: AsRef<Path>>(filename: P, config_type: Config...
    method has_server_plugins (line 2613) | pub fn has_server_plugins(&self) -> bool {
    method check_integrity (line 2625) | pub fn check_integrity(&self) -> Result<(), Error> {
    method fmt (line 2776) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type ErrorKind (line 1431) | pub enum ErrorKind {
  type Error (line 1445) | pub struct Error {
    method new (line 1452) | pub fn new(kind: ErrorKind, desc: &'static str, detail: Option<String>...
    method description (line 1458) | fn description(&self) -> &str {
  method fmt (line 1478) | fn fmt(&self, f: &mut Formatter) -> fmt::Result {
  method fmt (line 1487) | fn fmt(&self, f: &mut Formatter) -> fmt::Result {
  function read_variable_field_value (line 3217) | pub fn read_variable_field_value(value: &str) -> Cow<'_, str> {

FILE: crates/shadowsocks-service/src/dns/mod.rs
  function build_dns_resolver (line 11) | pub async fn build_dns_resolver(

FILE: crates/shadowsocks-service/src/lib.rs
  constant DEFAULT_UDP_EXPIRY_DURATION (line 77) | const DEFAULT_UDP_EXPIRY_DURATION: Duration = Duration::from_secs(5 * 60);
  function hint_support_default_system_resolver (line 80) | fn hint_support_default_system_resolver() -> bool {

FILE: crates/shadowsocks-service/src/local/context.rs
  type ServiceContext (line 28) | pub struct ServiceContext {
    method new (line 55) | pub fn new() -> Self {
    method context (line 73) | pub fn context(&self) -> SharedContext {
    method context_ref (line 78) | pub fn context_ref(&self) -> &Context {
    method set_connect_opts (line 83) | pub fn set_connect_opts(&mut self, connect_opts: ConnectOpts) {
    method connect_opts_ref (line 88) | pub fn connect_opts_ref(&self) -> &ConnectOpts {
    method set_accept_opts (line 93) | pub fn set_accept_opts(&mut self, accept_opts: AcceptOpts) {
    method accept_opts (line 98) | pub fn accept_opts(&self) -> AcceptOpts {
    method set_acl (line 103) | pub fn set_acl(&mut self, acl: Arc<AccessControl>) {
    method acl (line 108) | pub fn acl(&self) -> Option<&AccessControl> {
    method flow_stat (line 113) | pub fn flow_stat(&self) -> Arc<FlowStat> {
    method flow_stat_ref (line 118) | pub fn flow_stat_ref(&self) -> &FlowStat {
    method set_dns_resolver (line 123) | pub fn set_dns_resolver(&mut self, resolver: Arc<DnsResolver>) {
    method dns_resolver (line 129) | pub fn dns_resolver(&self) -> &DnsResolver {
    method check_target_bypassed (line 134) | pub async fn check_target_bypassed(&self, addr: &Address) -> bool {
    method add_to_reverse_lookup_cache (line 157) | pub async fn add_to_reverse_lookup_cache(&self, addr: IpAddr, forward:...
    method set_ipv6_first (line 183) | pub fn set_ipv6_first(&mut self, ipv6_first: bool) {
    method set_security_config (line 189) | pub fn set_security_config(&mut self, security: &SecurityConfig) {
    method add_fake_dns_manager (line 196) | pub async fn add_fake_dns_manager(&self, manager: Arc<FakeDnsManager>) {
    method try_map_fake_address (line 203) | pub async fn try_map_fake_address(&self, addr: &Address) -> Option<Add...
  method default (line 48) | fn default() -> Self {

FILE: crates/shadowsocks-service/src/local/dns/client_cache.rs
  type DnsClientKey (line 24) | enum DnsClientKey {
  type DnsClientCache (line 31) | pub struct DnsClientCache {
    method new (line 39) | pub fn new(max_client_per_addr: usize) -> Self {
    method lookup_local (line 48) | pub async fn lookup_local(
    method lookup_remote (line 62) | pub async fn lookup_remote(
    method lookup_unix_stream (line 78) | pub async fn lookup_unix_stream<P: AsRef<Path>>(&self, ns: &P, msg: Me...
    method lookup_dns (line 109) | async fn lookup_dns(
    method get_client_or_create (line 177) | async fn get_client_or_create<C>(&self, key: &DnsClientKey, create_fn:...
    method save_client (line 198) | async fn save_client(&self, key: DnsClientKey, client: DnsClient) {

FILE: crates/shadowsocks-service/src/local/dns/config.rs
  type NameServerAddr (line 13) | pub enum NameServerAddr {
  type NameServerAddrError (line 25) | pub type NameServerAddrError = Infallible;
  type NameServerAddrError (line 28) | pub type NameServerAddrError = <SocketAddr as FromStr>::Err;
  type Err (line 31) | type Err = NameServerAddrError;
  method from_str (line 33) | fn from_str(s: &str) -> Result<Self, Self::Err> {
  method fmt (line 49) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

FILE: crates/shadowsocks-service/src/local/dns/dns_resolver.rs
  type DnsResolver (line 19) | pub struct DnsResolver {
    method new (line 29) | pub fn new(ns: NameServerAddr) -> Self {
    method set_mode (line 40) | pub fn set_mode(&mut self, mode: Mode) {
    method set_ipv6_first (line 44) | pub fn set_ipv6_first(&mut self, ipv6_first: bool) {
    method set_connect_opts (line 48) | pub fn set_connect_opts(&mut self, connect_opts: ConnectOpts) {
    method lookup (line 52) | async fn lookup(&self, msg: Message) -> io::Result<Message> {
    method lookup_inner (line 65) | async fn lookup_inner(&self, msg: Message) -> io::Result<Message> {
  method resolve (line 107) | async fn resolve(&self, host: &str, port: u16) -> io::Result<Vec<SocketA...
  function store_dns (line 172) | fn store_dns(res: Message, port: u16) -> Vec<SocketAddr> {

FILE: crates/shadowsocks-service/src/local/dns/server.rs
  type DnsBuilder (line 51) | pub struct DnsBuilder {
    method new (line 67) | pub fn new(
    method with_context (line 86) | pub fn with_context(
    method set_mode (line 110) | pub fn set_mode(&mut self, mode: Mode) {
    method set_launchd_tcp_socket_name (line 116) | pub fn set_launchd_tcp_socket_name(&mut self, n: String) {
    method set_launchd_udp_socket_name (line 122) | pub fn set_launchd_udp_socket_name(&mut self, n: String) {
    method build (line 127) | pub async fn build(self) -> io::Result<Dns> {
  type DnsTcpServerBuilder (line 176) | struct DnsTcpServerBuilder {
    method new (line 187) | fn new(
    method set_launchd_socket_name (line 207) | fn set_launchd_socket_name(&mut self, n: String) {
    method build (line 211) | async fn build(self) -> io::Result<DnsTcpServer> {
  type DnsTcpServer (line 241) | pub struct DnsTcpServer {
    method local_addr (line 250) | pub fn local_addr(&self) -> io::Result<SocketAddr> {
    method run (line 255) | pub async fn run(self) -> io::Result<()> {
    method handle_tcp_stream (line 283) | async fn handle_tcp_stream(
  type DnsUdpServerBuilder (line 351) | struct DnsUdpServerBuilder {
    method new (line 362) | fn new(
    method set_launchd_socket_name (line 382) | fn set_launchd_socket_name(&mut self, n: String) {
    method build (line 386) | async fn build(self) -> io::Result<DnsUdpServer> {
  type DnsUdpServer (line 413) | pub struct DnsUdpServer {
    method local_addr (line 422) | pub fn local_addr(&self) -> io::Result<SocketAddr> {
    method run (line 427) | pub async fn run(self) -> io::Result<()> {
    method handle_udp_packet (line 467) | async fn handle_udp_packet(
  type Dns (line 491) | pub struct Dns {
    method tcp_server (line 498) | pub fn tcp_server(&self) -> Option<&DnsTcpServer> {
    method udp_server (line 503) | pub fn udp_server(&self) -> Option<&DnsUdpServer> {
    method run (line 508) | pub async fn run(self) -> io::Result<()> {
  function should_forward_by_ptr_name (line 526) | fn should_forward_by_ptr_name(acl: &AccessControl, name: &Name) -> bool {
  function check_name_in_proxy_list (line 569) | fn check_name_in_proxy_list(acl: &AccessControl, name: &Name) -> Option<...
  function should_forward_by_query (line 582) | fn should_forward_by_query(context: &ServiceContext, balancer: &PingBala...
  function should_forward_by_response (line 634) | fn should_forward_by_response(
  type DnsClient (line 714) | struct DnsClient {
    method new (line 723) | fn new(context: Arc<ServiceContext>, balancer: PingBalancer, mode: Mod...
    method resolve (line 733) | async fn resolve(
    method acl_lookup (line 784) | async fn acl_lookup(
    method lookup_remote (line 847) | async fn lookup_remote(&self, query: &Query, remote_addr: &Address) ->...
    method lookup_remote_inner (line 862) | async fn lookup_remote_inner(&self, query: &Query, remote_addr: &Addre...
    method lookup_local (line 926) | async fn lookup_local(&self, query: &Query, local_addr: &NameServerAdd...
    method lookup_local_inner (line 941) | async fn lookup_local_inner(&self, query: &Query, local_addr: &NameSer...

FILE: crates/shadowsocks-service/src/local/dns/upstream.rs
  type DnsClient (line 44) | pub enum DnsClient {
    method connect_tcp_local (line 69) | pub async fn connect_tcp_local(ns: SocketAddr, connect_opts: &ConnectO...
    method connect_udp_local (line 75) | pub async fn connect_udp_local(ns: SocketAddr, connect_opts: &ConnectO...
    method connect_unix_stream (line 82) | pub async fn connect_unix_stream<P: AsRef<Path>>(path: &P) -> io::Resu...
    method connect_tcp_remote (line 88) | pub async fn connect_tcp_remote(
    method connect_udp_remote (line 103) | pub async fn connect_udp_remote(
    method lookup (line 126) | pub async fn lookup(&mut self, mut msg: Message) -> Result<Message, Pr...
    method lookup_timeout (line 131) | pub async fn lookup_timeout(&mut self, mut msg: Message, timeout: Dura...
    method inner_lookup (line 139) | async fn inner_lookup(&mut self, msg: &mut Message) -> Result<Message,...
    method check_connected (line 201) | pub async fn check_connected(&mut self) -> bool {
  function stream_query (line 271) | pub async fn stream_query<S>(stream: &mut S, r: &Message) -> Result<Mess...

FILE: crates/shadowsocks-service/src/local/fake_dns/manager.rs
  constant FAKE_DNS_MANAGER_STORAGE_VERSION (line 19) | const FAKE_DNS_MANAGER_STORAGE_VERSION: u32 = 3;
  type FakeDnsError (line 23) | pub enum FakeDnsError {
  function from (line 33) | fn from(value: FakeDnsError) -> Self {
  type FakeDnsResult (line 42) | pub type FakeDnsResult<T> = Result<T, FakeDnsError>;
  type FakeDnsManager (line 45) | pub struct FakeDnsManager {
    method open (line 150) | pub fn open<P: AsRef<Path>>(
    method get_current_timestamp (line 250) | fn get_current_timestamp() -> i64 {
    method get_name2ip_key (line 258) | fn get_name2ip_key(domain: &Name) -> String {
    method get_ip2name_key (line 263) | fn get_ip2name_key(ip: IpAddr) -> String {
    method map_domain_ipv4 (line 268) | pub async fn map_domain_ipv4(&self, domain: &Name) -> FakeDnsResult<(I...
    method map_domain_ipv6 (line 273) | pub async fn map_domain_ipv6(&self, domain: &Name) -> FakeDnsResult<(I...
    method map_ip_domain (line 278) | pub async fn map_ip_domain(&self, ip: IpAddr) -> FakeDnsResult<Option<...

FILE: crates/shadowsocks-service/src/local/fake_dns/processor.rs
  function handle_dns_request (line 16) | pub async fn handle_dns_request(req_message: &Message, manager: &FakeDns...

FILE: crates/shadowsocks-service/src/local/fake_dns/proto.rs
  type StorageMeta (line 8) | pub struct StorageMeta {
    method decode (line 15) | pub fn decode(v: &[u8]) -> io::Result<Self> {
    method encode_to_vec (line 19) | pub fn encode_to_vec(&self) -> io::Result<Vec<u8>> {
  type IpAddrMapping (line 25) | pub struct IpAddrMapping {
    method decode (line 31) | pub fn decode(v: &[u8]) -> io::Result<Self> {
    method encode_to_vec (line 35) | pub fn encode_to_vec(&self) -> io::Result<Vec<u8>> {
  type DomainNameMapping (line 41) | pub struct DomainNameMapping {
    method decode (line 48) | pub fn decode(v: &[u8]) -> io::Result<Self> {
    method encode_to_vec (line 52) | pub fn encode_to_vec(&self) -> io::Result<Vec<u8>> {

FILE: crates/shadowsocks-service/src/local/fake_dns/server.rs
  type FakeDnsBuilder (line 20) | pub struct FakeDnsBuilder {
    method new (line 32) | pub fn new(client_addr: ServerAddr) -> Self {
    method with_context (line 38) | pub fn with_context(context: Arc<ServiceContext>, client_addr: ServerA...
    method set_ipv4_network (line 51) | pub fn set_ipv4_network(&mut self, ipv4_network: Ipv4Net) {
    method set_ipv6_network (line 56) | pub fn set_ipv6_network(&mut self, ipv6_network: Ipv6Net) {
    method set_expire_duration (line 61) | pub fn set_expire_duration(&mut self, expire: Duration) {
    method set_database_path (line 66) | pub fn set_database_path<P: AsRef<Path>>(&mut self, database_path: P) {
    method build (line 71) | pub async fn build(self) -> io::Result<FakeDns> {
  type FakeDns (line 101) | pub struct FakeDns {
    method tcp_server (line 109) | pub fn tcp_server(&self) -> Option<&FakeDnsTcpServer> {
    method udp_server (line 114) | pub fn udp_server(&self) -> Option<&FakeDnsUdpServer> {
    method clone_manager (line 119) | pub fn clone_manager(&self) -> Arc<FakeDnsManager> {
    method run (line 124) | pub async fn run(self) -> io::Result<()> {

FILE: crates/shadowsocks-service/src/local/fake_dns/tcp_server.rs
  type FakeDnsTcpServer (line 29) | pub struct FakeDnsTcpServer {
    method new (line 36) | pub(crate) async fn new(
    method local_addr (line 61) | pub fn local_addr(&self) -> io::Result<SocketAddr> {
    method run (line 66) | pub async fn run(self) -> io::Result<()> {
    method handle_client (line 92) | async fn handle_client(

FILE: crates/shadowsocks-service/src/local/fake_dns/udp_server.rs
  type FakeDnsUdpServer (line 15) | pub struct FakeDnsUdpServer {
    method new (line 21) | pub(crate) async fn new(
    method local_addr (line 42) | pub fn local_addr(&self) -> io::Result<SocketAddr> {
    method run (line 47) | pub async fn run(self) -> io::Result<()> {

FILE: crates/shadowsocks-service/src/local/http/config.rs
  constant BASIC_AUTH_BASE64_ENGINE (line 14) | const BASIC_AUTH_BASE64_ENGINE: base64::engine::GeneralPurpose = base64:...
  type SSHttpAuthBasicUserConfig (line 22) | struct SSHttpAuthBasicUserConfig {
  type SSHttpAuthBasicConfig (line 28) | struct SSHttpAuthBasicConfig {
  type SSHttpAuthConfig (line 33) | struct SSHttpAuthConfig {
  type HttpAuthConfig (line 40) | pub struct HttpAuthConfig {
    method new (line 46) | pub fn new() -> Self {
    method load_from_file (line 65) | pub fn load_from_file<P: AsRef<Path> + ?Sized>(filename: &P) -> io::Re...
    method auth_required (line 93) | pub fn auth_required(&self) -> bool {
    method verify_basic_auth (line 98) | pub fn verify_basic_auth(&self, header_value: &str) -> bool {
  method default (line 122) | fn default() -> Self {
  type HttpAuthBasicConfig (line 131) | pub struct HttpAuthBasicConfig {
    method new (line 137) | pub fn new() -> Self {
    method add_user (line 142) | pub fn add_user<U, P>(&mut self, user_name: U, password: P)
    method check_user (line 151) | pub fn check_user<U, P>(&self, user_name: U, password: P) -> bool
    method total_users (line 163) | pub fn total_users(&self) -> usize {
  method default (line 169) | fn default() -> Self {

FILE: crates/shadowsocks-service/src/local/http/http_client.rs
  constant CONNECTION_EXPIRE_DURATION (line 37) | const CONNECTION_EXPIRE_DURATION: Duration = Duration::from_secs(20);
  type HttpClientError (line 41) | pub enum HttpClientError {
  type SendRequestError (line 58) | enum SendRequestError<B> {
  type TokioTimer (line 67) | pub struct TokioTimer;
  method sleep (line 70) | fn sleep(&self, duration: Duration) -> Pin<Box<dyn Sleep>> {
  method sleep_until (line 76) | fn sleep_until(&self, deadline: Instant) -> Pin<Box<dyn Sleep>> {
  method reset (line 82) | fn reset(&self, sleep: &mut Pin<Box<dyn Sleep>>, new_deadline: Instant) {
  type TokioSleep (line 90) | pub(crate) struct TokioSleep {
    method reset (line 106) | pub fn reset(self: Pin<&mut Self>, deadline: Instant) {
  type Output (line 96) | type Output = ();
  method poll (line 98) | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
  type HttpClient (line 112) | pub struct HttpClient<B> {
  method clone (line 118) | fn clone(&self) -> Self {
  method default (line 131) | fn default() -> Self {
  function new (line 143) | pub fn new() -> Self {
  function send_request (line 151) | pub async fn send_request(
  function get_cached_connection (line 242) | async fn get_cached_connection(&self, host: &Address) -> Option<HttpConn...
  function send_request_conn (line 261) | async fn send_request_conn(
  type HttpConnection (line 300) | enum HttpConnection<B> {
  function connect (line 311) | async fn connect(
  function connect_http_http1 (line 333) | async fn connect_http_http1(scheme: &Scheme, host: Address, stream: Auto...
  function connect_https (line 361) | async fn connect_https(
  function send_request (line 414) | pub async fn send_request(&mut self, mut req: Request<B>) -> Result<Resp...
  function is_closed (line 459) | pub fn is_closed(&self) -> bool {
  function is_ready (line 466) | pub fn is_ready(&self) -> bool {
  function ready (line 473) | pub async fn ready(&mut self) -> Result<(), hyper::Error> {

FILE: crates/shadowsocks-service/src/local/http/http_service.rs
  type HttpService (line 29) | pub struct HttpService {
    method new (line 38) | pub fn new(
    method serve_connection (line 54) | pub async fn serve_connection(
  function empty_body (line 229) | fn empty_body() -> BoxBody<Bytes, hyper::Error> {
  function make_bad_request (line 235) | fn make_bad_request() -> Result<Response<BoxBody<Bytes, hyper::Error>>, ...
  function make_proxy_authentication_required (line 242) | fn make_proxy_authentication_required() -> Result<Response<BoxBody<Bytes...
  function make_internal_server_error (line 250) | fn make_internal_server_error() -> Result<Response<BoxBody<Bytes, hyper:...
  function get_extra_headers (line 257) | fn get_extra_headers(headers: header::GetAll<HeaderValue>) -> Vec<String> {
  function clear_hop_headers (line 274) | fn clear_hop_headers(headers: &mut HeaderMap<HeaderValue>) {
  function set_conn_keep_alive (line 301) | fn set_conn_keep_alive(version: Version, headers: &mut HeaderMap<HeaderV...
  function get_addr_from_header (line 318) | fn get_addr_from_header(req: &mut Request<body::Incoming>) -> Result<Add...

FILE: crates/shadowsocks-service/src/local/http/http_stream.rs
  type ProxyHttpStream (line 16) | pub enum ProxyHttpStream {
    method connect_http (line 25) | pub fn connect_http(stream: AutoProxyClientStream) -> Self {
    method connect_https (line 30) | pub async fn connect_https(stream: AutoProxyClientStream, domain: &str...
    method connect_https (line 62) | pub async fn connect_https(stream: AutoProxyClientStream, domain: &str...
    method connect_https (line 121) | pub async fn connect_https(_stream: AutoProxyClientStream, _domain: &s...
    method negotiated_http2 (line 128) | pub fn negotiated_http2(&self) -> bool {
  method poll_read (line 148) | fn poll_read(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf: ...
  method poll_write (line 154) | fn poll_write(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf:...
  method poll_flush (line 158) | fn poll_flush(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> P...
  method poll_shutdown (line 162) | fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -...

FILE: crates/shadowsocks-service/src/local/http/server.rs
  type HttpBuilder (line 22) | pub struct HttpBuilder {
    method new (line 33) | pub fn new(client_config: ServerAddr, balancer: PingBalancer) -> Self {
    method with_context (line 39) | pub fn with_context(context: Arc<ServiceContext>, client_config: Serve...
    method set_launchd_tcp_socket_name (line 51) | pub fn set_launchd_tcp_socket_name(&mut self, n: String) {
    method set_http_auth (line 55) | pub fn set_http_auth(&mut self, auth: HttpAuthConfig) {
    method build (line 60) | pub async fn build(self) -> io::Result<Http> {
  type Http (line 92) | pub struct Http {
    method local_addr (line 101) | pub fn local_addr(&self) -> io::Result<SocketAddr> {
    method run (line 106) | pub async fn run(self) -> io::Result<()> {
  type HttpConnectionHandler (line 142) | pub struct HttpConnectionHandler {
    method new (line 151) | pub fn new(context: Arc<ServiceContext>, balancer: PingBalancer, http_...
    method serve_connection (line 161) | pub async fn serve_connection<S>(self, stream: S, peer_addr: SocketAdd...

FILE: crates/shadowsocks-service/src/local/http/tokio_rt.rs
  type TokioIo (line 11) | pub struct TokioIo<T> {
  function new (line 17) | pub fn new(inner: T) -> Self {
  function poll_read (line 30) | fn poll_read(
  function poll_write (line 54) | fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) ->...
  function poll_flush (line 58) | fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result...
  function poll_shutdown (line 62) | fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Res...
  function is_write_vectored (line 66) | fn is_write_vectored(&self) -> bool {
  function poll_write_vectored (line 70) | fn poll_write_vectored(
  function poll_read (line 83) | fn poll_read(
  function poll_write (line 115) | fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) ->...
  function poll_flush (line 119) | fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result...
  function poll_shutdown (line 123) | fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Res...
  function is_write_vectored (line 127) | fn is_write_vectored(&self) -> bool {
  function poll_write_vectored (line 131) | fn poll_write_vectored(
  type TokioExecutor (line 141) | pub struct TokioExecutor;
    method execute (line 148) | fn execute(&self, future: F) {

FILE: crates/shadowsocks-service/src/local/http/utils.rs
  function authority_addr (line 23) | pub fn authority_addr(scheme_str: Option<&str>, authority: &Authority) -...
  function host_addr (line 65) | pub fn host_addr(uri: &Uri) -> Option<Address> {
  function get_keep_alive_val (line 72) | fn get_keep_alive_val(values: header::GetAll<HeaderValue>) -> Option<boo...
  function check_keep_alive (line 92) | pub fn check_keep_alive(version: Version, headers: &HeaderMap<HeaderValu...
  function connect_host (line 116) | pub async fn connect_host(

FILE: crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs
  constant EXPECTED_CHECK_POINTS_IN_CHECK_WINDOW (line 45) | const EXPECTED_CHECK_POINTS_IN_CHECK_WINDOW: u32 = 67;
  type ServerType (line 49) | pub enum ServerType {
    method fmt (line 55) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type PingBalancerBuilder (line 64) | pub struct PingBalancerBuilder {
    method new (line 74) | pub fn new(context: Arc<ServiceContext>, mode: Mode) -> Self {
    method add_server (line 85) | pub fn add_server(&mut self, server: ServerInstanceConfig) {
    method max_server_rtt (line 95) | pub fn max_server_rtt(&mut self, rtt: Duration) {
    method check_interval (line 99) | pub fn check_interval(&mut self, intv: Duration) {
    method check_best_interval (line 103) | pub fn check_best_interval(&mut self, intv: Duration) {
    method find_best_idx (line 107) | fn find_best_idx(servers: &[Arc<ServerIdent>], mode: Mode) -> (usize, ...
    method build (line 165) | pub async fn build(self) -> io::Result<PingBalancer> {
  type PingBalancerContextTask (line 191) | struct PingBalancerContextTask {
  method drop (line 197) | fn drop(&mut self) {
  type PingBalancerContext (line 205) | struct PingBalancerContext {
    method best_tcp_server (line 218) | fn best_tcp_server(&self) -> Arc<ServerIdent> {
    method best_udp_server (line 223) | fn best_udp_server(&self) -> Arc<ServerIdent> {
    method is_empty (line 229) | fn is_empty(&self) -> bool {
    method new (line 235) | pub(crate) async fn new(
    method init_score (line 336) | async fn init_score(&self) {
    method check_server_tcp_enabled (line 343) | fn check_server_tcp_enabled(svr_cfg: &ServerConfig) -> bool {
    method check_server_udp_enabled (line 347) | fn check_server_udp_enabled(svr_cfg: &ServerConfig) -> bool {
    method probing_required (line 351) | fn probing_required(&self) -> bool {
    method checker_task (line 372) | async fn checker_task(self: Arc<Self>) {
    method checker_task_dummy (line 381) | async fn checker_task_dummy(self: Arc<Self>) {
    method check_once (line 386) | async fn check_once(&self, first_run: bool) {
    method check_best_server (line 505) | async fn check_best_server(&self) {
    method checker_task_real (line 605) | async fn checker_task_real(&self) {
    method checker_task_all_servers (line 615) | async fn checker_task_all_servers(&self) {
    method checker_task_best_server (line 646) | async fn checker_task_best_server(&self) {
  type PingBalancerInner (line 663) | struct PingBalancerInner {
  method drop (line 669) | fn drop(&mut self) {
  type PingBalancer (line 676) | pub struct PingBalancer {
    method context (line 682) | pub fn context(&self) -> Arc<ServiceContext> {
    method best_tcp_server (line 688) | pub fn best_tcp_server(&self) -> Arc<ServerIdent> {
    method best_udp_server (line 694) | pub fn best_udp_server(&self) -> Arc<ServerIdent> {
    method is_empty (line 701) | pub fn is_empty(&self) -> bool {
    method servers (line 707) | pub fn servers(&self) -> PingServerIter<'_> {
    method reset_servers (line 717) | pub async fn reset_servers(
  method fmt (line 793) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
  type PingChecker (line 804) | struct PingChecker {
    method check_update_score (line 813) | async fn check_update_score(self) {
    method check_request_tcp_chromium (line 846) | async fn check_request_tcp_chromium(&self) -> io::Result<()> {
    method check_request_tcp_firefox (line 885) | async fn check_request_tcp_firefox(&self) -> io::Result<()> {
    method check_request_udp (line 923) | async fn check_request_udp(&self) -> io::Result<()> {
    method check_request (line 969) | async fn check_request(&self) -> io::Result<()> {
    method check_delay (line 976) | async fn check_delay(&self) -> io::Result<u32> {
  type ServerConfigFormatter (line 1024) | struct ServerConfigFormatter<'a> {
  function new (line 1029) | fn new(server_config: &'a ServerConfig) -> Self {
  method fmt (line 1035) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type PingServerIter (line 1050) | pub struct PingServerIter<'a> {
  type Item (line 1057) | type Item = &'a ServerIdent;
  method next (line 1059) | fn next(&mut self) -> Option<Self::Item> {

FILE: crates/shadowsocks-service/src/local/loadbalancing/server_data.rs
  type ServerScore (line 21) | pub struct ServerScore {
    method new (line 28) | pub fn new(user_weight: f32, max_server_rtt: Duration, check_window: D...
    method score (line 39) | pub fn score(&self) -> u32 {
    method push_score (line 44) | pub async fn push_score(&self, score: Score) -> u32 {
    method push_score_fetch_statistic (line 54) | pub async fn push_score_fetch_statistic(&self, score: Score) -> (u32, ...
    method report_failure (line 64) | pub async fn report_failure(&self) -> u32 {
    method stat_data (line 69) | pub async fn stat_data(&self) -> ServerStatData {
  method fmt (line 75) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  type ServerIdent (line 82) | pub struct ServerIdent {
    method new (line 91) | pub fn new(
    method connect_opts_ref (line 125) | pub fn connect_opts_ref(&self) -> &ConnectOpts {
    method server_config (line 129) | pub fn server_config(&self) -> &ServerConfig {
    method server_config_mut (line 133) | pub fn server_config_mut(&mut self) -> &mut ServerConfig {
    method server_instance_config (line 137) | pub fn server_instance_config(&self) -> &ServerInstanceConfig {
    method tcp_score (line 141) | pub fn tcp_score(&self) -> &ServerScore {
    method udp_score (line 145) | pub fn udp_score(&self) -> &ServerScore {

FILE: crates/shadowsocks-service/src/local/loadbalancing/server_stat.rs
  constant DEFAULT_CHECK_INTERVAL_SEC (line 9) | pub const DEFAULT_CHECK_INTERVAL_SEC: u64 = 10;
  constant DEFAULT_CHECK_TIMEOUT_SEC (line 11) | pub const DEFAULT_CHECK_TIMEOUT_SEC: u64 = 5;
  type Score (line 15) | pub enum Score {
  type ServerStatData (line 24) | pub struct ServerStatData {
  type ServerStat (line 42) | pub struct ServerStat {
    method new (line 67) | pub fn new(user_weight: f32, max_server_rtt: u32, check_window: Durati...
    method score (line 87) | fn score(&self) -> u32 {
    method push_score (line 119) | pub fn push_score(&mut self, score: Score) -> u32 {
    method recalculate_score (line 136) | fn recalculate_score(&mut self) -> u32 {
    method data (line 210) | pub fn data(&self) -> &ServerStatData {
  function max_latency_stdev (line 57) | fn max_latency_stdev(max_server_rtt: u32) -> f64 {

FILE: crates/shadowsocks-service/src/local/mod.rs
  constant LOCAL_DEFAULT_KEEPALIVE_TIMEOUT (line 64) | pub(crate) const LOCAL_DEFAULT_KEEPALIVE_TIMEOUT: Duration = Duration::f...
  type Server (line 67) | pub struct Server {
    method new (line 92) | pub async fn new(config: Config) -> io::Result<Self> {
    method run (line 532) | pub async fn run(self) -> io::Result<()> {
    method server_balancer (line 587) | pub fn server_balancer(&self) -> &PingBalancer {
    method socks_servers (line 592) | pub fn socks_servers(&self) -> &[Socks] {
    method tunnel_servers (line 598) | pub fn tunnel_servers(&self) -> &[Tunnel] {
    method http_servers (line 604) | pub fn http_servers(&self) -> &[Http] {
    method tun_servers (line 610) | pub fn tun_servers(&self) -> &[Tun] {
    method dns_servers (line 616) | pub fn dns_servers(&self) -> &[Dns] {
    method redir_servers (line 622) | pub fn redir_servers(&self) -> &[Redir] {
    method fake_dns_servers (line 628) | pub fn fake_dns_servers(&self) -> &[FakeDns] {
  function flow_report_task (line 634) | async fn flow_report_task(stat_addr: LocalFlowStatAddress, flow_stat: Ar...
  function run (line 710) | pub async fn run(config: Config) -> io::Result<()> {

FILE: crates/shadowsocks-service/src/local/net/tcp/auto_proxy_io.rs
  type AutoProxyIo (line 4) | pub trait AutoProxyIo {
    method is_proxied (line 6) | fn is_proxied(&self) -> bool;
    method is_bypassed (line 9) | fn is_bypassed(&self) -> bool {

FILE: crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs
  type AutoProxyClientStream (line 29) | pub enum AutoProxyClientStream {
    method connect (line 36) | pub async fn connect<A>(context: Arc<ServiceContext>, server: &ServerI...
    method connect_with_opts (line 44) | pub async fn connect_with_opts<A>(
    method connect_bypassed (line 69) | pub async fn connect_bypassed<A>(context: Arc<ServiceContext>, addr: A...
    method connect_bypassed_with_opts (line 77) | pub async fn connect_bypassed_with_opts<A>(
    method connect_bypassed_with_opts_inner (line 95) | async fn connect_bypassed_with_opts_inner<A>(
    method connect_proxied (line 109) | pub async fn connect_proxied<A>(context: Arc<ServiceContext>, server: ...
    method connect_proxied_with_opts (line 117) | pub async fn connect_proxied_with_opts<A>(
    method connect_proxied_with_opts_inner (line 135) | async fn connect_proxied_with_opts_inner<A>(
    method local_addr (line 163) | pub fn local_addr(&self) -> io::Result<SocketAddr> {
    method set_nodelay (line 170) | pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
    method from (line 228) | fn from(s: ProxyClientStream<MonProxyStream<TcpStream>>) -> Self {
  method is_proxied (line 179) | fn is_proxied(&self) -> bool {
  method poll_read (line 185) | fn poll_read(self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf: &mut...
  method poll_write (line 194) | fn poll_write(self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf: &[u...
  method poll_flush (line 201) | fn poll_flush(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<...
  method poll_shutdown (line 208) | fn poll_shutdown(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Po...
  method poll_write_vectored (line 215) | fn poll_write_vectored(

FILE: crates/shadowsocks-service/src/local/net/tcp/listener.rs
  function create_standard_tcp_listener (line 10) | pub async fn create_standard_tcp_listener(

FILE: crates/shadowsocks-service/src/local/net/udp/association.rs
  type UdpInboundWrite (line 38) | pub trait UdpInboundWrite {
    method send_to (line 40) | async fn send_to(&self, peer_addr: SocketAddr, remote_addr: &Address, ...
  type AssociationMap (line 43) | type AssociationMap<W> = LruCache<SocketAddr, UdpAssociation<W>>;
  type UdpAssociationManager (line 46) | pub struct UdpAssociationManager<W>
  function new (line 65) | pub fn new(
  function send_to (line 96) | pub async fn send_to(&mut self, peer_addr: SocketAddr, mut target_addr: ...
  function cleanup_expired (line 126) | pub async fn cleanup_expired(&mut self) {
  function keep_alive (line 131) | pub async fn keep_alive(&mut self, peer_addr: &SocketAddr) {
  type UdpAssociation (line 136) | struct UdpAssociation<W>
  method drop (line 149) | fn drop(&mut self) {
  function new (line 158) | fn new(
  function try_send (line 181) | fn try_send(&self, data: (Address, Bytes)) -> io::Result<()> {
  type ServerContext (line 191) | struct ServerContext {
  type ServerSessionContext (line 196) | struct ServerSessionContext {
    method new (line 201) | fn new(session_expire_duration: Duration) -> Self {
  type UdpAssociationContext (line 208) | struct UdpAssociationContext<W>
  method drop (line 231) | fn drop(&mut self) {
  function generate_client_session_id (line 242) | pub fn generate_client_session_id() -> u64 {
  function create (line 255) | fn create(
  function dispatch_packet (line 290) | async fn dispatch_packet(&mut self, mut receiver: mpsc::Receiver<(Addres...
  function dispatch_received_packet (line 428) | async fn dispatch_received_packet(&mut self, target_addr: &Address, data...
  function dispatch_received_bypassed_packet (line 461) | async fn dispatch_received_bypassed_packet(&mut self, target_addr: &Addr...
  function send_received_bypassed_packet (line 473) | async fn send_received_bypassed_packet(&mut self, mut target_addr: Socke...
  function dispatch_received_proxied_packet (line 537) | async fn dispatch_received_proxied_packet(&mut self, target_addr: &Addre...
  function send_received_respond_packet (line 603) | async fn send_received_respond_packet(&mut self, addr: &Address, data: &...

FILE: crates/shadowsocks-service/src/local/net/udp/listener.rs
  function create_standard_udp_listener (line 10) | pub async fn create_standard_udp_listener(

FILE: crates/shadowsocks-service/src/local/online_config/content_encoding.rs
  type ContentEncoding (line 12) | pub enum ContentEncoding {
    type Error (line 25) | type Error = ContentEncodingError;
    method try_from (line 27) | fn try_from(value: &'a HeaderValue) -> Result<Self, Self::Error> {
  type ContentEncodingError (line 22) | pub struct ContentEncodingError;
  function read_body (line 45) | pub async fn read_body<B>(encoding: ContentEncoding, body: &mut B) -> io...

FILE: crates/shadowsocks-service/src/local/online_config/mod.rs
  type OnlineConfigServiceBuilder (line 28) | pub struct OnlineConfigServiceBuilder {
    method new (line 38) | pub fn new(context: Arc<ServiceContext>, config_url: String, balancer:...
    method set_update_interval (line 49) | pub fn set_update_interval(&mut self, update_interval: Duration) {
    method set_allowed_plugins (line 54) | pub fn set_allowed_plugins<V, S>(&mut self, allowed_plugins: V)
    method build (line 67) | pub async fn build(self) -> io::Result<OnlineConfigService> {
  type OnlineConfigService (line 84) | pub struct OnlineConfigService {
    method run_once (line 94) | async fn run_once(&mut self) -> io::Result<()> {
    method run_once_impl (line 104) | async fn run_once_impl(&mut self) -> io::Result<()> {
    method run (line 261) | pub async fn run(mut self) -> io::Result<()> {

FILE: crates/shadowsocks-service/src/local/redir/redir_ext.rs
  type TcpListenerRedirExt (line 17) | pub trait TcpListenerRedirExt {
    method bind_redir (line 21) | async fn bind_redir(ty: RedirType, addr: SocketAddr, accept_opts: Acce...
  type TcpStreamRedirExt (line 25) | pub trait TcpStreamRedirExt {
    method destination_addr (line 29) | fn destination_addr(&self, ty: RedirType) -> io::Result<SocketAddr>;
  type UdpSocketRedir (line 33) | pub trait UdpSocketRedir {
    method poll_recv_dest_from (line 39) | fn poll_recv_dest_from(
  type UdpSocketRedirExt (line 47) | pub trait UdpSocketRedirExt {
    method recv_dest_from (line 48) | fn recv_dest_from<'a>(&'a self, buf: &'a mut [u8]) -> RecvDestFrom<'a,...
  type RecvDestFrom (line 59) | pub struct RecvDestFrom<'a, S: 'a> {
  type Output (line 68) | type Output = io::Result<(usize, SocketAddr, SocketAddr)>;
  method poll (line 70) | fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Ou...
  type RedirSocketOpts (line 77) | pub struct RedirSocketOpts {

FILE: crates/shadowsocks-service/src/local/redir/server.rs
  type RedirBuilder (line 16) | pub struct RedirBuilder {
    method new (line 30) | pub fn new(client_addr: ServerAddr, balancer: PingBalancer) -> Self {
    method with_context (line 36) | pub fn with_context(context: Arc<ServiceContext>, client_addr: ServerA...
    method set_udp_expiry_duration (line 51) | pub fn set_udp_expiry_duration(&mut self, d: Duration) {
    method set_udp_capacity (line 56) | pub fn set_udp_capacity(&mut self, c: usize) {
    method set_mode (line 61) | pub fn set_mode(&mut self, mode: Mode) {
    method set_tcp_redir (line 66) | pub fn set_tcp_redir(&mut self, ty: RedirType) {
    method set_udp_redir (line 71) | pub fn set_udp_redir(&mut self, ty: RedirType) {
    method set_udp_bind_addr (line 76) | pub fn set_udp_bind_addr(&mut self, addr: ServerAddr) {
    method build (line 80) | pub async fn build(self) -> io::Result<Redir> {
  type Redir (line 114) | pub struct Redir {
    method tcp_server (line 121) | pub fn tcp_server(&self) -> Option<&RedirTcpServer> {
    method udp_server (line 126) | pub fn udp_server(&self) -> Option<&RedirUdpServer> {
    method run (line 131) | pub async fn run(self) -> io::Result<()> {

FILE: crates/shadowsocks-service/src/local/redir/sys/mod.rs
  function set_ipv6_only (line 16) | pub fn set_ipv6_only<S>(socket: &S, ipv6_only: bool) -> io::Result<()>
  function set_ipv6_only (line 26) | pub fn set_ipv6_only<S>(socket: &S, ipv6_only: bool) -> io::Result<()>

FILE: crates/shadowsocks-service/src/local/redir/sys/unix/bsd_pf.rs
  type PacketFilter (line 24) | pub struct PacketFilter {
    method open (line 29) | fn open() -> io::Result<PacketFilter> {
    method natlook (line 53) | pub fn natlook(&self, bind_addr: &SocketAddr, peer_addr: &SocketAddr, ...
    method tcp_natlook (line 62) | fn tcp_natlook(&self, bind_addr: &SocketAddr, peer_addr: &SocketAddr, ...
    method udp_natlook (line 208) | fn udp_natlook(&self, bind_addr: &SocketAddr, peer_addr: &SocketAddr, ...
  method drop (line 363) | fn drop(&mut self) {

FILE: crates/shadowsocks-service/src/local/redir/sys/unix/pfvar_bindgen_freebsd.rs
  constant BSD (line 3) | pub const BSD: u32 = 199506;
  constant BSD4_3 (line 4) | pub const BSD4_3: u32 = 1;
  constant BSD4_4 (line 5) | pub const BSD4_4: u32 = 1;
  constant __FreeBSD_version (line 6) | pub const __FreeBSD_version: u32 = 1400097;
  constant __GNUCLIKE_ASM (line 7) | pub const __GNUCLIKE_ASM: u32 = 3;
  constant __GNUCLIKE___TYPEOF (line 8) | pub const __GNUCLIKE___TYPEOF: u32 = 1;
  constant __GNUCLIKE___SECTION (line 9) | pub const __GNUCLIKE___SECTION: u32 = 1;
  constant __GNUCLIKE_CTOR_SECTION_HANDLING (line 10) | pub const __GNUCLIKE_CTOR_SECTION_HANDLING: u32 = 1;
  constant __GNUCLIKE_BUILTIN_CONSTANT_P (line 11) | pub const __GNUCLIKE_BUILTIN_CONSTANT_P: u32 = 1;
  constant __GNUCLIKE_BUILTIN_VARARGS (line 12) | pub const __GNUCLIKE_BUILTIN_VARARGS: u32 = 1;
  constant __GNUCLIKE_BUILTIN_STDARG (line 13) | pub const __GNUCLIKE_BUILTIN_STDARG: u32 = 1;
  constant __GNUCLIKE_BUILTIN_VAALIST (line 14) | pub const __GNUCLIKE_BUILTIN_VAALIST: u32 = 1;
  constant __GNUC_VA_LIST_COMPATIBILITY (line 15) | pub const __GNUC_VA_LIST_COMPATIBILITY: u32 = 1;
  constant __GNUCLIKE_BUILTIN_NEXT_ARG (line 16) | pub const __GNUCLIKE_BUILTIN_NEXT_ARG: u32 = 1;
  constant __GNUCLIKE_BUILTIN_MEMCPY (line 17) | pub const __GNUCLIKE_BUILTIN_MEMCPY: u32 = 1;
  constant __CC_SUPPORTS_INLINE (line 18) | pub const __CC_SUPPORTS_INLINE: u32 = 1;
  constant __CC_SUPPORTS___INLINE (line 19) | pub const __CC_SUPPORTS___INLINE: u32 = 1;
  constant __CC_SUPPORTS___INLINE__ (line 20) | pub const __CC_SUPPORTS___INLINE__: u32 = 1;
  constant __CC_SUPPORTS___FUNC__ (line 21) | pub const __CC_SUPPORTS___FUNC__: u32 = 1;
  constant __CC_SUPPORTS_WARNING (line 22) | pub const __CC_SUPPORTS_WARNING: u32 = 1;
  constant __CC_SUPPORTS_VARADIC_XXX (line 23) | pub const __CC_SUPPORTS_VARADIC_XXX: u32 = 1;
  constant __CC_SUPPORTS_DYNAMIC_ARRAY_INIT (line 24) | pub const __CC_SUPPORTS_DYNAMIC_ARRAY_INIT: u32 = 1;
  constant __POSIX_VISIBLE (line 25) | pub const __POSIX_VISIBLE: u32 = 200809;
  constant __XSI_VISIBLE (line 26) | pub const __XSI_VISIBLE: u32 = 700;
  constant __BSD_VISIBLE (line 27) | pub const __BSD_VISIBLE: u32 = 1;
  constant __ISO_C_VISIBLE (line 28) | pub const __ISO_C_VISIBLE: u32 = 2011;
  constant __EXT1_VISIBLE (line 29) | pub const __EXT1_VISIBLE: u32 = 1;
  constant __CHAR_BIT (line 30) | pub const __CHAR_BIT: u32 = 8;
  constant __SCHAR_MAX (line 31) | pub const __SCHAR_MAX: u32 = 127;
  constant __SCHAR_MIN (line 32) | pub const __SCHAR_MIN: i32 = -128;
  constant __UCHAR_MAX (line 33) | pub const __UCHAR_MAX: u32 = 255;
  constant __USHRT_MAX (line 34) | pub const __USHRT_MAX: u32 = 65535;
  constant __SHRT_MAX (line 35) | pub const __SHRT_MAX: u32 = 32767;
  constant __SHRT_MIN (line 36) | pub const __SHRT_MIN: i32 = -32768;
  constant __UINT_MAX (line 37) | pub const __UINT_MAX: u32 = 4294967295;
  constant __INT_MAX (line 38) | pub const __INT_MAX: u32 = 2147483647;
  constant __INT_MIN (line 39) | pub const __INT_MIN: i32 = -2147483648;
  constant __ULONG_MAX (line 40) | pub const __ULONG_MAX: i32 = -1;
  constant __LONG_MAX (line 41) | pub const __LONG_MAX: u64 = 9223372036854775807;
  constant __LONG_MIN (line 42) | pub const __LONG_MIN: i64 = -9223372036854775808;
  constant __ULLONG_MAX (line 43) | pub const __ULLONG_MAX: i32 = -1;
  constant __LLONG_MAX (line 44) | pub const __LLONG_MAX: u64 = 9223372036854775807;
  constant __LLONG_MIN (line 45) | pub const __LLONG_MIN: i64 = -9223372036854775808;
  constant __SSIZE_MAX (line 46) | pub const __SSIZE_MAX: u64 = 9223372036854775807;
  constant __SIZE_T_MAX (line 47) | pub const __SIZE_T_MAX: i32 = -1;
  constant __OFF_MAX (line 48) | pub const __OFF_MAX: u64 = 9223372036854775807;
  constant __OFF_MIN (line 49) | pub const __OFF_MIN: i64 = -9223372036854775808;
  constant __UQUAD_MAX (line 50) | pub const __UQUAD_MAX: i32 = -1;
  constant __QUAD_MAX (line 51) | pub const __QUAD_MAX: u64 = 9223372036854775807;
  constant __QUAD_MIN (line 52) | pub const __QUAD_MIN: i64 = -9223372036854775808;
  constant __LONG_BIT (line 53) | pub const __LONG_BIT: u32 = 64;
  constant __WORD_BIT (line 54) | pub const __WORD_BIT: u32 = 32;
  constant __MINSIGSTKSZ (line 55) | pub const __MINSIGSTKSZ: u32 = 2048;
  constant __WCHAR_MIN (line 56) | pub const __WCHAR_MIN: i32 = -2147483648;
  constant __WCHAR_MAX (line 57) | pub const __WCHAR_MAX: u32 = 2147483647;
  constant _QUAD_HIGHWORD (line 58) | pub const _QUAD_HIGHWORD: u32 = 1;
  constant _QUAD_LOWWORD (line 59) | pub const _QUAD_LOWWORD: u32 = 0;
  constant _SIG_WORDS (line 60) | pub const _SIG_WORDS: u32 = 4;
  constant _SIG_MAXSIG (line 61) | pub const _SIG_MAXSIG: u32 = 128;
  constant FD_SETSIZE (line 62) | pub const FD_SETSIZE: u32 = 1024;
  constant ARG_MAX (line 63) | pub const ARG_MAX: u32 = 524288;
  constant CHILD_MAX (line 64) | pub const CHILD_MAX: u32 = 40;
  constant MAX_CANON (line 65) | pub const MAX_CANON: u32 = 255;
  constant MAX_INPUT (line 66) | pub const MAX_INPUT: u32 = 255;
  constant NAME_MAX (line 67) | pub const NAME_MAX: u32 = 255;
  constant NGROUPS_MAX (line 68) | pub const NGROUPS_MAX: u32 = 1023;
  constant OPEN_MAX (line 69) | pub const OPEN_MAX: u32 = 64;
  constant PATH_MAX (line 70) | pub const PATH_MAX: u32 = 1024;
  constant PIPE_BUF (line 71) | pub const PIPE_BUF: u32 = 512;
  constant IOV_MAX (line 72) | pub const IOV_MAX: u32 = 1024;
  constant MAXCOMLEN (line 73) | pub const MAXCOMLEN: u32 = 19;
  constant MAXINTERP (line 74) | pub const MAXINTERP: u32 = 1024;
  constant MAXLOGNAME (line 75) | pub const MAXLOGNAME: u32 = 33;
  constant MAXUPRC (line 76) | pub const MAXUPRC: u32 = 40;
  constant NCARGS (line 77) | pub const NCARGS: u32 = 524288;
  constant NGROUPS (line 78) | pub const NGROUPS: u32 = 1024;
  constant NOFILE (line 79) | pub const NOFILE: u32 = 64;
  constant NOGROUP (line 80) | pub const NOGROUP: u32 = 65535;
  constant MAXHOSTNAMELEN (line 81) | pub const MAXHOSTNAMELEN: u32 = 256;
  constant SPECNAMELEN (line 82) | pub const SPECNAMELEN: u32 = 255;
  constant _X86_SIGNAL_H (line 83) | pub const _X86_SIGNAL_H: u32 = 1;
  constant SIGHUP (line 84) | pub const SIGHUP: u32 = 1;
  constant SIGINT (line 85) | pub const SIGINT: u32 = 2;
  constant SIGQUIT (line 86) | pub const SIGQUIT: u32 = 3;
  constant SIGILL (line 87) | pub const SIGILL: u32 = 4;
  constant SIGTRAP (line 88) | pub const SIGTRAP: u32 = 5;
  constant SIGABRT (line 89) | pub const SIGABRT: u32 = 6;
  constant SIGIOT (line 90) | pub const SIGIOT: u32 = 6;
  constant SIGEMT (line 91) | pub const SIGEMT: u32 = 7;
  constant SIGFPE (line 92) | pub const SIGFPE: u32 = 8;
  constant SIGKILL (line 93) | pub const SIGKILL: u32 = 9;
  constant SIGBUS (line 94) | pub const SIGBUS: u32 = 10;
  constant SIGSEGV (line 95) | pub const SIGSEGV: u32 = 11;
  constant SIGSYS (line 96) | pub const SIGSYS: u32 = 12;
  constant SIGPIPE (line 97) | pub const SIGPIPE: u32 = 13;
  constant SIGALRM (line 98) | pub const SIGALRM: u32 = 14;
  constant SIGTERM (line 99) | pub const SIGTERM: u32 = 15;
  constant SIGURG (line 100) | pub const SIGURG: u32 = 16;
  constant SIGSTOP (line 101) | pub const SIGSTOP: u32 = 17;
  constant SIGTSTP (line 102) | pub const SIGTSTP: u32 = 18;
  constant SIGCONT (line 103) | pub const SIGCONT: u32 = 19;
  constant SIGCHLD (line 104) | pub const SIGCHLD: u32 = 20;
  constant SIGTTIN (line 105) | pub const SIGTTIN: u32 = 21;
  constant SIGTTOU (line 106) | pub const SIGTTOU: u32 = 22;
  constant SIGIO (line 107) | pub const SIGIO: u32 = 23;
  constant SIGXCPU (line 108) | pub const SIGXCPU: u32 = 24;
  constant SIGXFSZ (line 109) | pub const SIGXFSZ: u32 = 25;
  constant SIGVTALRM (line 110) | pub const SIGVTALRM: u32 = 26;
  constant SIGPROF (line 111) | pub const SIGPROF: u32 = 27;
  constant SIGWINCH (line 112) | pub const SIGWINCH: u32 = 28;
  constant SIGINFO (line 113) | pub const SIGINFO: u32 = 29;
  constant SIGUSR1 (line 114) | pub const SIGUSR1: u32 = 30;
  constant SIGUSR2 (line 115) | pub const SIGUSR2: u32 = 31;
  constant SIGTHR (line 116) | pub const SIGTHR: u32 = 32;
  constant SIGLWP (line 117) | pub const SIGLWP: u32 = 32;
  constant SIGLIBRT (line 118) | pub const SIGLIBRT: u32 = 33;
  constant SIGRTMIN (line 119) | pub const SIGRTMIN: u32 = 65;
  constant SIGRTMAX (line 120) | pub const SIGRTMAX: u32 = 126;
  constant SIGEV_NONE (line 121) | pub const SIGEV_NONE: u32 = 0;
  constant SIGEV_SIGNAL (line 122) | pub const SIGEV_SIGNAL: u32 = 1;
  constant SIGEV_THREAD (line 123) | pub const SIGEV_THREAD: u32 = 2;
  constant SIGEV_KEVENT (line 124) | pub const SIGEV_KEVENT: u32 = 3;
  constant SIGEV_THREAD_ID (line 125) | pub const SIGEV_THREAD_ID: u32 = 4;
  constant ILL_ILLOPC (line 126) | pub const ILL_ILLOPC: u32 = 1;
  constant ILL_ILLOPN (line 127) | pub const ILL_ILLOPN: u32 = 2;
  constant ILL_ILLADR (line 128) | pub const ILL_ILLADR: u32 = 3;
  constant ILL_ILLTRP (line 129) | pub const ILL_ILLTRP: u32 = 4;
  constant ILL_PRVOPC (line 130) | pub const ILL_PRVOPC: u32 = 5;
  constant ILL_PRVREG (line 131) | pub const ILL_PRVREG: u32 = 6;
  constant ILL_COPROC (line 132) | pub const ILL_COPROC: u32 = 7;
  constant ILL_BADSTK (line 133) | pub const ILL_BADSTK: u32 = 8;
  constant BUS_ADRALN (line 134) | pub const BUS_ADRALN: u32 = 1;
  constant BUS_ADRERR (line 135) | pub const BUS_ADRERR: u32 = 2;
  constant BUS_OBJERR (line 136) | pub const BUS_OBJERR: u32 = 3;
  constant BUS_OOMERR (line 137) | pub const BUS_OOMERR: u32 = 100;
  constant SEGV_MAPERR (line 138) | pub const SEGV_MAPERR: u32 = 1;
  constant SEGV_ACCERR (line 139) | pub const SEGV_ACCERR: u32 = 2;
  constant SEGV_PKUERR (line 140) | pub const SEGV_PKUERR: u32 = 100;
  constant FPE_INTOVF (line 141) | pub const FPE_INTOVF: u32 = 1;
  constant FPE_INTDIV (line 142) | pub const FPE_INTDIV: u32 = 2;
  constant FPE_FLTDIV (line 143) | pub const FPE_FLTDIV: u32 = 3;
  constant FPE_FLTOVF (line 144) | pub const FPE_FLTOVF: u32 = 4;
  constant FPE_FLTUND (line 145) | pub const FPE_FLTUND: u32 = 5;
  constant FPE_FLTRES (line 146) | pub const FPE_FLTRES: u32 = 6;
  constant FPE_FLTINV (line 147) | pub const FPE_FLTINV: u32 = 7;
  constant FPE_FLTSUB (line 148) | pub const FPE_FLTSUB: u32 = 8;
  constant FPE_FLTIDO (line 149) | pub const FPE_FLTIDO: u32 = 9;
  constant TRAP_BRKPT (line 150) | pub const TRAP_BRKPT: u32 = 1;
  constant TRAP_TRACE (line 151) | pub const TRAP_TRACE: u32 = 2;
  constant TRAP_DTRACE (line 152) | pub const TRAP_DTRACE: u32 = 3;
  constant TRAP_CAP (line 153) | pub const TRAP_CAP: u32 = 4;
  constant CLD_EXITED (line 154) | pub const CLD_EXITED: u32 = 1;
  constant CLD_KILLED (line 155) | pub const CLD_KILLED: u32 = 2;
  constant CLD_DUMPED (line 156) | pub const CLD_DUMPED: u32 = 3;
  constant CLD_TRAPPED (line 157) | pub const CLD_TRAPPED: u32 = 4;
  constant CLD_STOPPED (line 158) | pub const CLD_STOPPED: u32 = 5;
  constant CLD_CONTINUED (line 159) | pub const CLD_CONTINUED: u32 = 6;
  constant POLL_IN (line 160) | pub const POLL_IN: u32 = 1;
  constant POLL_OUT (line 161) | pub const POLL_OUT: u32 = 2;
  constant POLL_MSG (line 162) | pub const POLL_MSG: u32 = 3;
  constant POLL_ERR (line 163) | pub const POLL_ERR: u32 = 4;
  constant POLL_PRI (line 164) | pub const POLL_PRI: u32 = 5;
  constant POLL_HUP (line 165) | pub const POLL_HUP: u32 = 6;
  constant SA_NOCLDSTOP (line 166) | pub const SA_NOCLDSTOP: u32 = 8;
  constant SA_ONSTACK (line 167) | pub const SA_ONSTACK: u32 = 1;
  constant SA_RESTART (line 168) | pub const SA_RESTART: u32 = 2;
  constant SA_RESETHAND (line 169) | pub const SA_RESETHAND: u32 = 4;
  constant SA_NODEFER (line 170) | pub const SA_NODEFER: u32 = 16;
  constant SA_NOCLDWAIT (line 171) | pub const SA_NOCLDWAIT: u32 = 32;
  constant SA_SIGINFO (line 172) | pub const SA_SIGINFO: u32 = 64;
  constant NSIG (line 173) | pub const NSIG: u32 = 32;
  constant SI_NOINFO (line 174) | pub const SI_NOINFO: u32 = 0;
  constant SI_USER (line 175) | pub const SI_USER: u32 = 65537;
  constant SI_QUEUE (line 176) | pub const SI_QUEUE: u32 = 65538;
  constant SI_TIMER (line 177) | pub const SI_TIMER: u32 = 65539;
  constant SI_ASYNCIO (line 178) | pub const SI_ASYNCIO: u32 = 65540;
  constant SI_MESGQ (line 179) | pub const SI_MESGQ: u32 = 65541;
  constant SI_KERNEL (line 180) | pub const SI_KERNEL: u32 = 65542;
  constant SI_LWP (line 181) | pub const SI_LWP: u32 = 65543;
  constant SI_UNDEFINED (line 182) | pub const SI_UNDEFINED: u32 = 0;
  constant SS_ONSTACK (line 183) | pub const SS_ONSTACK: u32 = 1;
  constant SS_DISABLE (line 184) | pub const SS_DISABLE: u32 = 4;
  constant MINSIGSTKSZ (line 185) | pub const MINSIGSTKSZ: u32 = 2048;
  constant SIGSTKSZ (line 186) | pub const SIGSTKSZ: u32 = 34816;
  constant SV_ONSTACK (line 187) | pub const SV_ONSTACK: u32 = 1;
  constant SV_INTERRUPT (line 188) | pub const SV_INTERRUPT: u32 = 2;
  constant SV_RESETHAND (line 189) | pub const SV_RESETHAND: u32 = 4;
  constant SV_NODEFER (line 190) | pub const SV_NODEFER: u32 = 16;
  constant SV_NOCLDSTOP (line 191) | pub const SV_NOCLDSTOP: u32 = 8;
  constant SV_SIGINFO (line 192) | pub const SV_SIGINFO: u32 = 64;
  constant SIG_BLOCK (line 193) | pub const SIG_BLOCK: u32 = 1;
  constant SIG_UNBLOCK (line 194) | pub const SIG_UNBLOCK: u32 = 2;
  constant SIG_SETMASK (line 195) | pub const SIG_SETMASK: u32 = 3;
  constant MACHINE (line 196) | pub const MACHINE: &[u8; 6] = b"amd64\0";
  constant MACHINE_ARCH (line 197) | pub const MACHINE_ARCH: &[u8; 6] = b"amd64\0";
  constant MACHINE_ARCH32 (line 198) | pub const MACHINE_ARCH32: &[u8; 5] = b"i386\0";
  constant MAXCPU (line 199) | pub const MAXCPU: u32 = 1;
  constant MAXMEMDOM (line 200) | pub const MAXMEMDOM: u32 = 8;
  constant CACHE_LINE_SHIFT (line 201) | pub const CACHE_LINE_SHIFT: u32 = 6;
  constant CACHE_LINE_SIZE (line 202) | pub const CACHE_LINE_SIZE: u32 = 64;
  constant NPTEPGSHIFT (line 203) | pub const NPTEPGSHIFT: u32 = 9;
  constant PAGE_SHIFT (line 204) | pub const PAGE_SHIFT: u32 = 12;
  constant PAGE_SIZE (line 205) | pub const PAGE_SIZE: u32 = 4096;
  constant PAGE_MASK (line 206) | pub const PAGE_MASK: u32 = 4095;
  constant NPDEPGSHIFT (line 207) | pub const NPDEPGSHIFT: u32 = 9;
  constant PDRSHIFT (line 208) | pub const PDRSHIFT: u32 = 21;
  constant NBPDR (line 209) | pub const NBPDR: u32 = 2097152;
  constant PDRMASK (line 210) | pub const PDRMASK: u32 = 2097151;
  constant NPDPEPGSHIFT (line 211) | pub const NPDPEPGSHIFT: u32 = 9;
  constant PDPSHIFT (line 212) | pub const PDPSHIFT: u32 = 30;
  constant NBPDP (line 213) | pub const NBPDP: u32 = 1073741824;
  constant PDPMASK (line 214) | pub const PDPMASK: u32 = 1073741823;
  constant NPML4EPGSHIFT (line 215) | pub const NPML4EPGSHIFT: u32 = 9;
  constant PML4SHIFT (line 216) | pub const PML4SHIFT: u32 = 39;
  constant NBPML4 (line 217) | pub const NBPML4: u64 = 549755813888;
  constant PML4MASK (line 218) | pub const PML4MASK: u64 = 549755813887;
  constant NPML5EPGSHIFT (line 219) | pub const NPML5EPGSHIFT: u32 = 9;
  constant PML5SHIFT (line 220) | pub const PML5SHIFT: u32 = 48;
  constant NBPML5 (line 221) | pub const NBPML5: u64 = 281474976710656;
  constant PML5MASK (line 222) | pub const PML5MASK: u64 = 281474976710655;
  constant MAXPAGESIZES (line 223) | pub const MAXPAGESIZES: u32 = 3;
  constant IOPAGES (line 224) | pub const IOPAGES: u32 = 2;
  constant IOPERM_BITMAP_SIZE (line 225) | pub const IOPERM_BITMAP_SIZE: u32 = 8193;
  constant KSTACK_PAGES (line 226) | pub const KSTACK_PAGES: u32 = 4;
  constant KSTACK_GUARD_PAGES (line 227) | pub const KSTACK_GUARD_PAGES: u32 = 1;
  constant CHAR_BIT (line 228) | pub const CHAR_BIT: u32 = 8;
  constant SCHAR_MAX (line 229) | pub const SCHAR_MAX: u32 = 127;
  constant SCHAR_MIN (line 230) | pub const SCHAR_MIN: i32 = -128;
  constant UCHAR_MAX (line 231) | pub const UCHAR_MAX: u32 = 255;
  constant CHAR_MAX (line 232) | pub const CHAR_MAX: u32 = 127;
  constant CHAR_MIN (line 233) | pub const CHAR_MIN: i32 = -128;
  constant USHRT_MAX (line 234) | pub const USHRT_MAX: u32 = 65535;
  constant SHRT_MAX (line 235) | pub const SHRT_MAX: u32 = 32767;
  constant SHRT_MIN (line 236) | pub const SHRT_MIN: i32 = -32768;
  constant UINT_MAX (line 237) | pub const UINT_MAX: u32 = 4294967295;
  constant INT_MAX (line 238) | pub const INT_MAX: u32 = 2147483647;
  constant INT_MIN (line 239) | pub const INT_MIN: i32 = -2147483648;
  constant ULONG_MAX (line 240) | pub const ULONG_MAX: i32 = -1;
  constant LONG_MAX (line 241) | pub const LONG_MAX: u64 = 9223372036854775807;
  constant LONG_MIN (line 242) | pub const LONG_MIN: i64 = -9223372036854775808;
  constant ULLONG_MAX (line 243) | pub const ULLONG_MAX: i32 = -1;
  constant LLONG_MAX (line 244) | pub const LLONG_MAX: u64 = 9223372036854775807;
  constant LLONG_MIN (line 245) | pub const LLONG_MIN: i64 = -9223372036854775808;
  constant SSIZE_MAX (line 246) | pub const SSIZE_MAX: u64 = 9223372036854775807;
  constant SIZE_T_MAX (line 247) | pub const SIZE_T_MAX: i32 = -1;
  constant OFF_MAX (line 248) | pub const OFF_MAX: u64 = 9223372036854775807;
  constant OFF_MIN (line 249) | pub const OFF_MIN: i64 = -9223372036854775808;
  constant GID_MAX (line 250) | pub const GID_MAX: u32 = 4294967295;
  constant UID_MAX (line 251) | pub const UID_MAX: u32 = 4294967295;
  constant UQUAD_MAX (line 252) | pub const UQUAD_MAX: i32 = -1;
  constant QUAD_MAX (line 253) | pub const QUAD_MAX: u64 = 9223372036854775807;
  constant QUAD_MIN (line 254) | pub const QUAD_MIN: i64 = -9223372036854775808;
  constant LONG_BIT (line 255) | pub const LONG_BIT: u32 = 64;
  constant WORD_BIT (line 256) | pub const WORD_BIT: u32 = 32;
  constant MQ_PRIO_MAX (line 257) | pub const MQ_PRIO_MAX: u32 = 64;
  constant DEV_BSHIFT (line 258) | pub const DEV_BSHIFT: u32 = 9;
  constant DEV_BSIZE (line 259) | pub const DEV_BSIZE: u32 = 512;
  constant BLKDEV_IOSIZE (line 260) | pub const BLKDEV_IOSIZE: u32 = 4096;
  constant DFLTPHYS (line 261) | pub const DFLTPHYS: u32 = 65536;
  constant MAXPHYS (line 262) | pub const MAXPHYS: u32 = 1048576;
  constant MAXDUMPPGS (line 263) | pub const MAXDUMPPGS: u32 = 16;
  constant MSIZE (line 264) | pub const MSIZE: u32 = 256;
  constant MCLSHIFT (line 265) | pub const MCLSHIFT: u32 = 11;
  constant MCLBYTES (line 266) | pub const MCLBYTES: u32 = 2048;
  constant MJUMPAGESIZE (line 267) | pub const MJUMPAGESIZE: u32 = 4096;
  constant MJUM9BYTES (line 268) | pub const MJUM9BYTES: u32 = 9216;
  constant MJUM16BYTES (line 269) | pub const MJUM16BYTES: u32 = 16384;
  constant PRIMASK (line 270) | pub const PRIMASK: u32 = 255;
  constant PCATCH (line 271) | pub const PCATCH: u32 = 256;
  constant PDROP (line 272) | pub const PDROP: u32 = 512;
  constant PNOLOCK (line 273) | pub const PNOLOCK: u32 = 1024;
  constant PRILASTFLAG (line 274) | pub const PRILASTFLAG: u32 = 1024;
  constant NZERO (line 275) | pub const NZERO: u32 = 0;
  constant NBBY (line 276) | pub const NBBY: u32 = 8;
  constant CMASK (line 277) | pub const CMASK: u32 = 18;
  constant MAXBSIZE (line 278) | pub const MAXBSIZE: u32 = 65536;
  constant MAXBCACHEBUF (line 279) | pub const MAXBCACHEBUF: u32 = 65536;
  constant BKVASIZE (line 280) | pub const BKVASIZE: u32 = 16384;
  constant BKVAMASK (line 281) | pub const BKVAMASK: u32 = 16383;
  constant MAXPATHLEN (line 282) | pub const MAXPATHLEN: u32 = 1024;
  constant MAXSYMLINKS (line 283) | pub const MAXSYMLINKS: u32 = 32;
  constant FSHIFT (line 284) | pub const FSHIFT: u32 = 11;
  constant FSCALE (line 285) | pub const FSCALE: u32 = 2048;
  constant CPU_MAXSIZE (line 286) | pub const CPU_MAXSIZE: u32 = 1024;
  constant CPU_SETSIZE (line 287) | pub const CPU_SETSIZE: u32 = 1024;
  constant CPU_LEVEL_ROOT (line 288) | pub const CPU_LEVEL_ROOT: u32 = 1;
  constant CPU_LEVEL_CPUSET (line 289) | pub const CPU_LEVEL_CPUSET: u32 = 2;
  constant CPU_LEVEL_WHICH (line 290) | pub const CPU_LEVEL_WHICH: u32 = 3;
  constant CPU_WHICH_TID (line 291) | pub const CPU_WHICH_TID: u32 = 1;
  constant CPU_WHICH_PID (line 292) | pub const CPU_WHICH_PID: u32 = 2;
  constant CPU_WHICH_CPUSET (line 293) | pub const CPU_WHICH_CPUSET: u32 = 3;
  constant CPU_WHICH_IRQ (line 294) | pub const CPU_WHICH_IRQ: u32 = 4;
  constant CPU_WHICH_JAIL (line 295) | pub const CPU_WHICH_JAIL: u32 = 5;
  constant CPU_WHICH_DOMAIN (line 296) | pub const CPU_WHICH_DOMAIN: u32 = 6;
  constant CPU_WHICH_INTRHANDLER (line 297) | pub const CPU_WHICH_INTRHANDLER: u32 = 7;
  constant CPU_WHICH_ITHREAD (line 298) | pub const CPU_WHICH_ITHREAD: u32 = 8;
  constant CPU_WHICH_TIDPID (line 299) | pub const CPU_WHICH_TIDPID: u32 = 9;
  constant CPUSET_INVALID (line 300) | pub const CPUSET_INVALID: i32 = -1;
  constant CPUSET_DEFAULT (line 301) | pub const CPUSET_DEFAULT: u32 = 0;
  constant M_NOWAIT (line 302) | pub const M_NOWAIT: u32 = 1;
  constant M_WAITOK (line 303) | pub const M_WAITOK: u32 = 2;
  constant M_NORECLAIM (line 304) | pub const M_NORECLAIM: u32 = 128;
  constant M_ZERO (line 305) | pub const M_ZERO: u32 = 256;
  constant M_NOVM (line 306) | pub const M_NOVM: u32 = 512;
  constant M_USE_RESERVE (line 307) | pub const M_USE_RESERVE: u32 = 1024;
  constant M_NODUMP (line 308) | pub const M_NODUMP: u32 = 2048;
  constant M_FIRSTFIT (line 309) | pub const M_FIRSTFIT: u32 = 4096;
  constant M_BESTFIT (line 310) | pub const M_BESTFIT: u32 = 8192;
  constant M_EXEC (line 311) | pub const M_EXEC: u32 = 16384;
  constant M_NEXTFIT (line 312) | pub const M_NEXTFIT: u32 = 32768;
  constant M_VERSION (line 313) | pub const M_VERSION: u32 = 2020110501;
  constant DTMALLOC_PROBE_MALLOC (line 314) | pub const DTMALLOC_PROBE_MALLOC: u32 = 0;
  constant DTMALLOC_PROBE_FREE (line 315) | pub const DTMALLOC_PROBE_FREE: u32 = 1;
  constant DTMALLOC_PROBE_MAX (line 316) | pub const DTMALLOC_PROBE_MAX: u32 = 2;
  constant MALLOC_TYPE_STREAM_VERSION (line 317) | pub const MALLOC_TYPE_STREAM_VERSION: u32 = 1;
  constant MALLOC_MAX_NAME (line 318) | pub const MALLOC_MAX_NAME: u32 = 32;
  constant __bool_true_false_are_defined (line 319) | pub const __bool_true_false_are_defined: u32 = 1;
  constant false_ (line 320) | pub const false_: u32 = 0;
  constant true_ (line 321) | pub const true_: u32 = 1;
  constant INT8_MIN (line 322) | pub const INT8_MIN: i32 = -128;
  constant INT16_MIN (line 323) | pub const INT16_MIN: i32 = -32768;
  constant INT32_MIN (line 324) | pub const INT32_MIN: i32 = -2147483648;
  constant INT8_MAX (line 325) | pub const INT8_MAX: u32 = 127;
  constant INT16_MAX (line 326) | pub const INT16_MAX: u32 = 32767;
  constant INT32_MAX (line 327) | pub const INT32_MAX: u32 = 2147483647;
  constant UINT8_MAX (line 328) | pub const UINT8_MAX: u32 = 255;
  constant UINT16_MAX (line 329) | pub const UINT16_MAX: u32 = 65535;
  constant UINT32_MAX (line 330) | pub const UINT32_MAX: u32 = 4294967295;
  constant INT64_MIN (line 331) | pub const INT64_MIN: i64 = -9223372036854775808;
  constant INT64_MAX (line 332) | pub const INT64_MAX: u64 = 9223372036854775807;
  constant UINT64_MAX (line 333) | pub const UINT64_MAX: i32 = -1;
  constant INT_LEAST8_MIN (line 334) | pub const INT_LEAST8_MIN: i32 = -128;
  constant INT_LEAST16_MIN (line 335) | pub const INT_LEAST16_MIN: i32 = -32768;
  constant INT_LEAST32_MIN (line 336) | pub const INT_LEAST32_MIN: i32 = -2147483648;
  constant INT_LEAST64_MIN (line 337) | pub const INT_LEAST64_MIN: i64 = -9223372036854775808;
  constant INT_LEAST8_MAX (line 338) | pub const INT_LEAST8_MAX: u32 = 127;
  constant INT_LEAST16_MAX (line 339) | pub const INT_LEAST16_MAX: u32 = 32767;
  constant INT_LEAST32_MAX (line 340) | pub const INT_LEAST32_MAX: u32 = 2147483647;
  constant INT_LEAST64_MAX (line 341) | pub const INT_LEAST64_MAX: u64 = 9223372036854775807;
  constant UINT_LEAST8_MAX (line 342) | pub const UINT_LEAST8_MAX: u32 = 255;
  constant UINT_LEAST16_MAX (line 343) | pub const UINT_LEAST16_MAX: u32 = 65535;
  constant UINT_LEAST32_MAX (line 344) | pub const UINT_LEAST32_MAX: u32 = 4294967295;
  constant UINT_LEAST64_MAX (line 345) | pub const UINT_LEAST64_MAX: i32 = -1;
  constant INT_FAST8_MIN (line 346) | pub const INT_FAST8_MIN: i32 = -2147483648;
  constant INT_FAST16_MIN (line 347) | pub const INT_FAST16_MIN: i32 = -2147483648;
  constant INT_FAST32_MIN (line 348) | pub const INT_FAST32_MIN: i32 = -2147483648;
  constant INT_FAST64_MIN (line 349) | pub const INT_FAST64_MIN: i64 = -9223372036854775808;
  constant INT_FAST8_MAX (line 350) | pub const INT_FAST8_MAX: u32 = 2147483647;
  constant INT_FAST16_MAX (line 351) | pub const INT_FAST16_MAX: u32 = 2147483647;
  constant INT_FAST32_MAX (line 352) | pub const INT_FAST32_MAX: u32 = 2147483647;
  constant INT_FAST64_MAX (line 353) | pub const INT_FAST64_MAX: u64 = 9223372036854775807;
  constant UINT_FAST8_MAX (line 354) | pub const UINT_FAST8_MAX: u32 = 4294967295;
  constant UINT_FAST16_MAX (line 355) | pub const UINT_FAST16_MAX: u32 = 4294967295;
  constant UINT_FAST32_MAX (line 356) | pub const UINT_FAST32_MAX: u32 = 4294967295;
  constant UINT_FAST64_MAX (line 357) | pub const UINT_FAST64_MAX: i32 = -1;
  constant INTPTR_MIN (line 358) | pub const INTPTR_MIN: i64 = -9223372036854775808;
  constant INTPTR_MAX (line 359) | pub const INTPTR_MAX: u64 = 9223372036854775807;
  constant UINTPTR_MAX (line 360) | pub const UINTPTR_MAX: i32 = -1;
  constant INTMAX_MIN (line 361) | pub const INTMAX_MIN: i64 = -9223372036854775808;
  constant INTMAX_MAX (line 362) | pub const INTMAX_MAX: u64 = 9223372036854775807;
  constant UINTMAX_MAX (line 363) | pub const UINTMAX_MAX: i32 = -1;
  constant PTRDIFF_MIN (line 364) | pub const PTRDIFF_MIN: i64 = -9223372036854775808;
  constant PTRDIFF_MAX (line 365) | pub const PTRDIFF_MAX: u64 = 9223372036854775807;
  constant SIG_ATOMIC_MIN (line 366) | pub const SIG_ATOMIC_MIN: i64 = -9223372036854775808;
  constant SIG_ATOMIC_MAX (line 367) | pub const SIG_ATOMIC_MAX: u64 = 9223372036854775807;
  constant SIZE_MAX (line 368) | pub const SIZE_MAX: i32 = -1;
  constant WINT_MIN (line 369) | pub const WINT_MIN: i32 = -2147483648;
  constant WINT_MAX (line 370) | pub const WINT_MAX: u32 = 2147483647;
  constant __WORDSIZE (line 371) | pub const __WORDSIZE: u32 = 64;
  constant WCHAR_MIN (line 372) | pub const WCHAR_MIN: i32 = -2147483648;
  constant WCHAR_MAX (line 373) | pub const WCHAR_MAX: u32 = 2147483647;
  constant RSIZE_MAX (line 374) | pub const RSIZE_MAX: i32 = -1;
  constant __SLBF (line 375) | pub const __SLBF: u32 = 1;
  constant __SNBF (line 376) | pub const __SNBF: u32 = 2;
  constant __SRD (line 377) | pub const __SRD: u32 = 4;
  constant __SWR (line 378) | pub const __SWR: u32 = 8;
  constant __SRW (line 379) | pub const __SRW: u32 = 16;
  constant __SEOF (line 380) | pub const __SEOF: u32 = 32;
  constant __SERR (line 381) | pub const __SERR: u32 = 64;
  constant __SMBF (line 382) | pub const __SMBF: u32 = 128;
  constant __SAPP (line 383) | pub const __SAPP: u32 = 256;
  constant __SSTR (line 384) | pub const __SSTR: u32 = 512;
  constant __SOPT (line 385) | pub const __SOPT: u32 = 1024;
  constant __SNPT (line 386) | pub const __SNPT: u32 = 2048;
  constant __SOFF (line 387) | pub const __SOFF: u32 = 4096;
  constant __SMOD (line 388) | pub const __SMOD: u32 = 8192;
  constant __SALC (line 389) | pub const __SALC: u32 = 16384;
  constant __SIGN (line 390) | pub const __SIGN: u32 = 32768;
  constant __S2OAP (line 391) | pub const __S2OAP: u32 = 1;
  constant _IOFBF (line 392) | pub const _IOFBF: u32 = 0;
  constant _IOLBF (line 393) | pub const _IOLBF: u32 = 1;
  constant _IONBF (line 394) | pub const _IONBF: u32 = 2;
  constant BUFSIZ (line 395) | pub const BUFSIZ: u32 = 1024;
  constant EOF (line 396) | pub const EOF: i32 = -1;
  constant FOPEN_MAX (line 397) | pub const FOPEN_MAX: u32 = 20;
  constant FILENAME_MAX (line 398) | pub const FILENAME_MAX: u32 = 1024;
  constant P_tmpdir (line 399) | pub const P_tmpdir: &[u8; 6] = b"/tmp/\0";
  constant L_tmpnam (line 400) | pub const L_tmpnam: u32 = 1024;
  constant TMP_MAX (line 401) | pub const TMP_MAX: u32 = 308915776;
  constant SEEK_SET (line 402) | pub const SEEK_SET: u32 = 0;
  constant SEEK_CUR (line 403) | pub const SEEK_CUR: u32 = 1;
  constant SEEK_END (line 404) | pub const SEEK_END: u32 = 2;
  constant L_cuserid (line 405) | pub const L_cuserid: u32 = 17;
  constant L_ctermid (line 406) | pub const L_ctermid: u32 = 1024;
  constant NV_NAME_MAX (line 407) | pub const NV_NAME_MAX: u32 = 2048;
  constant NV_TYPE_NONE (line 408) | pub const NV_TYPE_NONE: u32 = 0;
  constant NV_TYPE_NULL (line 409) | pub const NV_TYPE_NULL: u32 = 1;
  constant NV_TYPE_BOOL (line 410) | pub const NV_TYPE_BOOL: u32 = 2;
  constant NV_TYPE_NUMBER (line 411) | pub const NV_TYPE_NUMBER: u32 = 3;
  constant NV_TYPE_STRING (line 412) | pub const NV_TYPE_STRING: u32 = 4;
  constant NV_TYPE_NVLIST (line 413) | pub const NV_TYPE_NVLIST: u32 = 5;
  constant NV_TYPE_DESCRIPTOR (line 414) | pub const NV_TYPE_DESCRIPTOR: u32 = 6;
  constant NV_TYPE_BINARY (line 415) | pub const NV_TYPE_BINARY: u32 = 7;
  constant NV_TYPE_BOOL_ARRAY (line 416) | pub const NV_TYPE_BOOL_ARRAY: u32 = 8;
  constant NV_TYPE_NUMBER_ARRAY (line 417) | pub const NV_TYPE_NUMBER_ARRAY: u32 = 9;
  constant NV_TYPE_STRING_ARRAY (line 418) | pub const NV_TYPE_STRING_ARRAY: u32 = 10;
  constant NV_TYPE_NVLIST_ARRAY (line 419) | pub const NV_TYPE_NVLIST_ARRAY: u32 = 11;
  constant NV_TYPE_DESCRIPTOR_ARRAY (line 420) | pub const NV_TYPE_DESCRIPTOR_ARRAY: u32 = 12;
  constant NV_FLAG_IGNORE_CASE (line 421) | pub const NV_FLAG_IGNORE_CASE: u32 = 1;
  constant NV_FLAG_NO_UNIQUE (line 422) | pub const NV_FLAG_NO_UNIQUE: u32 = 2;
  constant REFCOUNT_SATURATION_VALUE (line 423) | pub const REFCOUNT_SATURATION_VALUE: u32 = 3221225472;
  constant _DTRACE_VERSION (line 424) | pub const _DTRACE_VERSION: u32 = 1;
  constant CTL_MAXNAME (line 425) | pub const CTL_MAXNAME: u32 = 24;
  constant CTLTYPE (line 426) | pub const CTLTYPE: u32 = 15;
  constant CTLTYPE_NODE (line 427) | pub const CTLTYPE_NODE: u32 = 1;
  constant CTLTYPE_INT (line 428) | pub const CTLTYPE_INT: u32 = 2;
  constant CTLTYPE_STRING (line 429) | pub const CTLTYPE_STRING: u32 = 3;
  constant CTLTYPE_S64 (line 430) | pub const CTLTYPE_S64: u32 = 4;
  constant CTLTYPE_OPAQUE (line 431) | pub const CTLTYPE_OPAQUE: u32 = 5;
  constant CTLTYPE_STRUCT (line 432) | pub const CTLTYPE_STRUCT: u32 = 5;
  constant CTLTYPE_UINT (line 433) | pub const CTLTYPE_UINT: u32 = 6;
  constant CTLTYPE_LONG (line 434) | pub const CTLTYPE_LONG: u32 = 7;
  constant CTLTYPE_ULONG (line 435) | pub const CTLTYPE_ULONG: u32 = 8;
  constant CTLTYPE_U64 (line 436) | pub const CTLTYPE_U64: u32 = 9;
  constant CTLTYPE_U8 (line 437) | pub const CTLTYPE_U8: u32 = 10;
  constant CTLTYPE_U16 (line 438) | pub const CTLTYPE_U16: u32 = 11;
  constant CTLTYPE_S8 (line 439) | pub const CTLTYPE_S8: u32 = 12;
  constant CTLTYPE_S16 (line 440) | pub const CTLTYPE_S16: u32 = 13;
  constant CTLTYPE_S32 (line 441) | pub const CTLTYPE_S32: u32 = 14;
  constant CTLTYPE_U32 (line 442) | pub const CTLTYPE_U32: u32 = 15;
  constant CTLFLAG_RD (line 443) | pub const CTLFLAG_RD: u32 = 2147483648;
  constant CTLFLAG_WR (line 444) | pub const CTLFLAG_WR: u32 = 1073741824;
  constant CTLFLAG_RW (line 445) | pub const CTLFLAG_RW: u32 = 3221225472;
  constant CTLFLAG_DORMANT (line 446) | pub const CTLFLAG_DORMANT: u32 = 536870912;
  constant CTLFLAG_ANYBODY (line 447) | pub const CTLFLAG_ANYBODY: u32 = 268435456;
  constant CTLFLAG_SECURE (line 448) | pub const CTLFLAG_SECURE: u32 = 134217728;
  constant CTLFLAG_PRISON (line 449) | pub const CTLFLAG_PRISON: u32 = 67108864;
  constant CTLFLAG_DYN (line 450) | pub const CTLFLAG_DYN: u32 = 33554432;
  constant CTLFLAG_SKIP (line 451) | pub const CTLFLAG_SKIP: u32 = 16777216;
  constant CTLMASK_SECURE (line 452) | pub const CTLMASK_SECURE: u32 = 15728640;
  constant CTLFLAG_TUN (line 453) | pub const CTLFLAG_TUN: u32 = 524288;
  constant CTLFLAG_RDTUN (line 454) | pub const CTLFLAG_RDTUN: u32 = 2148007936;
  constant CTLFLAG_RWTUN (line 455) | pub const CTLFLAG_RWTUN: u32 = 3221749760;
  constant CTLFLAG_MPSAFE (line 456) | pub const CTLFLAG_MPSAFE: u32 = 262144;
  constant CTLFLAG_VNET (line 457) | pub const CTLFLAG_VNET: u32 = 131072;
  constant CTLFLAG_DYING (line 458) | pub const CTLFLAG_DYING: u32 = 65536;
  constant CTLFLAG_CAPRD (line 459) | pub const CTLFLAG_CAPRD: u32 = 32768;
  constant CTLFLAG_CAPWR (line 460) | pub const CTLFLAG_CAPWR: u32 = 16384;
  constant CTLFLAG_STATS (line 461) | pub const CTLFLAG_STATS: u32 = 8192;
  constant CTLFLAG_NOFETCH (line 462) | pub const CTLFLAG_NOFETCH: u32 = 4096;
  constant CTLFLAG_CAPRW (line 463) | pub const CTLFLAG_CAPRW: u32 = 49152;
  constant CTLFLAG_NEEDGIANT (line 464) | pub const CTLFLAG_NEEDGIANT: u32 = 2048;
  constant CTLSHIFT_SECURE (line 465) | pub const CTLSHIFT_SECURE: u32 = 20;
  constant CTLFLAG_SECURE1 (line 466) | pub const CTLFLAG_SECURE1: u32 = 134217728;
  constant CTLFLAG_SECURE2 (line 467) | pub const CTLFLAG_SECURE2: u32 = 135266304;
  constant CTLFLAG_SECURE3 (line 468) | pub const CTLFLAG_SECURE3: u32 = 136314880;
  constant OID_AUTO (line 469) | pub const OID_AUTO: i32 = -1;
  constant CTL_AUTO_START (line 470) | pub const CTL_AUTO_START: u32 = 256;
  constant CTL_SYSCTL (line 471) | pub const CTL_SYSCTL: u32 = 0;
  constant CTL_KERN (line 472) | pub const CTL_KERN: u32 = 1;
  constant CTL_VM (line 473) | pub const CTL_VM: u32 = 2;
  constant CTL_VFS (line 474) | pub const CTL_VFS: u32 = 3;
  constant CTL_NET (line 475) | pub const CTL_NET: u32 = 4;
  constant CTL_DEBUG (line 476) | pub const CTL_DEBUG: u32 = 5;
  constant CTL_HW (line 477) | pub const CTL_HW: u32 = 6;
  constant CTL_MACHDEP (line 478) | pub const CTL_MACHDEP: u32 = 7;
  constant CTL_USER (line 479) | pub const CTL_USER: u32 = 8;
  constant CTL_P1003_1B (line 480) | pub const CTL_P1003_1B: u32 = 9;
  constant CTL_SYSCTL_DEBUG (line 481) | pub const CTL_SYSCTL_DEBUG: u32 = 0;
  constant CTL_SYSCTL_NAME (line 482) | pub const CTL_SYSCTL_NAME: u32 = 1;
  constant CTL_SYSCTL_NEXT (line 483) | pub const CTL_SYSCTL_NEXT: u32 = 2;
  constant CTL_SYSCTL_NAME2OID (line 484) | pub const CTL_SYSCTL_NAME2OID: u32 = 3;
  constant CTL_SYSCTL_OIDFMT (line 485) | pub const CTL_SYSCTL_OIDFMT: u32 = 4;
  constant CTL_SYSCTL_OIDDESCR (line 486) | pub const CTL_SYSCTL_OIDDESCR: u32 = 5;
  constant CTL_SYSCTL_OIDLABEL (line 487) | pub const CTL_SYSCTL_OIDLABEL: u32 = 6;
  constant CTL_SYSCTL_NEXTNOSKIP (line 488) | pub const CTL_SYSCTL_NEXTNOSKIP: u32 = 7;
  constant KERN_OSTYPE (line 489) | pub const KERN_OSTYPE: u32 = 1;
  constant KERN_OSRELEASE (line 490) | pub const KERN_OSRELEASE: u32 = 2;
  constant KERN_OSREV (line 491) | pub const KERN_OSREV: u32 = 3;
  constant KERN_VERSION (line 492) | pub const KERN_VERSION: u32 = 4;
  constant KERN_MAXVNODES (line 493) | pub const KERN_MAXVNODES: u32 = 5;
  constant KERN_MAXPROC (line 494) | pub const KERN_MAXPROC: u32 = 6;
  constant KERN_MAXFILES (line 495) | pub const KERN_MAXFILES: u32 = 7;
  constant KERN_ARGMAX (line 496) | pub const KERN_ARGMAX: u32 = 8;
  constant KERN_SECURELVL (line 497) | pub const KERN_SECURELVL: u32 = 9;
  constant KERN_HOSTNAME (line 498) | pub const KERN_HOSTNAME: u32 = 10;
  constant KERN_HOSTID (line 499) | pub const KERN_HOSTID: u32 = 11;
  constant KERN_CLOCKRATE (line 500) | pub const KERN_CLOCKRATE: u32 = 12;
  constant KERN_PROC (line 501) | pub const KERN_PROC: u32 = 14;
  constant KERN_FILE (line 502) | pub const KERN_FILE: u32 = 15;
  constant KERN_PROF (line 503) | pub const KERN_PROF: u32 = 16;
  constant KERN_POSIX1 (line 504) | pub const KERN_POSIX1: u32 = 17;
  constant KERN_NGROUPS (line 505) | pub const KERN_NGROUPS: u32 = 18;
  constant KERN_JOB_CONTROL (line 506) | pub const KERN_JOB_CONTROL: u32 = 19;
  constant KERN_SAVED_IDS (line 507) | pub const KERN_SAVED_IDS: u32 = 20;
  constant KERN_BOOTTIME (line 508) | pub const KERN_BOOTTIME: u32 = 21;
  constant KERN_NISDOMAINNAME (line 509) | pub const KERN_NISDOMAINNAME: u32 = 22;
  constant KERN_UPDATEINTERVAL (line 510) | pub const KERN_UPDATEINTERVAL: u32 = 23;
  constant KERN_OSRELDATE (line 511) | pub const KERN_OSRELDATE: u32 = 24;
  constant KERN_NTP_PLL (line 512) | pub const KERN_NTP_PLL: u32 = 25;
  constant KERN_BOOTFILE (line 513) | pub const KERN_BOOTFILE: u32 = 26;
  constant KERN_MAXFILESPERPROC (line 514) | pub const KERN_MAXFILESPERPROC: u32 = 27;
  constant KERN_MAXPROCPERUID (line 515) | pub const KERN_MAXPROCPERUID: u32 = 28;
  constant KERN_DUMPDEV (line 516) | pub const KERN_DUMPDEV: u32 = 29;
  constant KERN_IPC (line 517) | pub const KERN_IPC: u32 = 30;
  constant KERN_DUMMY (line 518) | pub const KERN_DUMMY: u32 = 31;
  constant KERN_PS_STRINGS (line 519) | pub const KERN_PS_STRINGS: u32 = 32;
  constant KERN_USRSTACK (line 520) | pub const KERN_USRSTACK: u32 = 33;
  constant KERN_LOGSIGEXIT (line 521) | pub const KERN_LOGSIGEXIT: u32 = 34;
  constant KERN_IOV_MAX (line 522) | pub const KERN_IOV_MAX: u32 = 35;
  constant KERN_HOSTUUID (line 523) | pub const KERN_HOSTUUID: u32 = 36;
  constant KERN_ARND (line 524) | pub const KERN_ARND: u32 = 37;
  constant KERN_MAXPHYS (line 525) | pub const KERN_MAXPHYS: u32 = 38;
  constant KERN_LOCKF (line 526) | pub const KERN_LOCKF: u32 = 39;
  constant KERN_PROC_ALL (line 527) | pub const KERN_PROC_ALL: u32 = 0;
  constant KERN_PROC_PID (line 528) | pub const KERN_PROC_PID: u32 = 1;
  constant KERN_PROC_PGRP (line 529) | pub const KERN_PROC_PGRP: u32 = 2;
  constant KERN_PROC_SESSION (line 530) | pub const KERN_PROC_SESSION: u32 = 3;
  constant KERN_PROC_TTY (line 531) | pub const KERN_PROC_TTY: u32 = 4;
  constant KERN_PROC_UID (line 532) | pub const KERN_PROC_UID: u32 = 5;
  constant KERN_PROC_RUID (line 533) | pub const KERN_PROC_RUID: u32 = 6;
  constant KERN_PROC_ARGS (line 534) | pub const KERN_PROC_ARGS: u32 = 7;
  constant KERN_PROC_PROC (line 535) | pub const KERN_PROC_PROC: u32 = 8;
  constant KERN_PROC_SV_NAME (line 536) | pub const KERN_PROC_SV_NAME: u32 = 9;
  constant KERN_PROC_RGID (line 537) | pub const KERN_PROC_RGID: u32 = 10;
  constant KERN_PROC_GID (line 538) | pub const KERN_PROC_GID: u32 = 11;
  constant KERN_PROC_PATHNAME (line 539) | pub const KERN_PROC_PATHNAME: u32 = 12;
  constant KERN_PROC_OVMMAP (line 540) | pub const KERN_PROC_OVMMAP: u32 = 13;
  constant KERN_PROC_OFILEDESC (line 541) | pub const KERN_PROC_OFILEDESC: u32 = 14;
  constant KERN_PROC_KSTACK (line 542) | pub const KERN_PROC_KSTACK: u32 = 15;
  constant KERN_PROC_INC_THREAD (line 543) | pub const KERN_PROC_INC_THREAD: u32 = 16;
  constant KERN_PROC_VMMAP (line 544) | pub const KERN_PROC_VMMAP: u32 = 32;
  constant KERN_PROC_FILEDESC (line 545) | pub const KERN_PROC_FILEDESC: u32 = 33;
  constant KERN_PROC_GROUPS (line 546) | pub const KERN_PROC_GROUPS: u32 = 34;
  constant KERN_PROC_ENV (line 547) | pub const KERN_PROC_ENV: u32 = 35;
  constant KERN_PROC_AUXV (line 548) | pub const KERN_PROC_AUXV: u32 = 36;
  constant KERN_PROC_RLIMIT (line 549) | pub const KERN_PROC_RLIMIT: u32 = 37;
  constant KERN_PROC_PS_STRINGS (line 550) | pub const KERN_PROC_PS_STRINGS: u32 = 38;
  constant KERN_PROC_UMASK (line 551) | pub const KERN_PROC_UMASK: u32 = 39;
  constant KERN_PROC_OSREL (line 552) | pub const KERN_PROC_OSREL: u32 = 40;
  constant KERN_PROC_SIGTRAMP (line 553) | pub const KERN_PROC_SIGTRAMP: u32 = 41;
  constant KERN_PROC_CWD (line 554) | pub const KERN_PROC_CWD: u32 = 42;
  constant KERN_PROC_NFDS (line 555) | pub const KERN_PROC_NFDS: u32 = 43;
  constant KERN_PROC_SIGFASTBLK (line 556) | pub const KERN_PROC_SIGFASTBLK: u32 = 44;
  constant KERN_PROC_VM_LAYOUT (line 557) | pub const KERN_PROC_VM_LAYOUT: u32 = 45;
  constant KIPC_MAXSOCKBUF (line 558) | pub const KIPC_MAXSOCKBUF: u32 = 1;
  constant KIPC_SOCKBUF_WASTE (line 559) | pub const KIPC_SOCKBUF_WASTE: u32 = 2;
  constant KIPC_SOMAXCONN (line 560) | pub const KIPC_SOMAXCONN: u32 = 3;
  constant KIPC_MAX_LINKHDR (line 561) | pub const KIPC_MAX_LINKHDR: u32 = 4;
  constant KIPC_MAX_PROTOHDR (line 562) | pub const KIPC_MAX_PROTOHDR: u32 = 5;
  constant KIPC_MAX_HDR (line 563) | pub const KIPC_MAX_HDR: u32 = 6;
  constant KIPC_MAX_DATALEN (line 564) | pub const KIPC_MAX_DATALEN: u32 = 7;
  constant HW_MACHINE (line 565) | pub const HW_MACHINE: u32 = 1;
  constant HW_MODEL (line 566) | pub const HW_MODEL: u32 = 2;
  constant HW_NCPU (line 567) | pub const HW_NCPU: u32 = 3;
  constant HW_BYTEORDER (line 568) | pub const HW_BYTEORDER: u32 = 4;
  constant HW_PHYSMEM (line 569) | pub const HW_PHYSMEM: u32 = 5;
  constant HW_USERMEM (line 570) | pub const HW_USERMEM: u32 = 6;
  constant HW_PAGESIZE (line 571) | pub const HW_PAGESIZE: u32 = 7;
  constant HW_DISKNAMES (line 572) | pub const HW_DISKNAMES: u32 = 8;
  constant HW_DISKSTATS (line 573) | pub const HW_DISKSTATS: u32 = 9;
  constant HW_FLOATINGPT (line 574) | pub const HW_FLOATINGPT: u32 = 10;
  constant HW_MACHINE_ARCH (line 575) | pub const HW_MACHINE_ARCH: u32 = 11;
  constant HW_REALMEM (line 576) | pub const HW_REALMEM: u32 = 12;
  constant USER_CS_PATH (line 577) | pub const USER_CS_PATH: u32 = 1;
  constant USER_BC_BASE_MAX (line 578) | pub const USER_BC_BASE_MAX: u32 = 2;
  constant USER_BC_DIM_MAX (line 579) | pub const USER_BC_DIM_MAX: u32 = 3;
  constant USER_BC_SCALE_MAX (line 580) | pub const USER_BC_SCALE_MAX: u32 = 4;
  constant USER_BC_STRING_MAX (line 581) | pub const USER_BC_STRING_MAX: u32 = 5;
  constant USER_COLL_WEIGHTS_MAX (line 582) | pub const USER_COLL_WEIGHTS_MAX: u32 = 6;
  constant USER_EXPR_NEST_MAX (line 583) | pub const USER_EXPR_NEST_MAX: u32 = 7;
  constant USER_LINE_MAX (line 584) | pub const USER_LINE_MAX: u32 = 8;
  constant USER_RE_DUP_MAX (line 585) | pub const USER_RE_DUP_MAX: u32 = 9;
  constant USER_POSIX2_VERSION (line 586) | pub const USER_POSIX2_VERSION: u32 = 10;
  constant USER_POSIX2_C_BIND (line 587) | pub const USER_POSIX2_C_BIND: u32 = 11;
  constant USER_POSIX2_C_DEV (line 588) | pub const USER_POSIX2_C_DEV: u32 = 12;
  constant USER_POSIX2_CHAR_TERM (line 589) | pub const USER_POSIX2_CHAR_TERM: u32 = 13;
  constant USER_POSIX2_FORT_DEV (line 590) | pub const USER_POSIX2_FORT_DEV: u32 = 14;
  constant USER_POSIX2_FORT_RUN (line 591) | pub const USER_POSIX2_FORT_RUN: u32 = 15;
  constant USER_POSIX2_LOCALEDEF (line 592) | pub const USER_POSIX2_LOCALEDEF: u32 = 16;
  constant USER_POSIX2_SW_DEV (line 593) | pub const USER_POSIX2_SW_DEV: u32 = 17;
  constant USER_POSIX2_UPE (line 594) | pub const USER_POSIX2_UPE: u32 = 18;
  constant USER_STREAM_MAX (line 595) | pub const USER_STREAM_MAX: u32 = 19;
  constant USER_TZNAME_MAX (line 596) | pub const USER_TZNAME_MAX: u32 = 20;
  constant USER_LOCALBASE (line 597) | pub const USER_LOCALBASE: u32 = 21;
  constant CTL_P1003_1B_ASYNCHRONOUS_IO (line 598) | pub const CTL_P1003_1B_ASYNCHRONOUS_IO: u32 = 1;
  constant CTL_P1003_1B_MAPPED_FILES (line 599) | pub const CTL_P1003_1B_MAPPED_FILES: u32 = 2;
  constant CTL_P1003_1B_MEMLOCK (line 600) | pub const CTL_P1003_1B_MEMLOCK: u32 = 3;
  constant CTL_P1003_1B_MEMLOCK_RANGE (line 601) | pub const CTL_P1003_1B_MEMLOCK_RANGE: u32 = 4;
  constant CTL_P1003_1B_MEMORY_PROTECTION (line 602) | pub const CTL_P1003_1B_MEMORY_PROTECTION: u32 = 5;
  constant CTL_P1003_1B_MESSAGE_PASSING (line 603) | pub const CTL_P1003_1B_MESSAGE_PASSING: u32 = 6;
  constant CTL_P1003_1B_PRIORITIZED_IO (line 604) | pub const CTL_P1003_1B_PRIORITIZED_IO: u32 = 7;
  constant CTL_P1003_1B_PRIORITY_SCHEDULING (line 605) | pub const CTL_P1003_1B_PRIORITY_SCHEDULING: u32 = 8;
  constant CTL_P1003_1B_REALTIME_SIGNALS (line 606) | pub const CTL_P1003_1B_REALTIME_SIGNALS: u32 = 9;
  constant CTL_P1003_1B_SEMAPHORES (line 607) | pub const CTL_P1003_1B_SEMAPHORES: u32 = 10;
  constant CTL_P1003_1B_FSYNC (line 608) | pub const CTL_P1003_1B_FSYNC: u32 = 11;
  constant CTL_P1003_1B_SHARED_MEMORY_OBJECTS (line 609) | pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: u32 = 12;
  constant CTL_P1003_1B_SYNCHRONIZED_IO (line 610) | pub const CTL_P1003_1B_SYNCHRONIZED_IO: u32 = 13;
  constant CTL_P1003_1B_TIMERS (line 611) | pub const CTL_P1003_1B_TIMERS: u32 = 14;
  constant CTL_P1003_1B_AIO_LISTIO_MAX (line 612) | pub const CTL_P1003_1B_AIO_LISTIO_MAX: u32 = 15;
  constant CTL_P1003_1B_AIO_MAX (line 613) | pub const CTL_P1003_1B_AIO_MAX: u32 = 16;
  constant CTL_P1003_1B_AIO_PRIO_DELTA_MAX (line 614) | pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: u32 = 17;
  constant CTL_P1003_1B_DELAYTIMER_MAX (line 615) | pub const CTL_P1003_1B_DELAYTIMER_MAX: u32 = 18;
  constant CTL_P1003_1B_MQ_OPEN_MAX (line 616) | pub const CTL_P1003_1B_MQ_OPEN_MAX: u32 = 19;
  constant CTL_P1003_1B_PAGESIZE (line 617) | pub const CTL_P1003_1B_PAGESIZE: u32 = 20;
  constant CTL_P1003_1B_RTSIG_MAX (line 618) | pub const CTL_P1003_1B_RTSIG_MAX: u32 = 21;
  constant CTL_P1003_1B_SEM_NSEMS_MAX (line 619) | pub const CTL_P1003_1B_SEM_NSEMS_MAX: u32 = 22;
  constant CTL_P1003_1B_SEM_VALUE_MAX (line 620) | pub const CTL_P1003_1B_SEM_VALUE_MAX: u32 = 23;
  constant CTL_P1003_1B_SIGQUEUE_MAX (line 621) | pub const CTL_P1003_1B_SIGQUEUE_MAX: u32 = 24;
  constant CTL_P1003_1B_TIMER_MAX (line 622) | pub const CTL_P1003_1B_TIMER_MAX: u32 = 25;
  constant KTR_GEN (line 623) | pub const KTR_GEN: u32 = 1;
  constant KTR_NET (line 624) | pub const KTR_NET: u32 = 2;
  constant KTR_DEV (line 625) | pub const KTR_DEV: u32 = 4;
  constant KTR_LOCK (line 626) | pub const KTR_LOCK: u32 = 8;
  constant KTR_SMP (line 627) | pub const KTR_SMP: u32 = 16;
  constant KTR_SUBSYS (line 628) | pub const KTR_SUBSYS: u32 = 32;
  constant KTR_PMAP (line 629) | pub const KTR_PMAP: u32 = 64;
  constant KTR_MALLOC (line 630) | pub const KTR_MALLOC: u32 = 128;
  constant KTR_TRAP (line 631) | pub const KTR_TRAP: u32 = 256;
  constant KTR_INTR (line 632) | pub const KTR_INTR: u32 = 512;
  constant KTR_SIG (line 633) | pub const KTR_SIG: u32 = 1024;
  constant KTR_SPARE2 (line 634) | pub const KTR_SPARE2: u32 = 2048;
  constant KTR_PROC (line 635) | pub const KTR_PROC: u32 = 4096;
  constant KTR_SYSC (line 636) | pub const KTR_SYSC: u32 = 8192;
  constant KTR_INIT (line 637) | pub const KTR_INIT: u32 = 16384;
  constant KTR_SPARE3 (line 638) | pub const KTR_SPARE3: u32 = 32768;
  constant KTR_SPARE4 (line 639) | pub const KTR_SPARE4: u32 = 65536;
  constant KTR_EVH (line 640) | pub const KTR_EVH: u32 = 131072;
  constant KTR_VFS (line 641) | pub const KTR_VFS: u32 = 262144;
  constant KTR_VOP (line 642) | pub const KTR_VOP: u32 = 524288;
  constant KTR_VM (line 643) | pub const KTR_VM: u32 = 1048576;
  constant KTR_INET (line 644) | pub const KTR_INET: u32 = 2097152;
  constant KTR_RUNQ (line 645) | pub const KTR_RUNQ: u32 = 4194304;
  constant KTR_SPARE5 (line 646) | pub const KTR_SPARE5: u32 = 8388608;
  constant KTR_UMA (line 647) | pub const KTR_UMA: u32 = 16777216;
  constant KTR_CALLOUT (line 648) | pub const KTR_CALLOUT: u32 = 33554432;
  constant KTR_GEOM (line 649) | pub const KTR_GEOM: u32 = 67108864;
  constant KTR_BUSDMA (line 650) | pub const KTR_BUSDMA: u32 = 134217728;
  constant KTR_INET6 (line 651) | pub const KTR_INET6: u32 = 268435456;
  constant KTR_SCHED (line 652) | pub const KTR_SCHED: u32 = 536870912;
  constant KTR_BUF (line 653) | pub const KTR_BUF: u32 = 1073741824;
  constant KTR_PTRACE (line 654) | pub const KTR_PTRACE: u32 = 2147483648;
  constant KTR_ALL (line 655) | pub const KTR_ALL: u32 = 4294967295;
  constant KTR_COMPILE (line 656) | pub const KTR_COMPILE: u32 = 0;
  constant LC_SLEEPLOCK (line 657) | pub const LC_SLEEPLOCK: u32 = 1;
  constant LC_SPINLOCK (line 658) | pub const LC_SPINLOCK: u32 = 2;
  constant LC_SLEEPABLE (line 659) | pub const LC_SLEEPABLE: u32 = 4;
  constant LC_RECURSABLE (line 660) | pub const LC_RECURSABLE: u32 = 8;
  constant LC_UPGRADABLE (line 661) | pub const LC_UPGRADABLE: u32 = 16;
  constant LO_CLASSFLAGS (line 662) | pub const LO_CLASSFLAGS: u32 = 65535;
  constant LO_INITIALIZED (line 663) | pub const LO_INITIALIZED: u32 = 65536;
  constant LO_WITNESS (line 664) | pub const LO_WITNESS: u32 = 131072;
  constant LO_QUIET (line 665) | pub const LO_QUIET: u32 = 262144;
  constant LO_RECURSABLE (line 666) | pub const LO_RECURSABLE: u32 = 524288;
  constant LO_SLEEPABLE (line 667) | pub const LO_SLEEPABLE: u32 = 1048576;
  constant LO_UPGRADABLE (line 668) | pub const LO_UPGRADABLE: u32 = 2097152;
  constant LO_DUPOK (line 669) | pub const LO_DUPOK: u32 = 4194304;
  constant LO_IS_VNODE (line 670) | pub const LO_IS_VNODE: u32 = 8388608;
  constant LO_CLASSMASK (line 671) | pub const LO_CLASSMASK: u32 = 251658240;
  constant LO_NOPROFILE (line 672) | pub const LO_NOPROFILE: u32 = 268435456;
  constant LO_NEW (line 673) | pub const LO_NEW: u32 = 536870912;
  constant LO_CLASSSHIFT (line 674) | pub const LO_CLASSSHIFT: u32 = 24;
  constant LOCK_CLASS_MAX (line 675) | pub const LOCK_CLASS_MAX: u32 = 15;
  constant LOP_NEWORDER (line 676) | pub const LOP_NEWORDER: u32 = 1;
  constant LOP_QUIET (line 677) | pub const LOP_QUIET: u32 = 2;
  constant LOP_TRYLOCK (line 678) | pub const LOP_TRYLOCK: u32 = 4;
  constant LOP_EXCLUSIVE (line 679) | pub const LOP_EXCLUSIVE: u32 = 8;
  constant LOP_DUPOK (line 680) | pub const LOP_DUPOK: u32 = 16;
  constant LOP_NOSLEEP (line 681) | pub const LOP_NOSLEEP: u32 = 32;
  constant LA_MASKASSERT (line 682) | pub const LA_MASKASSERT: u32 = 255;
  constant LA_UNLOCKED (line 683) | pub const LA_UNLOCKED: u32 = 0;
  constant LA_LOCKED (line 684) | pub const LA_LOCKED: u32 = 1;
  constant LA_SLOCKED (line 685) | pub const LA_SLOCKED: u32 = 2;
  constant LA_XLOCKED (line 686) | pub const LA_XLOCKED: u32 = 4;
  constant LA_RECURSED (line 687) | pub const LA_RECURSED: u32 = 8;
  constant LA_NOTRECURSED (line 688) | pub const LA_NOTRECURSED: u32 = 16;
  constant SX_LOCK_SHARED (line 689) | pub const SX_LOCK_SHARED: u32 = 1;
  constant SX_LOCK_SHARED_WAITERS (line 690) | pub const SX_LOCK_SHARED_WAITERS: u32 = 2;
  constant SX_LOCK_EXCLUSIVE_WAITERS (line 691) | pub const SX_LOCK_EXCLUSIVE_WAITERS: u32 = 4;
  constant SX_LOCK_WRITE_SPINNER (line 692) | pub const SX_LOCK_WRITE_SPINNER: u32 = 8;
  constant SX_LOCK_RECURSED (line 693) | pub const SX_LOCK_RECURSED: u32 = 16;
  constant SX_LOCK_FLAGMASK (line 694) | pub const SX_LOCK_FLAGMASK: u32 = 31;
  constant SX_LOCK_WAITERS (line 695) | pub const SX_LOCK_WAITERS: u32 = 6;
  constant SX_SHARERS_SHIFT (line 696) | pub const SX_SHARERS_SHIFT: u32 = 5;
  constant SX_ONE_SHARER (line 697) | pub const SX_ONE_SHARER: u32 = 32;
  constant SX_LOCK_DESTROYED (line 698) | pub const SX_LOCK_DESTROYED: u32 = 6;
  constant SPLAY_NEGINF (line 699) | pub const SPLAY_NEGINF: i32 = -1;
  constant SPLAY_INF (line 700) | pub const SPLAY_INF: u32 = 1;
  constant RB_STRICT_HST (line 701) | pub const RB_STRICT_HST: u32 = 0;
  constant RB_NEGINF (line 702) | pub const RB_NEGINF: i32 = -1;
  constant RB_INF (line 703) | pub const RB_INF: u32 = 1;
  constant UMA_SMALLEST_UNIT (line 704) | pub const UMA_SMALLEST_UNIT: u32 = 8;
  constant UMA_ZONE_UNMANAGED (line 705) | pub const UMA_ZONE_UNMANAGED: u32 = 1;
  constant UMA_ZONE_ZINIT (line 706) | pub const UMA_ZONE_ZINIT: u32 = 2;
  constant UMA_ZONE_CONTIG (line 707) | pub const UMA_ZONE_CONTIG: u32 = 4;
  constant UMA_ZONE_NOTOUCH (line 708) | pub const UMA_ZONE_NOTOUCH: u32 = 8;
  constant UMA_ZONE_MALLOC (line 709) | pub const UMA_ZONE_MALLOC: u32 = 16;
  constant UMA_ZONE_NOFREE (line 710) | pub const UMA_ZONE_NOFREE: u32 = 32;
  constant UMA_ZONE_MTXCLASS (line 711) | pub const UMA_ZONE_MTXCLASS: u32 = 64;
  constant UMA_ZONE_VM (line 712) | pub const UMA_ZONE_VM: u32 = 128;
  constant UMA_ZONE_NOTPAGE (line 713) | pub const UMA_ZONE_NOTPAGE: u32 = 256;
  constant UMA_ZONE_SECONDARY (line 714) | pub const UMA_ZONE_SECONDARY: u32 = 512;
  constant UMA_ZONE_NOBUCKET (line 715) | pub const UMA_ZONE_NOBUCKET: u32 = 1024;
  constant UMA_ZONE_MAXBUCKET (line 716) | pub const UMA_ZONE_MAXBUCKET: u32 = 2048;
  constant UMA_ZONE_CACHESPREAD (line 717) | pub const UMA_ZONE_CACHESPREAD: u32 = 8192;
  constant UMA_ZONE_NODUMP (line 718) | pub const UMA_ZONE_NODUMP: u32 = 16384;
  constant UMA_ZONE_PCPU (line 719) | pub const UMA_ZONE_PCPU: u32 = 32768;
  constant UMA_ZONE_FIRSTTOUCH (line 720) | pub const UMA_ZONE_FIRSTTOUCH: u32 = 65536;
  constant UMA_ZONE_ROUNDROBIN (line 721) | pub const UMA_ZONE_ROUNDROBIN: u32 = 131072;
  constant UMA_ZONE_SMR (line 722) | pub const UMA_ZONE_SMR: u32 = 262144;
  constant UMA_ZONE_NOKASAN (line 723) | pub const UMA_ZONE_NOKASAN: u32 = 524288;
  constant UMA_ZONE_INHERIT (line 724) | pub const UMA_ZONE_INHERIT: u32 = 754104;
  constant UMA_ALIGN_CACHE (line 725) | pub const UMA_ALIGN_CACHE: i32 = -1;
  constant UMA_ANYDOMAIN (line 726) | pub const UMA_ANYDOMAIN: i32 = -1;
  constant UMA_RECLAIM_DRAIN (line 727) | pub const UMA_RECLAIM_DRAIN: u32 = 1;
  constant UMA_RECLAIM_DRAIN_CPU (line 728) | pub const UMA_RECLAIM_DRAIN_CPU: u32 = 2;
  constant UMA_RECLAIM_TRIM (line 729) | pub const UMA_RECLAIM_TRIM: u32 = 3;
  constant UMA_SLAB_BOOT (line 730) | pub const UMA_SLAB_BOOT: u32 = 1;
  constant UMA_SLAB_KERNEL (line 731) | pub const UMA_SLAB_KERNEL: u32 = 4;
  constant UMA_SLAB_PRIV (line 732) | pub const UMA_SLAB_PRIV: u32 = 8;
  constant UMA_STREAM_VERSION (line 733) | pub const UMA_STREAM_VERSION: u32 = 1;
  constant UTH_MAX_NAME (line 734) | pub const UTH_MAX_NAME: u32 = 32;
  constant UTH_ZONE_SECONDARY (line 735) | pub const UTH_ZONE_SECONDARY: u32 = 1;
  constant CLOCK_REALTIME (line 736) | pub const CLOCK_REALTIME: u32 = 0;
  constant CLOCK_VIRTUAL (line 737) | pub const CLOCK_VIRTUAL: u32 = 1;
  constant CLOCK_PROF (line 738) | pub const CLOCK_PROF: u32 = 2;
  constant CLOCK_MONOTONIC (line 739) | pub const CLOCK_MONOTONIC: u32 = 4;
  constant CLOCK_UPTIME_FAST (line 740) | pub const CLOCK_UPTIME_FAST: u32 = 8;
  constant CLOCK_UPTIME (line 741) | pub const CLOCK_UPTIME: u32 = 5;
  constant CLOCK_UPTIME_PRECISE (line 742) | pub const CLOCK_UPTIME_PRECISE: u32 = 7;
  constant CLOCK_REALTIME_PRECISE (line 743) | pub const CLOCK_REALTIME_PRECISE: u32 = 9;
  constant CLOCK_REALTIME_FAST (line 744) | pub const CLOCK_REALTIME_FAST: u32 = 10;
  constant CLOCK_MONOTONIC_PRECISE (line 745) | pub const CLOCK_MONOTONIC_PRECISE: u32 = 11;
  constant CLOCK_MONOTONIC_FAST (line 746) | pub const CLOCK_MONOTONIC_FAST: u32 = 12;
  constant CLOCK_SECOND (line 747) | pub const CLOCK_SECOND: u32 = 13;
  constant CLOCK_THREAD_CPUTIME_ID (line 748) | pub const CLOCK_THREAD_CPUTIME_ID: u32 = 14;
  constant CLOCK_PROCESS_CPUTIME_ID (line 749) | pub const CLOCK_PROCESS_CPUTIME_ID: u32 = 15;
  constant CLOCK_BOOTTIME (line 750) | pub const CLOCK_BOOTTIME: u32 = 5;
  constant CLOCK_REALTIME_COARSE (line 751) | pub const CLOCK_REALTIME_COARSE: u32 = 10;
  constant CLOCK_MONOTONIC_COARSE (line 752) | pub const CLOCK_MONOTONIC_COARSE: u32 = 12;
  constant TIMER_RELTIME (line 753) | pub const TIMER_RELTIME: u32 = 0;
  constant TIMER_ABSTIME (line 754) | pub const TIMER_ABSTIME: u32 = 1;
  constant DST_NONE (line 755) | pub const DST_NONE: u32 = 0;
  constant DST_USA (line 756) | pub const DST_USA: u32 = 1;
  constant DST_AUST (line 757) | pub const DST_AUST: u32 = 2;
  constant DST_WET (line 758) | pub const DST_WET: u32 = 3;
  constant DST_MET (line 759) | pub const DST_MET: u32 = 4;
  constant DST_EET (line 760) | pub const DST_EET: u32 = 5;
  constant DST_CAN (line 761) | pub const DST_CAN: u32 = 6;
  constant SBT_MAX (line 762) | pub const SBT_MAX: u64 = 9223372036854775807;
  constant ITIMER_REAL (line 763) | pub const ITIMER_REAL: u32 = 0;
  constant ITIMER_VIRTUAL (line 764) | pub const ITIMER_VIRTUAL: u32 = 1;
  constant ITIMER_PROF (line 765) | pub const ITIMER_PROF: u32 = 2;
  constant CPUCLOCK_WHICH_PID (line 766) | pub const CPUCLOCK_WHICH_PID: u32 = 0;
  constant CPUCLOCK_WHICH_TID (line 767) | pub const CPUCLOCK_WHICH_TID: u32 = 1;
  constant CLK_TCK (line 768) | pub const CLK_TCK: u32 = 128;
  constant CLOCKS_PER_SEC (line 769) | pub const CLOCKS_PER_SEC: u32 = 128;
  constant TIME_UTC (line 770) | pub const TIME_UTC: u32 = 1;
  constant TIME_MONOTONIC (line 771) | pub const TIME_MONOTONIC: u32 = 2;
  constant SOCK_STREAM (line 772) | pub const SOCK_STREAM: u32 = 1;
  constant SOCK_DGRAM (line 773) | pub const SOCK_DGRAM: u32 = 2;
  constant SOCK_RAW (line 774) | pub const SOCK_RAW: u32 = 3;
  constant SOCK_RDM (line 775) | pub const SOCK_RDM: u32 = 4;
  constant SOCK_SEQPACKET (line 776) | pub const SOCK_SEQPACKET: u32 = 5;
  constant SOCK_CLOEXEC (line 777) | pub const SOCK_CLOEXEC: u32 = 268435456;
  constant SOCK_NONBLOCK (line 778) | pub const SOCK_NONBLOCK: u32 = 536870912;
  constant SO_DEBUG (line 779) | pub const SO_DEBUG: u32 = 1;
  constant SO_ACCEPTCONN (line 780) | pub const SO_ACCEPTCONN: u32 = 2;
  constant SO_REUSEADDR (line 781) | pub const SO_REUSEADDR: u32 = 4;
  constant SO_KEEPALIVE (line 782) | pub const SO_KEEPALIVE: u32 = 8;
  constant SO_DONTROUTE (line 783) | pub const SO_DONTROUTE: u32 = 16;
  constant SO_BROADCAST (line 784) | pub const SO_BROADCAST: u32 = 32;
  constant SO_USELOOPBACK (line 785) | pub const SO_USELOOPBACK: u32 = 64;
  constant SO_LINGER (line 786) | pub const SO_LINGER: u32 = 128;
  constant SO_OOBINLINE (line 787) | pub const SO_OOBINLINE: u32 = 256;
  constant SO_REUSEPORT (line 788) | pub const SO_REUSEPORT: u32 = 512;
  constant SO_TIMESTAMP (line 789) | pub const SO_TIMESTAMP: u32 = 1024;
  constant SO_NOSIGPIPE (line 790) | pub const SO_NOSIGPIPE: u32 = 2048;
  constant SO_ACCEPTFILTER (line 791) | pub const SO_ACCEPTFILTER: u32 = 4096;
  constant SO_BINTIME (line 792) | pub const SO_BINTIME: u32 = 8192;
  constant SO_NO_OFFLOAD (line 793) | pub const SO_NO_OFFLOAD: u32 = 16384;
  constant SO_NO_DDP (line 794) | pub const SO_NO_DDP: u32 = 32768;
  constant SO_REUSEPORT_LB (line 795) | pub const SO_REUSEPORT_LB: u32 = 65536;
  constant SO_RERROR (line 796) | pub const SO_RERROR: u32 = 131072;
  constant SO_SNDBUF (line 797) | pub const SO_SNDBUF: u32 = 4097;
  constant SO_RCVBUF (line 798) | pub const SO_RCVBUF: u32 = 4098;
  constant SO_SNDLOWAT (line 799) | pub const SO_SNDLOWAT: u32 = 4099;
  constant SO_RCVLOWAT (line 800) | pub const SO_RCVLOWAT: u32 = 4100;
  constant SO_SNDTIMEO (line 801) | pub const SO_SNDTIMEO: u32 = 4101;
  constant SO_RCVTIMEO (line 802) | pub const SO_RCVTIMEO: u32 = 4102;
  constant SO_ERROR (line 803) | pub const SO_ERROR: u32 = 4103;
  constant SO_TYPE (line 804) | pub const SO_TYPE: u32 = 4104;
  constant SO_LABEL (line 805) | pub const SO_LABEL: u32 = 4105;
  constant SO_PEERLABEL (line 806) | pub const SO_PEERLABEL: u32 = 4112;
  constant SO_LISTENQLIMIT (line 807) | pub const SO_LISTENQLIMIT: u32 = 4113;
  constant SO_LISTENQLEN (line 808) | pub const SO_LISTENQLEN: u32 = 4114;
  constant SO_LISTENINCQLEN (line 809) | pub const SO_LISTENINCQLEN: u32 = 4115;
  constant SO_SETFIB (line 810) | pub const SO_SETFIB: u32 = 4116;
  constant SO_USER_COOKIE (line 811) | pub const SO_USER_COOKIE: u32 = 4117;
  constant SO_PROTOCOL (line 812) | pub const SO_PROTOCOL: u32 = 4118;
  constant SO_PROTOTYPE (line 813) | pub const SO_PROTOTYPE: u32 = 4118;
  constant SO_TS_CLOCK (line 814) | pub const SO_TS_CLOCK: u32 = 4119;
  constant SO_MAX_PACING_RATE (line 815) | pub const SO_MAX_PACING_RATE: u32 = 4120;
  constant SO_DOMAIN (line 816) | pub const SO_DOMAIN: u32 = 4121;
  constant SO_TS_REALTIME_MICRO (line 817) | pub const SO_TS_REALTIME_MICRO: u32 = 0;
  constant SO_TS_BINTIME (line 818) | pub const SO_TS_BINTIME: u32 = 1;
  constant SO_TS_REALTIME (line 819) | pub const SO_TS_REALTIME: u32 = 2;
  constant SO_TS_MONOTONIC (line 820) | pub const SO_TS_MONOTONIC: u32 = 3;
  constant SO_TS_DEFAULT (line 821) | pub const SO_TS_DEFAULT: u32 = 0;
  constant SO_TS_CLOCK_MAX (line 822) | pub const SO_TS_CLOCK_MAX: u32 = 3;
  constant SO_VENDOR (line 823) | pub const SO_VENDOR: u32 = 2147483648;
  constant SOL_SOCKET (line 824) | pub const SOL_SOCKET: u32 = 65535;
  constant AF_UNSPEC (line 825) | pub const AF_UNSPEC: u32 = 0;
  constant AF_UNIX (line 826) | pub const AF_UNIX: u32 = 1;
  constant AF_INET (line 827) | pub const AF_INET: u32 = 2;
  constant AF_IMPLINK (line 828) | pub const AF_IMPLINK: u32 = 3;
  constant AF_PUP (line 829) | pub const AF_PUP: u32 = 4;
  constant AF_CHAOS (line 830) | pub const AF_CHAOS: u32 = 5;
  constant AF_NETBIOS (line 831) | pub const AF_NETBIOS: u32 = 6;
  constant AF_ISO (line 832) | pub const AF_ISO: u32 = 7;
  constant AF_OSI (line 833) | pub const AF_OSI: u32 = 7;
  constant AF_ECMA (line 834) | pub const AF_ECMA: u32 = 8;
  constant AF_DATAKIT (line 835) | pub const AF_DATAKIT: u32 = 9;
  constant AF_CCITT (line 836) | pub const AF_CCITT: u32 = 10;
  constant AF_SNA (line 837) | pub const AF_SNA: u32 = 11;
  constant AF_DECnet (line 838) | pub const AF_DECnet: u32 = 12;
  constant AF_DLI (line 839) | pub const AF_DLI: u32 = 13;
  constant AF_LAT (line 840) | pub const AF_LAT: u32 = 14;
  constant AF_HYLINK (line 841) | pub const AF_HYLINK: u32 = 15;
  constant AF_APPLETALK (line 842) | pub const AF_APPLETALK: u32 = 16;
  constant AF_ROUTE (line 843) | pub const AF_ROUTE: u32 = 17;
  constant AF_LINK (line 844) | pub const AF_LINK: u32 = 18;
  constant pseudo_AF_XTP (line 845) | pub const pseudo_AF_XTP: u32 = 19;
  constant AF_COIP (line 846) | pub const AF_COIP: u32 = 20;
  constant AF_CNT (line 847) | pub const AF_CNT: u32 = 21;
  constant pseudo_AF_RTIP (line 848) | pub const pseudo_AF_RTIP: u32 = 22;
  constant AF_IPX (line 849) | pub const AF_IPX: u32 = 23;
  constant AF_SIP (line 850) | pub const AF_SIP: u32 = 24;
  constant pseudo_AF_PIP (line 851) | pub const pseudo_AF_PIP: u32 = 25;
  constant AF_ISDN (line 852) | pub const AF_ISDN: u32 = 26;
  constant AF_E164 (line 853) | pub const AF_E164: u32 = 26;
  constant pseudo_AF_KEY (line 854) | pub const pseudo_AF_KEY: u32 = 27;
  constant AF_INET6 (line 855) | pub const AF_INET6: u32 = 28;
  constant AF_NATM (line 856) | pub const AF_NATM: u32 = 29;
  constant AF_ATM (line 857) | pub const AF_ATM: u32 = 30;
  constant pseudo_AF_HDRCMPLT (line 858) | pub const pseudo_AF_HDRCMPLT: u32 = 31;
  constant AF_NETGRAPH (line 859) | pub const AF_NETGRAPH: u32 = 32;
  constant AF_SLOW (line 860) | pub const AF_SLOW: u32 = 33;
  constant AF_SCLUSTER (line 861) | pub const AF_SCLUSTER: u32 = 34;
  constant AF_ARP (line 862) | pub const AF_ARP: u32 = 35;
  constant AF_BLUETOOTH (line 863) | pub const AF_BLUETOOTH: u32 = 36;
  constant AF_IEEE80211 (line 864) | pub const AF_IEEE80211: u32 = 37;
  constant AF_NETLINK (line 865) | pub const AF_NETLINK: u32 = 38;
  constant AF_INET_SDP (line 866) | pub const AF_INET_SDP: u32 = 40;
  constant AF_INET6_SDP (line 867) | pub const AF_INET6_SDP: u32 = 42;
  constant AF_HYPERV (line 868) | pub const AF_HYPERV: u32 = 43;
  constant AF_DIVERT (line 869) | pub const AF_DIVERT: u32 = 44;
  constant AF_MAX (line 870) | pub const AF_MAX: u32 = 44;
  constant AF_VENDOR00 (line 871) | pub const AF_VENDOR00: u32 = 39;
  constant AF_VENDOR01 (line 872) | pub const AF_VENDOR01: u32 = 41;
  constant AF_VENDOR03 (line 873) | pub const AF_VENDOR03: u32 = 45;
  constant AF_VENDOR04 (line 874) | pub const AF_VENDOR04: u32 = 47;
  constant AF_VENDOR05 (line 875) | pub const AF_VENDOR05: u32 = 49;
  constant AF_VENDOR06 (line 876) | pub const AF_VENDOR06: u32 = 51;
  constant AF_VENDOR07 (line 877) | pub const AF_VENDOR07: u32 = 53;
  constant AF_VENDOR08 (line 878) | pub const AF_VENDOR08: u32 = 55;
  constant AF_VENDOR09 (line 879) | pub const AF_VENDOR09: u32 = 57;
  constant AF_VENDOR10 (line 880) | pub const AF_VENDOR10: u32 = 59;
  constant AF_VENDOR11 (line 881) | pub const AF_VENDOR11: u32 = 61;
  constant AF_VENDOR12 (line 882) | pub const AF_VENDOR12: u32 = 63;
  constant AF_VENDOR13 (line 883) | pub const AF_VENDOR13: u32 = 65;
  constant AF_VENDOR14 (line 884) | pub const AF_VENDOR14: u32 = 67;
  constant AF_VENDOR15 (line 885) | pub const AF_VENDOR15: u32 = 69;
  constant AF_VENDOR16 (line 886) | pub const AF_VENDOR16: u32 = 71;
  constant AF_VENDOR17 (line 887) | pub const AF_VENDOR17: u32 = 73;
  constant AF_VENDOR18 (line 888) | pub const AF_VENDOR18: u32 = 75;
  constant AF_VENDOR19 (line 889) | pub const AF_VENDOR19: u32 = 77;
  constant AF_VENDOR20 (line 890) | pub const AF_VENDOR20: u32 = 79;
  constant AF_VENDOR21 (line 891) | pub const AF_VENDOR21: u32 = 81;
  constant AF_VENDOR22 (line 892) | pub const AF_VENDOR22: u32 = 83;
  constant AF_VENDOR23 (line 893) | pub const AF_VENDOR23: u32 = 85;
  constant AF_VENDOR24 (line 894) | pub const AF_VENDOR24: u32 = 87;
  constant AF_VENDOR25 (line 895) | pub const AF_VENDOR25: u32 = 89;
  constant AF_VENDOR26 (line 896) | pub const AF_VENDOR26: u32 = 91;
  constant AF_VENDOR27 (line 897) | pub const AF_VENDOR27: u32 = 93;
  constant AF_VENDOR28 (line 898) | pub const AF_VENDOR28: u32 = 95;
  constant AF_VENDOR29 (line 899) | pub const AF_VENDOR29: u32 = 97;
  constant AF_VENDOR30 (line 900) | pub const AF_VENDOR30: u32 = 99;
  constant AF_VENDOR31 (line 901) | pub const AF_VENDOR31: u32 = 101;
  constant AF_VENDOR32 (line 902) | pub const AF_VENDOR32: u32 = 103;
  constant AF_VENDOR33 (line 903) | pub const AF_VENDOR33: u32 = 105;
  constant AF_VENDOR34 (line 904) | pub const AF_VENDOR34: u32 = 107;
  constant AF_VENDOR35 (line 905) | pub const AF_VENDOR35: u32 = 109;
  constant AF_VENDOR36 (line 906) | pub const AF_VENDOR36: u32 = 111;
  constant AF_VENDOR37 (line 907) | pub const AF_VENDOR37: u32 = 113;
  constant AF_VENDOR38 (line 908) | pub const AF_VENDOR38: u32 = 115;
  constant AF_VENDOR39 (line 909) | pub const AF_VENDOR39: u32 = 117;
  constant AF_VENDOR40 (line 910) | pub const AF_VENDOR40: u32 = 119;
  constant AF_VENDOR41 (line 911) | pub const AF_VENDOR41: u32 = 121;
  constant AF_VENDOR42 (line 912) | pub const AF_VENDOR42: u32 = 123;
  constant AF_VENDOR43 (line 913) | pub const AF_VENDOR43: u32 = 125;
  constant AF_VENDOR44 (line 914) | pub const AF_VENDOR44: u32 = 127;
  constant AF_VENDOR45 (line 915) | pub const AF_VENDOR45: u32 = 129;
  constant AF_VENDOR46 (line 916) | pub const AF_VENDOR46: u32 = 131;
  constant AF_VENDOR47 (line 917) | pub const AF_VENDOR47: u32 = 133;
  constant SOCK_MAXADDRLEN (line 918) | pub const SOCK_MAXADDRLEN: u32 = 255;
  constant _SS_MAXSIZE (line 919) | pub const _SS_MAXSIZE: u32 = 128;
  constant PF_UNSPEC (line 920) | pub const PF_UNSPEC: u32 = 0;
  constant PF_INET (line 921) | pub const PF_INET: u32 = 2;
  constant PF_IMPLINK (line 922) | pub const PF_IMPLINK: u32 = 3;
  constant PF_PUP (line 923) | pub const PF_PUP: u32 = 4;
  constant PF_CHAOS (line 924) | pub const PF_CHAOS: u32 = 5;
  constant PF_NETBIOS (line 925) | pub const PF_NETBIOS: u32 = 6;
  constant PF_ISO (line 926) | pub const PF_ISO: u32 = 7;
  constant PF_OSI (line 927) | pub const PF_OSI: u32 = 7;
  constant PF_ECMA (line 928) | pub const PF_ECMA: u32 = 8;
  constant PF_DATAKIT (line 929) | pub const PF_DATAKIT: u32 = 9;
  constant PF_CCITT (line 930) | pub const PF_CCITT: u32 = 10;
  constant PF_SNA (line 931) | pub const PF_SNA: u32 = 11;
  constant PF_DECnet (line 932) | pub const PF_DECnet: u32 = 12;
  constant PF_DLI (line 933) | pub const PF_DLI: u32 = 13;
  constant PF_LAT (line 934) | pub const PF_LAT: u32 = 14;
  constant PF_HYLINK (line 935) | pub const PF_HYLINK: u32 = 15;
  constant PF_APPLETALK (line 936) | pub const PF_APPLETALK: u32 = 16;
  constant PF_ROUTE (line 937) | pub const PF_ROUTE: u32 = 17;
  constant PF_LINK (line 938) | pub const PF_LINK: u32 = 18;
  constant PF_XTP (line 939) | pub const PF_XTP: u32 = 19;
  constant PF_COIP (line 940) | pub const PF_COIP: u32 = 20;
  constant PF_CNT (line 941) | pub const PF_CNT: u32 = 21;
  constant PF_SIP (line 942) | pub const PF_SIP: u32 = 24;
  constant PF_IPX (line 943) | pub const PF_IPX: u32 = 23;
  constant PF_RTIP (line 944) | pub const PF_RTIP: u32 = 22;
  constant PF_PIP (line 945) | pub const PF_PIP: u32 = 25;
  constant PF_ISDN (line 946) | pub const PF_ISDN: u32 = 26;
  constant PF_KEY (line 947) | pub const PF_KEY: u32 = 27;
  constant PF_INET6 (line 948) | pub const PF_INET6: u32 = 28;
  constant PF_NATM (line 949) | pub const PF_NATM: u32 = 29;
  constant PF_ATM (line 950) | pub const PF_ATM: u32 = 30;
  constant PF_NETGRAPH (line 951) | pub const PF_NETGRAPH: u32 = 32;
  constant PF_SLOW (line 952) | pub const PF_SLOW: u32 = 33;
  constant PF_SCLUSTER (line 953) | pub const PF_SCLUSTER: u32 = 34;
  constant PF_ARP (line 954) | pub const PF_ARP: u32 = 35;
  constant PF_BLUETOOTH (line 955) | pub const PF_BLUETOOTH: u32 = 36;
  constant PF_IEEE80211 (line 956) | pub const PF_IEEE80211: u32 = 37;
  constant PF_NETLINK (line 957) | pub const PF_NETLINK: u32 = 38;
  constant PF_INET_SDP (line 958) | pub const PF_INET_SDP: u32 = 40;
  constant PF_INET6_SDP (line 959) | pub const PF_INET6_SDP: u32 = 42;
  constant PF_DIVERT (line 960) | pub const PF_DIVERT: u32 = 44;
  constant PF_MAX (line 961) | pub const PF_MAX: u32 = 44;
  constant NET_RT_DUMP (line 962) | pub const NET_RT_DUMP: u32 = 1;
  constant NET_RT_FLAGS (line 963) | pub const NET_RT_FLAGS: u32 = 2;
  constant NET_RT_IFLIST (line 964) | pub const NET_RT_IFLIST: u32 = 3;
  constant NET_RT_IFMALIST (line 965) | pub const NET_RT_IFMALIST: u32 = 4;
  constant NET_RT_IFLISTL (line 966) | pub const NET_RT_IFLISTL: u32 = 5;
  constant NET_RT_NHOP (line 967) | pub const NET_RT_NHOP: u32 = 6;
  constant NET_RT_NHGRP (line 968) | pub const NET_RT_NHGRP: u32 = 7;
  constant SOMAXCONN (line 969) | pub const SOMAXCONN: u32 = 128;
  constant MSG_OOB (line 970) | pub const MSG_OOB: u32 = 1;
  constant MSG_PEEK (line 971) | pub const MSG_PEEK: u32 = 2;
  constant MSG_DONTROUTE (line 972) | pub const MSG_DONTROUTE: u32 = 4;
  constant MSG_EOR (line 973) | pub const MSG_EOR: u32 = 8;
  constant MSG_TRUNC (line 974) | pub const MSG_TRUNC: u32 = 16;
  constant MSG_CTRUNC (line 975) | pub const MSG_CTRUNC: u32 = 32;
  constant MSG_WAITALL (line 976) | pub const MSG_WAITALL: u32 = 64;
  constant MSG_DONTWAIT (line 977) | pub const MSG_DONTWAIT: u32 = 128;
  constant MSG_EOF (line 978) | pub const MSG_EOF: u32 = 256;
  constant MSG_NOTIFICATION (line 979) | pub const MSG_NOTIFICATION: u32 = 8192;
  constant MSG_NBIO (line 980) | pub const MSG_NBIO: u32 = 16384;
  constant MSG_COMPAT (line 981) | pub const MSG_COMPAT: u32 = 32768;
  constant MSG_NOSIGNAL (line 982) | pub const MSG_NOSIGNAL: u32 = 131072;
  constant MSG_CMSG_CLOEXEC (line 983) | pub const MSG_CMSG_CLOEXEC: u32 = 262144;
  constant MSG_WAITFORONE (line 984) | pub const MSG_WAITFORONE: u32 = 524288;
  constant CMGROUP_MAX (line 985) | pub const CMGROUP_MAX: u32 = 16;
  constant SCM_RIGHTS (line 986) | pub const SCM_RIGHTS: u32 = 1;
  constant SCM_TIMESTAMP (line 987) | pub const SCM_TIMESTAMP: u32 = 2;
  constant SCM_CREDS (line 988) | pub const SCM_CREDS: u32 = 3;
  constant SCM_BINTIME (line 989) | pub const SCM_BINTIME: u32 = 4;
  constant SCM_REALTIME (line 990) | pub const SCM_REALTIME: u32 = 5;
  constant SCM_MONOTONIC (line 991) | pub const SCM_MONOTONIC: u32 = 6;
  constant SCM_TIME_INFO (line 992) | pub const SCM_TIME_INFO: u32 = 7;
  constant SCM_CREDS2 (line 993) | pub const SCM_CREDS2: u32 = 8;
  constant ST_INFO_HW (line 994) | pub const ST_INFO_HW: u32 = 1;
  constant ST_INFO_HW_HPREC (line 995) | pub const ST_INFO_HW_HPREC: u32 = 2;
  constant SHUT_RD (line 996) | pub const SHUT_RD: u32 = 0;
  constant SHUT_WR (line 997) | pub const SHUT_WR: u32 = 1;
  constant SHUT_RDWR (line 998) | pub const SHUT_RDWR: u32 = 2;
  constant PRU_FLUSH_RD (line 999) | pub const PRU_FLUSH_RD: u32 = 0;
  constant PRU_FLUSH_WR (line 1000) | pub const PRU_FLUSH_WR: u32 = 1;
  constant PRU_FLUSH_RDWR (line 1001) | pub const PRU_FLUSH_RDWR: u32 = 2;
  constant SF_NODISKIO (line 1002) | pub const SF_NODISKIO: u32 = 1;
  constant SF_MNOWAIT (line 1003) | pub const SF_MNOWAIT: u32 = 2;
  constant SF_SYNC (line 1004) | pub const SF_SYNC: u32 = 4;
  constant SF_USER_READAHEAD (line 1005) | pub const SF_USER_READAHEAD: u32 = 8;
  constant SF_NOCACHE (line 1006) | pub const SF_NOCACHE: u32 = 16;
  constant IF_NAMESIZE (line 1007) | pub const IF_NAMESIZE: u32 = 16;
  constant IFNAMSIZ (line 1008) | pub const IFNAMSIZ: u32 = 16;
  constant IF_MAXUNIT (line 1009) | pub const IF_MAXUNIT: u32 = 32767;
  constant IFF_UP (line 1010) | pub const IFF_UP: u32 = 1;
  constant IFF_BROADCAST (line 1011) | pub const IFF_BROADCAST: u32 = 2;
  constant IFF_DEBUG (line 1012) | pub const IFF_DEBUG: u32 = 4;
  constant IFF_LOOPBACK (line 1013) | pub const IFF_LOOPBACK: u32 = 8;
  constant IFF_POINTOPOINT (line 1014) | pub const IFF_POINTOPOINT: u32 = 16;
  constant IFF_NEEDSEPOCH (line 1015) | pub const IFF_NEEDSEPOCH: u32 = 32;
  constant IFF_DRV_RUNNING (line 1016) | pub const IFF_DRV_RUNNING: u32 = 64;
  constant IFF_NOARP (line 1017) | pub const IFF_NOARP: u32 = 128;
  constant IFF_PROMISC (line 1018) | pub const IFF_PROMISC: u32 = 256;
  constant IFF_ALLMULTI (line 1019) | pub const IFF_ALLMULTI: u32 = 512;
  constant IFF_DRV_OACTIVE (line 1020) | pub const IFF_DRV_OACTIVE: u32 = 1024;
  constant IFF_SIMPLEX (line 1021) | pub const IFF_SIMPLEX: u32 = 2048;
  constant IFF_LINK0 (line 1022) | pub const IFF_LINK0: u32 = 4096;
  constant IFF_LINK1 (line 1023) | pub const IFF_LINK1: u32 = 8192;
  constant IFF_LINK2 (line 1024) | pub const IFF_LINK2: u32 = 16384;
  constant IFF_ALTPHYS (line 1025) | pub const IFF_ALTPHYS: u32 = 16384;
  constant IFF_MULTICAST (line 1026) | pub const IFF_MULTICAST: u32 = 32768;
  constant IFF_CANTCONFIG (line 1027) | pub const IFF_CANTCONFIG: u32 = 65536;
  constant IFF_PPROMISC (line 1028) | pub const IFF_PPROMISC: u32 = 131072;
  constant IFF_MONITOR (line 1029) | pub const IFF_MONITOR: u32 = 262144;
  constant IFF_STATICARP (line 1030) | pub const IFF_STATICARP: u32 = 524288;
  constant IFF_STICKYARP (line 1031) | pub const IFF_STICKYARP: u32 = 1048576;
  constant IFF_DYING (line 1032) | pub const IFF_DYING: u32 = 2097152;
  constant IFF_RENAMING (line 1033) | pub const IFF_RENAMING: u32 = 4194304;
  constant IFF_SPARE (line 1034) | pub const IFF_SPARE: u32 = 8388608;
  constant IFF_NETLINK_1 (line 1035) | pub const IFF_NETLINK_1: u32 = 16777216;
  constant IFF_RUNNING (line 1036) | pub const IFF_RUNNING: u32 = 64;
  constant IFF_OACTIVE (line 1037) | pub const IFF_OACTIVE: u32 = 1024;
  constant IFF_CANTCHANGE (line 1038) | pub const IFF_CANTCHANGE: u32 = 2199410;
  constant LINK_STATE_UNKNOWN (line 1039) | pub const LINK_STATE_UNKNOWN: u32 = 0;
  constant LINK_STATE_DOWN (line 1040) | pub const LINK_STATE_DOWN: u32 = 1;
  constant LINK_STATE_UP (line 1041) | pub const LINK_STATE_UP: u32 = 2;
  constant IFCAP_B_RXCSUM (line 1042) | pub const IFCAP_B_RXCSUM: u32 = 0;
  constant IFCAP_B_TXCSUM (line 1043) | pub const IFCAP_B_TXCSUM: u32 = 1;
  constant IFCAP_B_NETCONS (line 1044) | pub const IFCAP_B_NETCONS: u32 = 2;
  constant IFCAP_B_VLAN_MTU (line 1045) | pub const IFCAP_B_VLAN_MTU: u32 = 3;
  constant IFCAP_B_VLAN_HWTAGGING (line 1046) | pub const IFCAP_B_VLAN_HWTAGGING: u32 = 4;
  constant IFCAP_B_JUMBO_MTU (line 1047) | pub const IFCAP_B_JUMBO_MTU: u32 = 5;
  constant IFCAP_B_POLLING (line 1048) | pub const IFCAP_B_POLLING: u32 = 6;
  constant IFCAP_B_VLAN_HWCSUM (line 1049) | pub const IFCAP_B_VLAN_HWCSUM: u32 = 7;
  constant IFCAP_B_TSO4 (line 1050) | pub const IFCAP_B_TSO4: u32 = 8;
  constant IFCAP_B_TSO6 (line 1051) | pub const IFCAP_B_TSO6: u32 = 9;
  constant IFCAP_B_LRO (line 1052) | pub const IFCAP_B_LRO: u32 = 10;
  constant IFCAP_B_WOL_UCAST (line 1053) | pub const IFCAP_B_WOL_UCAST: u32 = 11;
  constant IFCAP_B_WOL_MCAST (line 1054) | pub const IFCAP_B_WOL_MCAST: u32 = 12;
  constant IFCAP_B_WOL_MAGIC (line 1055) | pub const IFCAP_B_WOL_MAGIC: u32 = 13;
  constant IFCAP_B_TOE4 (line 1056) | pub const IFCAP_B_TOE4: u32 = 14;
  constant IFCAP_B_TOE6 (line 1057) | pub const IFCAP_B_TOE6: u32 = 15;
  constant IFCAP_B_VLAN_HWFILTER (line 1058) | pub const IFCAP_B_VLAN_HWFILTER: u32 = 16;
  constant IFCAP_B_NV (line 1059) | pub const IFCAP_B_NV: u32 = 17;
  constant IFCAP_B_VLAN_HWTSO (line 1060) | pub const IFCAP_B_VLAN_HWTSO: u32 = 18;
  constant IFCAP_B_LINKSTATE (line 1061) | pub const IFCAP_B_LINKSTATE: u32 = 19;
  constant IFCAP_B_NETMAP (line 1062) | pub const IFCAP_B_NETMAP: u32 = 20;
  constant IFCAP_B_RXCSUM_IPV6 (line 1063) | pub const IFCAP_B_RXCSUM_IPV6: u32 = 21;
  constant IFCAP_B_TXCSUM_IPV6 (line 1064) | pub const IFCAP_B_TXCSUM_IPV6: u32 = 22;
  constant IFCAP_B_HWSTATS (line 1065) | pub const IFCAP_B_HWSTATS: u32 = 23;
  constant IFCAP_B_TXRTLMT (line 1066) | pub const IFCAP_B_TXRTLMT: u32 = 24;
  constant IFCAP_B_HWRXTSTMP (line 1067) | pub const IFCAP_B_HWRXTSTMP: u32 = 25;
  constant IFCAP_B_MEXTPG (line 1068) | pub const IFCAP_B_MEXTPG: u32 = 26;
  constant IFCAP_B_TXTLS4 (line 1069) | pub const IFCAP_B_TXTLS4: u32 = 27;
  constant IFCAP_B_TXTLS6 (line 1070) | pub const IFCAP_B_TXTLS6: u32 = 28;
  constant IFCAP_B_VXLAN_HWCSUM (line 1071) | pub const IFCAP_B_VXLAN_HWCSUM: u32 = 29;
  constant IFCAP_B_VXLAN_HWTSO (line 1072) | pub const IFCAP_B_VXLAN_HWTSO: u32 = 30;
  constant IFCAP_B_TXTLS_RTLMT (line 1073) | pub const IFCAP_B_TXTLS_RTLMT: u32 = 31;
  constant IFCAP_B_RXTLS4 (line 1074) | pub const IFCAP_B_RXTLS4: u32 = 32;
  constant IFCAP_B_RXTLS6 (line 1075) | pub const IFCAP_B_RXTLS6: u32 = 33;
  constant __IFCAP_B_SIZE (line 1076) | pub const __IFCAP_B_SIZE: u32 = 34;
  constant IFCAP_B_SIZE (line 1077) | pub const IFCAP_B_SIZE: u32 = 34;
  constant IFCAP2_RXTLS4 (line 1078) | pub const IFCAP2_RXTLS4: u32 = 0;
  constant IFCAP2_RXTLS6 (line 1079) | pub const IFCAP2_RXTLS6: u32 = 1;
  constant IFCAP_ALLCAPS (line 1080) | pub const IFCAP_ALLCAPS: u32 = 4294967295;
  constant IFQ_MAXLEN (line 1081) | pub const IFQ_MAXLEN: u32 = 50;
  constant IFNET_SLOWHZ (line 1082) | pub const IFNET_SLOWHZ: u32 = 1;
  constant IFAN_ARRIVAL (line 1083) | pub const IFAN_ARRIVAL: u32 = 0;
  constant IFAN_DEPARTURE (line 1084) | pub const IFAN_DEPARTURE: u32 = 1;
  constant IFR_CAP_NV_MAXBUFSIZE (line 1085) | pub const IFR_CAP_NV_MAXBUFSIZE: u32 = 2097152;
  constant IFSTATMAX (line 1086) | pub const IFSTATMAX: u32 = 800;
  constant IFG_ALL (line 1087) | pub const IFG_ALL: &[u8; 4] = b"all\0";
  constant IFG_EGRESS (line 1088) | pub const IFG_EGRESS: &[u8; 7] = b"egress\0";
  constant RSS_FUNC_NONE (line 1089) | pub const RSS_FUNC_NONE: u32 = 0;
  constant RSS_FUNC_PRIVATE (line 1090) | pub const RSS_FUNC_PRIVATE: u32 = 1;
  constant RSS_FUNC_TOEPLITZ (line 1091) | pub const RSS_FUNC_TOEPLITZ: u32 = 2;
  constant RSS_TYPE_IPV4 (line 1092) | pub const RSS_TYPE_IPV4: u32 = 1;
  constant RSS_TYPE_TCP_IPV4 (line 1093) | pub const RSS_TYPE_TCP_IPV4: u32 = 2;
  constant RSS_TYPE_IPV6 (line 1094) | pub const RSS_TYPE_IPV6: u32 = 4;
  constant RSS_TYPE_IPV6_EX (line 1095) | pub const RSS_TYPE_IPV6_EX: u32 = 8;
  constant RSS_TYPE_TCP_IPV6 (line 1096) | pub const RSS_TYPE_TCP_IPV6: u32 = 16;
  constant RSS_TYPE_TCP_IPV6_EX (line 1097) | pub const RSS_TYPE_TCP_IPV6_EX: u32 = 32;
  constant RSS_TYPE_UDP_IPV4 (line 1098) | pub const RSS_TYPE_UDP_IPV4: u32 = 64;
  constant RSS_TYPE_UDP_IPV6 (line 1099) | pub const RSS_TYPE_UDP_IPV6: u32 = 128;
  constant RSS_TYPE_UDP_IPV6_EX (line 1100) | pub const RSS_TYPE_UDP_IPV6_EX: u32 = 256;
  constant RSS_KEYLEN (line 1101) | pub const RSS_KEYLEN: u32 = 128;
  constant IFNET_PCP_NONE (line 1102) | pub const IFNET_PCP_NONE: u32 = 255;
  constant IFDR_MSG_SIZE (line 1103) | pub const IFDR_MSG_SIZE: u32 = 64;
  constant IFDR_REASON_MSG (line 1104) | pub const IFDR_REASON_MSG: u32 = 1;
  constant IFDR_REASON_VENDOR (line 1105) | pub const IFDR_REASON_VENDOR: u32 = 2;
  constant ETHER_ADDR_LEN (line 1106) | pub const ETHER_ADDR_LEN: u32 = 6;
  constant ETHER_TYPE_LEN (line 1107) | pub const ETHER_TYPE_LEN: u32 = 2;
  constant ETHER_CRC_LEN (line 1108) | pub const ETHER_CRC_LEN: u32 = 4;
  constant ETHER_HDR_LEN (line 1109) | pub const ETHER_HDR_LEN: u32 = 14;
  constant ETHER_MIN_LEN (line 1110) | pub const ETHER_MIN_LEN: u32 = 64;
  constant ETHER_MAX_LEN (line 1111) | pub const ETHER_MAX_LEN: u32 = 1518;
  constant ETHER_MAX_LEN_JUMBO (line 1112) | pub const ETHER_MAX_LEN_JUMBO: u32 = 9018;
  constant ETHER_VLAN_ENCAP_LEN (line 1113) | pub const ETHER_VLAN_ENCAP_LEN: u32 = 4;
  constant ETHER_ALIGN (line 1114) | pub const ETHER_ALIGN: u32 = 2;
  constant ETHER_CRC_POLY_LE (line 1115) | pub const ETHER_CRC_POLY_LE: u32 = 3988292384;
  constant ETHER_CRC_POLY_BE (line 1116) | pub const ETHER_CRC_POLY_BE: u32 = 79764918;
  constant EVL_VLID_MASK (line 1117) | pub const EVL_VLID_MASK: u32 = 4095;
  constant EVL_PRI_MASK (line 1118) | pub const EVL_PRI_MASK: u32 = 57344;
  constant ETHERTYPE_8023 (line 1119) | pub const ETHERTYPE_8023: u32 = 4;
  constant ETHERTYPE_PUP (line 1120) | pub const ETHERTYPE_PUP: u32 = 512;
  constant ETHERTYPE_PUPAT (line 1121) | pub const ETHERTYPE_PUPAT: u32 = 512;
  constant ETHERTYPE_SPRITE (line 1122) | pub const ETHERTYPE_SPRITE: u32 = 1280;
  constant ETHERTYPE_NS (line 1123) | pub const ETHERTYPE_NS: u32 = 1536;
  constant ETHERTYPE_NSAT (line 1124) | pub const ETHERTYPE_NSAT: u32 = 1537;
  constant ETHERTYPE_DLOG1 (line 1125) | pub const ETHERTYPE_DLOG1: u32 = 1632;
  constant ETHERTYPE_DLOG2 (line 1126) | pub const ETHERTYPE_DLOG2: u32 = 1633;
  constant ETHERTYPE_IP (line 1127) | pub const ETHERTYPE_IP: u32 = 2048;
  constant ETHERTYPE_X75 (line 1128) | pub const ETHERTYPE_X75: u32 = 2049;
  constant ETHERTYPE_NBS (line 1129) | pub const ETHERTYPE_NBS: u32 = 2050;
  constant ETHERTYPE_ECMA (line 1130) | pub const ETHERTYPE_ECMA: u32 = 2051;
  constant ETHERTYPE_CHAOS (line 1131) | pub const ETHERTYPE_CHAOS: u32 = 2052;
  constant ETHERTYPE_X25 (line 1132) | pub const ETHERTYPE_X25: u32 = 2053;
  constant ETHERTYPE_ARP (line 1133) | pub const ETHERTYPE_ARP: u32 = 2054;
  constant ETHERTYPE_NSCOMPAT (line 1134) | pub const ETHERTYPE_NSCOMPAT: u32 = 2055;
  constant ETHERTYPE_FRARP (line 1135) | pub const ETHERTYPE_FRARP: u32 = 2056;
  constant ETHERTYPE_UBDEBUG (line 1136) | pub const ETHERTYPE_UBDEBUG: u32 = 2304;
  constant ETHERTYPE_IEEEPUP (line 1137) | pub const ETHERTYPE_IEEEPUP: u32 = 2560;
  constant ETHERTYPE_IEEEPUPAT (line 1138) | pub const ETHERTYPE_IEEEPUPAT: u32 = 2561;
  constant ETHERTYPE_VINES (line 1139) | pub const ETHERTYPE_VINES: u32 = 2989;
  constant ETHERTYPE_VINESLOOP (line 1140) | pub const ETHERTYPE_VINESLOOP: u32 = 2990;
  constant ETHERTYPE_VINESECHO (line 1141) | pub const ETHERTYPE_VINESECHO: u32 = 2991;
  constant ETHERTYPE_TRAIL (line 1142) | pub const ETHERTYPE_TRAIL: u32 = 4096;
  constant ETHERTYPE_NTRAILER (line 1143) | pub const ETHERTYPE_NTRAILER: u32 = 16;
  constant ETHERTYPE_DCA (line 1144) | pub const ETHERTYPE_DCA: u32 = 4660;
  constant ETHERTYPE_VALID (line 1145) | pub const ETHERTYPE_VALID: u32 = 5632;
  constant ETHERTYPE_DOGFIGHT (line 1146) | pub const ETHERTYPE_DOGFIGHT: u32 = 6537;
  constant ETHERTYPE_RCL (line 1147) | pub const ETHERTYPE_RCL: u32 = 6549;
  constant ETHERTYPE_NBPVCD (line 1148) | pub const ETHERTYPE_NBPVCD: u32 = 15360;
  constant ETHERTYPE_NBPSCD (line 1149) | pub const ETHERTYPE_NBPSCD: u32 = 15361;
  constant ETHERTYPE_NBPCREQ (line 1150) | pub const ETHERTYPE_NBPCREQ: u32 = 15362;
  constant ETHERTYPE_NBPCRSP (line 1151) | pub const ETHERTYPE_NBPCRSP: u32 = 15363;
  constant ETHERTYPE_NBPCC (line 1152) | pub const ETHERTYPE_NBPCC: u32 = 15364;
  constant ETHERTYPE_NBPCLREQ (line 1153) | pub const ETHERTYPE_NBPCLREQ: u32 = 15365;
  constant ETHERTYPE_NBPCLRSP (line 1154) | pub const ETHERTYPE_NBPCLRSP: u32 = 15366;
  constant ETHERTYPE_NBPDG (line 1155) | pub const ETHERTYPE_NBPDG: u32 = 15367;
  constant ETHERTYPE_NBPDGB (line 1156) | pub const ETHERTYPE_NBPDGB: u32 = 15368;
  constant ETHERTYPE_NBPCLAIM (line 1157) | pub const ETHERTYPE_NBPCLAIM: u32 = 15369;
  constant ETHERTYPE_NBPDLTE (line 1158) | pub const ETHERTYPE_NBPDLTE: u32 = 15370;
  constant ETHERTYPE_NBPRAS (line 1159) | pub const ETHERTYPE_NBPRAS: u32 = 15371;
  constant ETHERTYPE_NBPRAR (line 1160) | pub const ETHERTYPE_NBPRAR: u32 = 15372;
  constant ETHERTYPE_NBPRST (line 1161) | pub const ETHERTYPE_NBPRST: u32 = 15373;
  constant ETHERTYPE_PCS (line 1162) | pub const ETHERTYPE_PCS: u32 = 16962;
  constant ETHERTYPE_IMLBLDIAG (line 1163) | pub const ETHERTYPE_IMLBLDIAG: u32 = 16972;
  constant ETHERTYPE_DIDDLE (line 1164) | pub const ETHERTYPE_DIDDLE: u32 = 17185;
  constant ETHERTYPE_IMLBL (line 1165) | pub const ETHERTYPE_IMLBL: u32 = 19522;
  constant ETHERTYPE_SIMNET (line 1166) | pub const ETHERTYPE_SIMNET: u32 = 21000;
  constant ETHERTYPE_DECEXPER (line 1167) | pub const ETHERTYPE_DECEXPER: u32 = 24576;
  constant ETHERTYPE_MOPDL (line 1168) | pub const ETHERTYPE_MOPDL: u32 = 24577;
  constant ETHERTYPE_MOPRC (line 1169) | pub const ETHERTYPE_MOPRC: u32 = 24578;
  constant ETHERTYPE_DECnet (line 1170) | pub const ETHERTYPE_DECnet: u32 = 24579;
  constant ETHERTYPE_DN (line 1171) | pub const ETHERTYPE_DN: u32 = 24579;
  constant ETHERTYPE_LAT (line 1172) | pub const ETHERTYPE_LAT: u32 = 24580;
  constant ETHERTYPE_DECDIAG (line 1173) | pub const ETHERTYPE_DECDIAG: u32 = 24581;
  constant ETHERTYPE_DECCUST (line 1174) | pub const ETHERTYPE_DECCUST: u32 = 24582;
  constant ETHERTYPE_SCA (line 1175) | pub const ETHERTYPE_SCA: u32 = 24583;
  constant ETHERTYPE_AMBER (line 1176) | pub const ETHERTYPE_AMBER: u32 = 24584;
  constant ETHERTYPE_DECMUMPS (line 1177) | pub const ETHERTYPE_DECMUMPS: u32 = 24585;
  constant ETHERTYPE_TRANSETHER (line 1178) | pub const ETHERTYPE_TRANSETHER: u32 = 25944;
  constant ETHERTYPE_RAWFR (line 1179) | pub const ETHERTYPE_RAWFR: u32 = 25945;
  constant ETHERTYPE_UBDL (line 1180) | pub const ETHERTYPE_UBDL: u32 = 28672;
  constant ETHERTYPE_UBNIU (line 1181) | pub const ETHERTYPE_UBNIU: u32 = 28673;
  constant ETHERTYPE_UBDIAGLOOP (line 1182) | pub const ETHERTYPE_UBDIAGLOOP: u32 = 28674;
  constant ETHERTYPE_UBNMC (line 1183) | pub const ETHERTYPE_UBNMC: u32 = 28675;
  constant ETHERTYPE_UBBST (line 1184) | pub const ETHERTYPE_UBBST: u32 = 28677;
  constant ETHERTYPE_OS9 (line 1185) | pub const ETHERTYPE_OS9: u32 = 28679;
  constant ETHERTYPE_OS9NET (line 1186) | pub const ETHERTYPE_OS9NET: u32 = 28681;
  constant ETHERTYPE_RACAL (line 1187) | pub const ETHERTYPE_RACAL: u32 = 28720;
  constant ETHERTYPE_PRIMENTS (line 1188) | pub const ETHERTYPE_PRIMENTS: u32 = 28721;
  constant ETHERTYPE_CABLETRON (line 1189) | pub const ETHERTYPE_CABLETRON: u32 = 28724;
  constant ETHERTYPE_CRONUSVLN (line 1190) | pub const ETHERTYPE_CRONUSVLN: u32 = 32771;
  constant ETHERTYPE_CRONUS (line 1191) | pub const ETHERTYPE_CRONUS: u32 = 32772;
  constant ETHERTYPE_HP (line 1192) | pub const ETHERTYPE_HP: u32 = 32773;
  constant ETHERTYPE_NESTAR (line 1193) | pub const ETHERTYPE_NESTAR: u32 = 32774;
  constant ETHERTYPE_ATTSTANFORD (line 1194) | pub const ETHERTYPE_ATTSTANFORD: u32 = 32776;
  constant ETHERTYPE_EXCELAN (line 1195) | pub const ETHERTYPE_EXCELAN: u32 = 32784;
  constant ETHERTYPE_SG_DIAG (line 1196) | pub const ETHERTYPE_SG_DIAG: u32 = 32787;
  constant ETHERTYPE_SG_NETGAMES (line 1197) | pub const ETHERTYPE_SG_NETGAMES: u32 = 32788;
  constant ETHERTYPE_SG_RESV (line 1198) | pub const ETHERTYPE_SG_RESV: u32 = 32789;
  constant ETHERTYPE_SG_BOUNCE (line 1199) | pub const ETHERTYPE_SG_BOUNCE: u32 = 32790;
  constant ETHERTYPE_APOLLODOMAIN (line 1200) | pub const ETHERTYPE_APOLLODOMAIN: u32 = 32793;
  constant ETHERTYPE_TYMSHARE (line 1201) | pub const ETHERTYPE_TYMSHARE: u32 = 32814;
  constant ETHERTYPE_TIGAN (line 1202) | pub const ETHERTYPE_TIGAN: u32 = 32815;
  constant ETHERTYPE_REVARP (line 1203) | pub const ETHERTYPE_REVARP: u32 = 32821;
  constant ETHERTYPE_AEONIC (line 1204) | pub const ETHERTYPE_AEONIC: u32 = 32822;
  constant ETHERTYPE_IPXNEW (line 1205) | pub const ETHERTYPE_IPXNEW: u32 = 32823;
  constant ETHERTYPE_LANBRIDGE (line 1206) | pub const ETHERTYPE_LANBRIDGE: u32 = 32824;
  constant ETHERTYPE_DSMD (line 1207) | pub const ETHERTYPE_DSMD: u32 = 32825;
  constant ETHERTYPE_ARGONAUT (line 1208) | pub const ETHERTYPE_ARGONAUT: u32 = 32826;
  constant ETHERTYPE_VAXELN (line 1209) | pub const ETHERTYPE_VAXELN: u32 = 32827;
  constant ETHERTYPE_DECDNS (line 1210) | pub const ETHERTYPE_DECDNS: u32 = 32828;
  constant ETHERTYPE_ENCRYPT (line 1211) | pub const ETHERTYPE_ENCRYPT: u32 = 32829;
  constant ETHERTYPE_DECDTS (line 1212) | pub const ETHERTYPE_DECDTS: u32 = 32830;
  constant ETHERTYPE_DECLTM (line 1213) | pub const ETHERTYPE_DECLTM: u32 = 32831;
  constant ETHERTYPE_DECNETBIOS (line 1214) | pub const ETHERTYPE_DECNETBIOS: u32 = 32832;
  constant ETHERTYPE_DECLAST (line 1215) | pub const ETHERTYPE_DECLAST: u32 = 32833;
  constant ETHERTYPE_PLANNING (line 1216) | pub const ETHERTYPE_PLANNING: u32 = 32836;
  constant ETHERTYPE_DECAM (line 1217) | pub const ETHERTYPE_DECAM: u32 = 32840;
  constant ETHERTYPE_EXPERDATA (line 1218) | pub const ETHERTYPE_EXPERDATA: u32 = 32841;
  constant ETHERTYPE_VEXP (line 1219) | pub const ETHERTYPE_VEXP: u32 = 32859;
  constant ETHERTYPE_VPROD (line 1220) | pub const ETHERTYPE_VPROD: u32 = 32860;
  constant ETHERTYPE_ES (line 1221) | pub const ETHERTYPE_ES: u32 = 32861;
  constant ETHERTYPE_LITTLE (line 1222) | pub const ETHERTYPE_LITTLE: u32 = 32864;
  constant ETHERTYPE_COUNTERPOINT (line 1223) | pub const ETHERTYPE_COUNTERPOINT: u32 = 32866;
  constant ETHERTYPE_VEECO (line 1224) | pub const ETHERTYPE_VEECO: u32 = 32871;
  constant ETHERTYPE_GENDYN (line 1225) | pub const ETHERTYPE_GENDYN: u32 = 32872;
  constant ETHERTYPE_ATT (line 1226) | pub const ETHERTYPE_ATT: u32 = 32873;
  constant ETHERTYPE_AUTOPHON (line 1227) | pub const ETHERTYPE_AUTOPHON: u32 = 32874;
  constant ETHERTYPE_COMDESIGN (line 1228) | pub const ETHERTYPE_COMDESIGN: u32 = 32876;
  constant ETHERTYPE_COMPUGRAPHIC (line 1229) | pub const ETHERTYPE_COMPUGRAPHIC: u32 = 32877;
  constant ETHERTYPE_MATRA (line 1230) | pub const ETHERTYPE_MATRA: u32 = 32890;
  constant ETHERTYPE_DDE (line 1231) | pub const ETHERTYPE_DDE: u32 = 32891;
  constant ETHERTYPE_MERIT (line 1232) | pub const ETHERTYPE_MERIT: u32 = 32892;
  constant ETHERTYPE_VLTLMAN (line 1233) | pub const ETHERTYPE_VLTLMAN: u32 = 32896;
  constant ETHERTYPE_ATALK (line 1234) | pub const ETHERTYPE_ATALK: u32 = 32923;
  constant ETHERTYPE_AT (line 1235) | pub const ETHERTYPE_AT: u32 = 32923;
  constant ETHERTYPE_APPLETALK (line 1236) | pub const ETHERTYPE_APPLETALK: u32 = 32923;
  constant ETHERTYPE_SPIDER (line 1237) | pub const ETHERTYPE_SPIDER: u32 = 32927;
  constant ETHERTYPE_PACER (line 1238) | pub const ETHERTYPE_PACER: u32 = 32966;
  constant ETHERTYPE_APPLITEK (line 1239) | pub const ETHERTYPE_APPLITEK: u32 = 32967;
  constant ETHERTYPE_SNA (line 1240) | pub const ETHERTYPE_SNA: u32 = 32981;
  constant ETHERTYPE_VARIAN (line 1241) | pub const ETHERTYPE_VARIAN: u32 = 32989;
  constant ETHERTYPE_RETIX (line 1242) | pub const ETHERTYPE_RETIX: u32 = 33010;
  constant ETHERTYPE_AARP (line 1243) | pub const ETHERTYPE_AARP: u32 = 33011;
  constant ETHERTYPE_APOLLO (line 1244) | pub const ETHERTYPE_APOLLO: u32 = 33015;
  constant ETHERTYPE_VLAN (line 1245) | pub const ETHERTYPE_VLAN: u32 = 33024;
  constant ETHERTYPE_BOFL (line 1246) | pub const ETHERTYPE_BOFL: u32 = 33026;
  constant ETHERTYPE_WELLFLEET (line 1247) | pub const ETHERTYPE_WELLFLEET: u32 = 33027;
  constant ETHERTYPE_TALARIS (line 1248) | pub const ETHERTYPE_TALARIS: u32 = 33067;
  constant ETHERTYPE_WATERLOO (line 1249) | pub const ETHERTYPE_WATERLOO: u32 = 33072;
  constant ETHERTYPE_HAYES (line 1250) | pub const ETHERTYPE_HAYES: u32 = 33072;
  constant ETHERTYPE_VGLAB (line 1251) | pub const ETHERTYPE_VGLAB: u32 = 33073;
  constant ETHERTYPE_IPX (line 1252) | pub const ETHERTYPE_IPX: u32 = 33079;
  constant ETHERTYPE_NOVELL (line 1253) | pub const ETHERTYPE_NOVELL: u32 = 33080;
  constant ETHERTYPE_MUMPS (line 1254) | pub const ETHERTYPE_MUMPS: u32 = 33087;
  constant ETHERTYPE_AMOEBA (line 1255) | pub const ETHERTYPE_AMOEBA: u32 = 33093;
  constant ETHERTYPE_FLIP (line 1256) | pub const ETHERTYPE_FLIP: u32 = 33094;
  constant ETHERTYPE_VURESERVED (line 1257) | pub const ETHERTYPE_VURESERVED: u32 = 33095;
  constant ETHERTYPE_LOGICRAFT (line 1258) | pub const ETHERTYPE_LOGICRAFT: u32 = 33096;
  constant ETHERTYPE_NCD (line 1259) | pub const ETHERTYPE_NCD: u32 = 33097;
  constant ETHERTYPE_ALPHA (line 1260) | pub const ETHERTYPE_ALPHA: u32 = 33098;
  constant ETHERTYPE_SNMP (line 1261) | pub const ETHERTYPE_SNMP: u32 = 33100;
  constant ETHERTYPE_TEC (line 1262) | pub const ETHERTYPE_TEC: u32 = 33103;
  constant ETHERTYPE_RATIONAL (line 1263) | pub const ETHERTYPE_RATIONAL: u32 = 33104;
  constant ETHERTYPE_XTP (line 1264) | pub const ETHERTYPE_XTP: u32 = 33149;
  constant ETHERTYPE_SGITW (line 1265) | pub const ETHERTYPE_SGITW: u32 = 33150;
  constant ETHERTYPE_HIPPI_FP (line 1266) | pub const ETHERTYPE_HIPPI_FP: u32 = 33152;
  constant ETHERTYPE_STP (line 1267) | pub const ETHERTYPE_STP: u32 = 33153;
  constant ETHERTYPE_MOTOROLA (line 1268) | pub const ETHERTYPE_MOTOROLA: u32 = 33165;
  constant ETHERTYPE_NETBEUI (line 1269) | pub const ETHERTYPE_NETBEUI: u32 = 33169;
  constant ETHERTYPE_ACCTON (line 1270) | pub const ETHERTYPE_ACCTON: u32 = 33680;
  constant ETHERTYPE_TALARISMC (line 1271) | pub const ETHERTYPE_TALARISMC: u32 = 34091;
  constant ETHERTYPE_KALPANA (line 1272) | pub const ETHERTYPE_KALPANA: u32 = 34178;
  constant ETHERTYPE_SECTRA (line 1273) | pub const ETHERTYPE_SECTRA: u32 = 34523;
  constant ETHERTYPE_IPV6 (line 1274) | pub const ETHERTYPE_IPV6: u32 = 34525;
  constant ETHERTYPE_DELTACON (line 1275) | pub const ETHERTYPE_DELTACON: u32 = 34526;
  constant ETHERTYPE_ATOMIC (line 1276) | pub const ETHERTYPE_ATOMIC: u32 = 34527;
  constant ETHERTYPE_RDP (line 1277) | pub const ETHERTYPE_RDP: u32 = 34617;
  constant ETHERTYPE_MICP (line 1278) | pub const ETHERTYPE_MICP: u32 = 34618;
  constant ETHERTYPE_TCPCOMP (line 1279) | pub const ETHERTYPE_TCPCOMP: u32 = 34667;
  constant ETHERTYPE_IPAS (line 1280) | pub const ETHERTYPE_IPAS: u32 = 34668;
  constant ETHERTYPE_SECUREDATA (line 1281) | pub const ETHERTYPE_SECUREDATA: u32 = 34669;
  constant ETHERTYPE_FLOWCONTROL (line 1282) | pub const ETHERTYPE_FLOWCONTROL: u32 = 34824;
  constant ETHERTYPE_SLOW (line 1283) | pub const ETHERTYPE_SLOW: u32 = 34825;
  constant ETHERTYPE_PPP (line 1284) | pub const ETHERTYPE_PPP: u32 = 34827;
  constant ETHERTYPE_HITACHI (line 1285) | pub const ETHERTYPE_HITACHI: u32 = 34848;
  constant ETHERTYPE_TEST (line 1286) | pub const ETHERTYPE_TEST: u32 = 34850;
  constant ETHERTYPE_MPLS (line 1287) | pub const ETHERTYPE_MPLS: u32 = 34887;
  constant ETHERTYPE_MPLS_MCAST (line 1288) | pub const ETHERTYPE_MPLS_MCAST: u32 = 34888;
  constant ETHERTYPE_AXIS (line 1289) | pub const ETHERTYPE_AXIS: u32 = 34902;
  constant ETHERTYPE_PPPOEDISC (line 1290) | pub const ETHERTYPE_PPPOEDISC: u32 = 34915;
  constant ETHERTYPE_PPPOE (line 1291) | pub const ETHERTYPE_PPPOE: u32 = 34916;
  constant ETHERTYPE_LANPROBE (line 1292) | pub const ETHERTYPE_LANPROBE: u32 = 34952;
  constant ETHERTYPE_PAE (line 1293) | pub const ETHERTYPE_PAE: u32 = 34958;
  constant ETHERTYPE_PROFINET (line 1294) | pub const ETHERTYPE_PROFINET: u32 = 34962;
  constant ETHERTYPE_AOE (line 1295) | pub const ETHERTYPE_AOE: u32 = 34978;
  constant ETHERTYPE_ETHERCAT (line 1296) | pub const ETHERTYPE_ETHERCAT: u32 = 34980;
  constant ETHERTYPE_QINQ (line 1297) | pub const ETHERTYPE_QINQ: u32 = 34984;
  constant ETHERTYPE_POWERLINK (line 1298) | pub const ETHERTYPE_POWERLINK: u32 = 34987;
  constant ETHERTYPE_LLDP (line 1299) | pub const ETHERTYPE_LLDP: u32 = 35020;
  constant ETHERTYPE_SERCOS (line 1300) | pub const ETHERTYPE_SERCOS: u32 = 35021;
  constant ETHERTYPE_MACSEC (line 1301) | pub const ETHERTYPE_MACSEC: u32 = 35045;
  constant ETHERTYPE_PBB (line 1302) | pub const ETHERTYPE_PBB: u32 = 35047;
  constant ETHERTYPE_FCOE (line 1303) | pub const ETHERTYPE_FCOE: u32 = 35078;
  constant ETHERTYPE_LOOPBACK (line 1304) | pub const ETHERTYPE_LOOPBACK: u32 = 36864;
  constant ETHERTYPE_8021Q9100 (line 1305) | pub const ETHERTYPE_8021Q9100: u32 = 37120;
  constant ETHERTYPE_LBACK (line 1306) | pub const ETHERTYPE_LBACK: u32 = 36864;
  constant ETHERTYPE_XNSSM (line 1307) | pub const ETHERTYPE_XNSSM: u32 = 36865;
  constant ETHERTYPE_TCPSM (line 1308) | pub const ETHERTYPE_TCPSM: u32 = 36866;
  constant ETHERTYPE_BCLOOP (line 1309) | pub const ETHERTYPE_BCLOOP: u32 = 36867;
  constant ETHERTYPE_8021Q9200 (line 1310) | pub const ETHERTYPE_8021Q9200: u32 = 37376;
  constant ETHERTYPE_8021Q9300 (line 1311) | pub const ETHERTYPE_8021Q9300: u32 = 37632;
  constant ETHERTYPE_DEBNI (line 1312) | pub const ETHERTYPE_DEBNI: u32 = 43690;
  constant ETHERTYPE_SONIX (line 1313) | pub const ETHERTYPE_SONIX: u32 = 64245;
  constant ETHERTYPE_VITAL (line 1314) | pub const ETHERTYPE_VITAL: u32 = 65280;
  constant ETHERTYPE_MAX (line 1315) | pub const ETHERTYPE_MAX: u32 = 65535;
  constant ETHERMTU (line 1316) | pub const ETHERMTU: u32 = 1500;
  constant ETHERMIN (line 1317) | pub const ETHERMIN: u32 = 46;
  constant ETHERMTU_JUMBO (line 1318) | pub const ETHERMTU_JUMBO: u32 = 9000;
  constant IEEE8021Q_PCP_BK (line 1319) | pub const IEEE8021Q_PCP_BK: u32 = 1;
  constant IEEE8021Q_PCP_BE (line 1320) | pub const IEEE8021Q_PCP_BE: u32 = 0;
  constant IEEE8021Q_PCP_EE (line 1321) | pub const IEEE8021Q_PCP_EE: u32 = 2;
  constant IEEE8021Q_PCP_CA (line 1322) | pub const IEEE8021Q_PCP_CA: u32 = 3;
  constant IEEE8021Q_PCP_VI (line 1323) | pub const IEEE8021Q_PCP_VI: u32 = 4;
  constant IEEE8021Q_PCP_VO (line 1324) | pub const IEEE8021Q_PCP_VO: u32 = 5;
  constant IEEE8021Q_PCP_IC (line 1325) | pub const IEEE8021Q_PCP_IC: u32 = 6;
  constant IEEE8021Q_PCP_NC (line 1326) | pub const IEEE8021Q_PCP_NC: u32 = 7;
  constant RNF_NORMAL (line 1327) | pub const RNF_NORMAL: u32 = 1;
  constant RNF_ROOT (line 1328) | pub const RNF_ROOT: u32 = 2;
  constant RNF_ACTIVE (line 1329) | pub const RNF_ACTIVE: u32 = 4;
  constant IPPROTO_IP (line 1330) | pub const IPPROTO_IP: u32 = 0;
  constant IPPROTO_ICMP (line 1331) | pub const IPPROTO_ICMP: u32 = 1;
  constant IPPROTO_TCP (line 1332) | pub const IPPROTO_TCP: u32 = 6;
  constant IPPROTO_UDP (line 1333) | pub const IPPROTO_UDP: u32 = 17;
  constant IPPROTO_IPV6 (line 1334) | pub const IPPROTO_IPV6: u32 = 41;
  constant IPPROTO_RAW (line 1335) | pub const IPPROTO_RAW: u32 = 255;
  constant INET_ADDRSTRLEN (line 1336) | pub const INET_ADDRSTRLEN: u32 = 16;
  constant IPPROTO_HOPOPTS (line 1337) | pub const IPPROTO_HOPOPTS: u32 = 0;
  constant IPPROTO_IGMP (line 1338) | pub const IPPROTO_IGMP: u32 = 2;
  constant IPPROTO_GGP (line 1339) | pub const IPPROTO_GGP: u32 = 3;
  constant IPPROTO_IPV4 (line 1340) | pub const IPPROTO_IPV4: u32 = 4;
  constant IPPROTO_IPIP (line 1341) | pub const IPPROTO_IPIP: u32 = 4;
  constant IPPROTO_ST (line 1342) | pub const IPPROTO_ST: u32 = 7;
  constant IPPROTO_EGP (line 1343) | pub const IPPROTO_EGP: u32 = 8;
  constant IPPROTO_PIGP (line 1344) | pub const IPPROTO_PIGP: u32 = 9;
  constant IPPROTO_RCCMON (line 1345) | pub const IPPROTO_RCCMON: u32 = 10;
  constant IPPROTO_NVPII (line 1346) | pub const IPPROTO_NVPII: u32 = 11;
  constant IPPROTO_PUP (line 1347) | pub const IPPROTO_PUP: u32 = 12;
  constant IPPROTO_ARGUS (line 1348) | pub const IPPROTO_ARGUS: u32 = 13;
  constant IPPROTO_EMCON (line 1349) | pub const IPPROTO_EMCON: u32 = 14;
  constant IPPROTO_XNET (line 1350) | pub const IPPROTO_XNET: u32 = 15;
  constant IPPROTO_CHAOS (line 1351) | pub const IPPROTO_CHAOS: u32 = 16;
  constant IPPROTO_MUX (line 1352) | pub const IPPROTO_MUX: u32 = 18;
  constant IPPROTO_MEAS (line 1353) | pub const IPPROTO_MEAS: u32 = 19;
  constant IPPROTO_HMP (line 1354) | pub const IPPROTO_HMP: u32 = 20;
  constant IPPROTO_PRM (line 1355) | pub const IPPROTO_PRM: u32 = 21;
  constant IPPROTO_IDP (line 1356) | pub const IPPROTO_IDP: u32 = 22;
  constant IPPROTO_TRUNK1 (line 1357) | pub const IPPROTO_TRUNK1: u32 = 23;
  constant IPPROTO_TRUNK2 (line 1358) | pub const IPPROTO_TRUNK2: u32 = 24;
  constant IPPROTO_LEAF1 (line 1359) | pub const IPPROTO_LEAF1: u32 = 25;
  constant IPPROTO_LEAF2 (line 1360) | pub const IPPROTO_LEAF2: u32 = 26;
  constant IPPROTO_RDP (line 1361) | pub const IPPROTO_RDP: u32 = 27;
  constant IPPROTO_IRTP (line 1362) | pub const IPPROTO_IRTP: u32 = 28;
  constant IPPROTO_TP (line 1363) | pub const IPPROTO_TP: u32 = 29;
  constant IPPROTO_BLT (line 1364) | pub const IPPROTO_BLT: u32 = 30;
  constant IPPROTO_NSP (line 1365) | pub const IPPROTO_NSP: u32 = 31;
  constant IPPROTO_INP (line 1366) | pub const IPPROTO_INP: u32 = 32;
  constant IPPROTO_DCCP (line 1367) | pub const IPPROTO_DCCP: u32 = 33;
  constant IPPROTO_3PC (line 1368) | pub const IPPROTO_3PC: u32 = 34;
  constant IPPROTO_IDPR (line 1369) | pub const IPPROTO_IDPR: u32 = 35;
  constant IPPROTO_XTP (line 1370) | pub const IPPROTO_XTP: u32 = 36;
  constant IPPROTO_DDP (line 1371) | pub const IPPROTO_DDP: u32 = 37;
  constant IPPROTO_CMTP (line 1372) | pub const IPPROTO_CMTP: u32 = 38;
  constant IPPROTO_TPXX (line 1373) | pub const IPPROTO_TPXX: u32 = 39;
  constant IPPROTO_IL (line 1374) | pub const IPPROTO_IL: u32 = 40;
  constant IPPROTO_SDRP (line 1375) | pub const IPPROTO_SDRP: u32 = 42;
  constant IPPROTO_ROUTING (line 1376) | pub const IPPROTO_ROUTING: u32 = 43;
  constant IPPROTO_FRAGMENT (line 1377) | pub const IPPROTO_FRAGMENT: u32 = 44;
  constant IPPROTO_IDRP (line 1378) | pub const IPPROTO_IDRP: u32 = 45;
  constant IPPROTO_RSVP (line 1379) | pub const IPPROTO_RSVP: u32 = 46;
  constant IPPROTO_GRE (line 1380) | pub const IPPROTO_GRE: u32 = 47;
  constant IPPROTO_MHRP (line 1381) | pub const IPPROTO_MHRP: u32 = 48;
  constant IPPROTO_BHA (line 1382) | pub const IPPROTO_BHA: u32 = 49;
  constant IPPROTO_ESP (line 1383) | pub const IPPROTO_ESP: u32 = 50;
  constant IPPROTO_AH (line 1384) | pub const IPPROTO_AH: u32 = 51;
  constant IPPROTO_INLSP (line 1385) | pub const IPPROTO_INLSP: u32 = 52;
  constant IPPROTO_SWIPE (line 1386) | pub const IPPROTO_SWIPE: u32 = 53;
  constant IPPROTO_NHRP (line 1387) | pub const IPPROTO_NHRP: u32 = 54;
  constant IPPROTO_MOBILE (line 1388) | pub const IPPROTO_MOBILE: u32 = 55;
  constant IPPROTO_TLSP (line 1389) | pub const IPPROTO_TLSP: u32 = 56;
  constant IPPROTO_SKIP (line 1390) | pub const IPPROTO_SKIP: u32 = 57;
  constant IPPROTO_ICMPV6 (line 1391) | pub const IPPROTO_ICMPV6: u32 = 58;
  constant IPPROTO_NONE (line 1392) | pub const IPPROTO_NONE: u32 = 59;
  constant IPPROTO_DSTOPTS (line 1393) | pub const IPPROTO_DSTOPTS: u32 = 60;
  constant IPPROTO_AHIP (line 1394) | pub const IPPROTO_AHIP: u32 = 61;
  constant IPPROTO_CFTP (line 1395) | pub const IPPROTO_CFTP: u32 = 62;
  constant IPPROTO_HELLO (line 1396) | pub const IPPROTO_HELLO: u32 = 63;
  constant IPPROTO_SATEXPAK (line 1397) | pub const IPPROTO_SATEXPAK: u32 = 64;
  constant IPPROTO_KRYPTOLAN (line 1398) | pub const IPPROTO_KRYPTOLAN: u32 = 65;
  constant IPPROTO_RVD (line 1399) | pub const IPPROTO_RVD: u32 = 66;
  constant IPPROTO_IPPC (line 1400) | pub const IPPROTO_IPPC: u32 = 67;
  constant IPPROTO_ADFS (line 1401) | pub const IPPROTO_ADFS: u32 = 68;
  constant IPPROTO_SATMON (line 1402) | pub const IPPROTO_SATMON: u32 = 69;
  constant IPPROTO_VISA (line 1403) | pub const IPPROTO_VISA: u32 = 70;
  constant IPPROTO_IPCV (line 1404) | pub const IPPROTO_IPCV: u32 = 71;
  constant IPPROTO_CPNX (line 1405) | pub const IPPROTO_CPNX: u32 = 72;
  constant IPPROTO_CPHB (line 1406) | pub const IPPROTO_CPHB: u32 = 73;
  constant IPPROTO_WSN (line 1407) | pub const IPPROTO_WSN: u32 = 74;
  constant IPPROTO_PVP (line 1408) | pub const IPPROTO_PVP: u32 = 75;
  constant IPPROTO_BRSATMON (line 1409) | pub const IPPROTO_BRSATMON: u32 = 76;
  constant IPPROTO_ND (line 1410) | pub const IPPROTO_ND: u32 = 77;
  constant IPPROTO_WBMON (line 1411) | pub const IPPROTO_WBMON: u32 = 78;
  constant IPPROTO_WBEXPAK (line 1412) | pub const IPPROTO_WBEXPAK: u32 = 79;
  constant IPPROTO_EON (line 1413) | pub const IPPROTO_EON: u32 = 80;
  constant IPPROTO_VMTP (line 1414) | pub const IPPROTO_VMTP: u32 = 81;
  constant IPPROTO_SVMTP (line 1415) | pub const IPPROTO_SVMTP: u32 = 82;
  constant IPPROTO_VINES (line 1416) | pub const IPPROTO_VINES: u32 = 83;
  constant IPPROTO_TTP (line 1417) | pub const IPPROTO_TTP: u32 = 84;
  constant IPPROTO_IGP (line 1418) | pub const IPPROTO_IGP: u32 = 85;
  constant IPPROTO_DGP (line 1419) | pub const IPPROTO_DGP: u32 = 86;
  constant IPPROTO_TCF (line 1420) | pub const IPPROTO_TCF: u32 = 87;
  constant IPPROTO_IGRP (line 1421) | pub const IPPROTO_IGRP: u32 = 88;
  constant IPPROTO_OSPFIGP (line 1422) | pub const IPPROTO_OSPFIGP: u32 = 89;
  constant IPPROTO_SRPC (line 1423) | pub const IPPROTO_SRPC: u32 = 90;
  constant IPPROTO_LARP (line 1424) | pub const IPPROTO_LARP: u32 = 91;
  constant IPPROTO_MTP (line 1425) | pub const IPPROTO_MTP: u32 = 92;
  constant IPPROTO_AX25 (line 1426) | pub const IPPROTO_AX25: u32 = 93;
  constant IPPROTO_IPEIP (line 1427) | pub const IPPROTO_IPEIP: u32 = 94;
  constant IPPROTO_MICP (line 1428) | pub const IPPROTO_MICP: u32 = 95;
  constant IPPROTO_SCCSP (line 1429) | pub const IPPROTO_SCCSP: u32 = 96;
  constant IPPROTO_ETHERIP (line 1430) | pub const IPPROTO_ETHERIP: u32 = 97;
  constant IPPROTO_ENCAP (line 1431) | pub const IPPROTO_ENCAP: u32 = 98;
  constant IPPROTO_APES (line 1432) | pub const IPPROTO_APES: u32 = 99;
  constant IPPROTO_GMTP (line 1433) | pub const IPPROTO_GMTP: u32 = 100;
  constant IPPROTO_IPCOMP (line 1434) | pub const IPPROTO_IPCOMP: u32 = 108;
  constant IPPROTO_SCTP (line 1435) | pub const IPPROTO_SCTP: u32 = 132;
  constant IPPROTO_MH (line 1436) | pub const IPPROTO_MH: u32 = 135;
  constant IPPROTO_UDPLITE (line 1437) | pub const IPPROTO_UDPLITE: u32 = 136;
  constant IPPROTO_HIP (line 1438) | pub const IPPROTO_HIP: u32 = 139;
  constant IPPROTO_SHIM6 (line 1439) | pub const IPPROTO_SHIM6: u32 = 140;
  constant IPPROTO_PIM (line 1440) | pub const IPPROTO_PIM: u32 = 103;
  constant IPPROTO_CARP (line 1441) | pub const IPPROTO_CARP: u32 = 112;
  constant IPPROTO_PGM (line 1442) | pub const IPPROTO_PGM: u32 = 113;
  constant IPPROTO_MPLS (line 1443) | pub const IPPROTO_MPLS: u32 = 137;
  constant IPPROTO_PFSYNC (line 1444) | pub const IPPROTO_PFSYNC: u32 = 240;
  constant IPPROTO_RESERVED_253 (line 1445) | pub const IPPROTO_RESERVED_253: u32 = 253;
  constant IPPROTO_RESERVED_254 (line 1446) | pub const IPPROTO_RESERVED_254: u32 = 254;
  constant IPPROTO_OLD_DIVERT (line 1447) | pub const IPPROTO_OLD_DIVERT: u32 = 254;
  constant IPPROTO_MAX (line 1448) | pub const IPPROTO_MAX: u32 = 256;
  constant IPPROTO_DONE (line 1449) | pub const IPPROTO_DONE: u32 = 257;
  constant IPPROTO_DIVERT (line 1450) | pub const IPPROTO_DIVERT: u32 = 258;
  constant IPPROTO_SEND (line 1451) | pub const IPPROTO_SEND: u32 = 259;
  constant IPPROTO_SPACER (line 1452) | pub const IPPROTO_SPACER: u32 = 32767;
  constant IPPORT_RESERVED (line 1453) | pub const IPPORT_RESERVED: u32 = 1024;
  constant IPPORT_EPHEMERALFIRST (line 1454) | pub const IPPORT_EPHEMERALFIRST: u32 = 10000;
  constant IPPORT_EPHEMERALLAST (line 1455) | pub const IPPORT_EPHEMERALLAST: u32 = 65535;
  constant IPPORT_HIFIRSTAUTO (line 1456) | pub const IPPORT_HIFIRSTAUTO: u32 = 49152;
  constant IPPORT_HILASTAUTO (line 1457) | pub const IPPORT_HILASTAUTO: u32 = 65535;
  constant IPPORT_RESERVEDSTART (line 1458) | pub const IPPORT_RESERVEDSTART: u32 = 600;
  constant IPPORT_MAX (line 1459) | pub const IPPORT_MAX: u32 = 65535;
  constant IN_CLASSA_NET (line 1460) | pub const IN_CLASSA_NET: u32 = 4278190080;
  constant IN_CLASSA_NSHIFT (line 1461) | pub const IN_CLASSA_NSHIFT: u32 = 24;
  constant IN_CLASSA_HOST (line 1462) | pub const IN_CLASSA_HOST: u32 = 16777215;
  constant IN_CLASSA_MAX (line 1463) | pub const IN_CLASSA_MAX: u32 = 128;
  constant IN_CLASSB_NET (line 1464) | pub const IN_CLASSB_NET: u32 = 4294901760;
  constant IN_CLASSB_NSHIFT (line 1465) | pub const IN_CLASSB_NSHIFT: u32 = 16;
  constant IN_CLASSB_HOST (line 1466) | pub const IN_CLASSB_HOST: u32 = 65535;
  constant IN_CLASSB_MAX (line 1467) | pub const IN_CLASSB_MAX: u32 = 65536;
  constant IN_CLASSC_NET (line 1468) | pub const IN_CLASSC_NET: u32 = 4294967040;
  constant IN_CLASSC_NSHIFT (line 1469) | pub const IN_CLASSC_NSHIFT: u32 = 8;
  constant IN_CLASSC_HOST (line 1470) | pub const IN_CLASSC_HOST: u32 = 255;
  constant IN_NETMASK_DEFAULT (line 1471) | pub const IN_NETMASK_DEFAULT: u32 = 4294967040;
  constant IN_CLASSD_NET (line 1472) | pub const IN_CLASSD_NET: u32 = 4026531840;
  constant IN_CLASSD_NSHIFT (line 1473) | pub const IN_CLASSD_NSHIFT: u32 = 28;
  constant IN_CLASSD_HOST (line 1474) | pub const IN_CLASSD_HOST: u32 = 268435455;
  constant IN_LOOPBACKNET (line 1475) | pub const IN_LOOPBACKNET: u32 = 127;
  constant IP_OPTIONS (line 1476) | pub const IP_OPTIONS: u32 = 1;
  constant IP_HDRINCL (line 1477) | pub const IP_HDRINCL: u32 = 2;
  constant IP_TOS (line 1478) | pub const IP_TOS: u32 = 3;
  constant IP_TTL (line 1479) | pub const IP_TTL: u32 = 4;
  constant IP_RECVOPTS (line 1480) | pub const IP_RECVOPTS: u32 = 5;
  constant IP_RECVRETOPTS (line 1481) | pub const IP_RECVRETOPTS: u32 = 6;
  constant IP_RECVDSTADDR (line 1482) | pub const IP_RECVDSTADDR: u32 = 7;
  constant IP_SENDSRCADDR (line 1483) | pub const IP_SENDSRCADDR: u32 = 7;
  constant IP_RETOPTS (line 1484) | pub const IP_RETOPTS: u32 = 8;
  constant IP_MULTICAST_IF (line 1485) | pub const IP_MULTICAST_IF: u32 = 9;
  constant IP_MULTICAST_TTL (line 1486) | pub const IP_MULTICAST_TTL: u32 = 10;
  constant IP_MULTICAST_LOOP (line 1487) | pub const IP_MULTICAST_LOOP: u32 = 11;
  constant IP_ADD_MEMBERSHIP (line 1488) | pub const IP_ADD_MEMBERSHIP: u32 = 12;
  constant IP_DROP_MEMBERSHIP (line 1489) | pub const IP_DROP_MEMBERSHIP: u32 = 13;
  constant IP_MULTICAST_VIF (line 1490) | pub const IP_MULTICAST_VIF: u32 = 14;
  constant IP_RSVP_ON (line 1491) | pub const IP_RSVP_ON: u32 = 15;
  constant IP_RSVP_OFF (line 1492) | pub const IP_RSVP_OFF: u32 = 16;
  constant IP_RSVP_VIF_ON (line 1493) | pub const IP_RSVP_VIF_ON: u32 = 17;
  constant IP_RSVP_VIF_OFF (line 1494) | pub const IP_RSVP_VIF_OFF: u32 = 18;
  constant IP_PORTRANGE (line 1495) | pub const IP_PORTRANGE: u32 = 19;
  constant IP_RECVIF (line 1496) | pub const IP_RECVIF: u32 = 20;
  constant IP_IPSEC_POLICY (line 1497) | pub const IP_IPSEC_POLICY: u32 = 21;
  constant IP_ONESBCAST (line 1498) | pub const IP_ONESBCAST: u32 = 23;
  constant IP_BINDANY (line 1499) | pub const IP_BINDANY: u32 = 24;
  constant IP_ORIGDSTADDR (line 1500) | pub const IP_ORIGDSTADDR: u32 = 27;
  constant IP_RECVORIGDSTADDR (line 1501) | pub const IP_RECVORIGDSTADDR: u32 = 27;
  constant IP_FW_TABLE_ADD (line 1502) | pub const IP_FW_TABLE_ADD: u32 = 40;
  constant IP_FW_TABLE_DEL (line 1503) | pub const IP_FW_TABLE_DEL: u32 = 41;
  constant IP_FW_TABLE_FLUSH (line 1504) | pub const IP_FW_TABLE_FLUSH: u32 = 42;
  constant IP_FW_TABLE_GETSIZE (line 1505) | pub const IP_FW_TABLE_GETSIZE: u32 = 43;
  constant IP_FW_TABLE_LIST (line 1506) | pub const IP_FW_TABLE_LIST: u32 = 44;
  constant IP_FW3 (line 1507) | pub const IP_FW3: u32 = 48;
  constant IP_DUMMYNET3 (line 1508) | pub const IP_DUMMYNET3: u32 = 49;
  constant IP_FW_ADD (line 1509) | pub const IP_FW_ADD: u32 = 50;
  constant IP_FW_DEL (line 1510) | pub const IP_FW_DEL: u32 = 51;
  constant IP_FW_FLUSH (line 1511) | pub const IP_FW_FLUSH: u32 = 52;
  constant IP_FW_ZERO (line 1512) | pub const IP_FW_ZERO: u32 = 53;
  constant IP_FW_GET (line 1513) | pub const IP_FW_GET: u32 = 54;
  constant IP_FW_RESETLOG (line 1514) | pub const IP_FW_RESETLOG: u32 = 55;
  constant IP_FW_NAT_CFG (line 1515) | pub const IP_FW_NAT_CFG: u32 = 56;
  constant IP_FW_NAT_DEL (line 1516) | pub const IP_FW_NAT_DEL: u32 = 57;
  constant IP_FW_NAT_GET_CONFIG (line 1517) | pub const IP_FW_NAT_GET_CONFIG: u32 = 58;
  constant IP_FW_NAT_GET_LOG (line 1518) | pub const IP_FW_NAT_GET_LOG: u32 = 59;
  constant IP_DUMMYNET_CONFIGURE (line 1519) | pub const IP_DUMMYNET_CONFIGURE: u32 = 60;
  constant IP_DUMMYNET_DEL (line 1520) | pub const IP_DUMMYNET_DEL: u32 = 61;
  constant IP_DUMMYNET_FLUSH (line 1521) | pub const IP_DUMMYNET_FLUSH: u32 = 62;
  constant IP_DUMMYNET_GET (line 1522) | pub const IP_DUMMYNET_GET: u32 = 64;
  constant IP_RECVTTL (line 1523) | pub const IP_RECVTTL: u32 = 65;
  constant IP_MINTTL (line 1524) | pub const IP_MINTTL: u32 = 66;
  constant IP_DONTFRAG (line 1525) | pub const IP_DONTFRAG: u32 = 67;
  constant IP_RECVTOS (line 1526) | pub const IP_RECVTOS: u32 = 68;
  constant IP_ADD_SOURCE_MEMBERSHIP (line 1527) | pub const IP_ADD_SOURCE_MEMBERSHIP: u32 = 70;
  constant IP_DROP_SOURCE_MEMBERSHIP (line 1528) | pub const IP_DROP_SOURCE_MEMBERSHIP: u32 = 71;
  constant IP_BLOCK_SOURCE (line 1529) | pub const IP_BLOCK_SOURCE: u32 = 72;
  constant IP_UNBLOCK_SOURCE (line 1530) | pub const IP_UNBLOCK_SOURCE: u32 = 73;
  constant IP_MSFILTER (line 1531) | pub const IP_MSFILTER: u32 = 74;
  constant IP_VLAN_PCP (line 1532) | pub const IP_VLAN_PCP: u32 = 75;
  constant MCAST_JOIN_GROUP (line 1533) | pub const MCAST_JOIN_GROUP: u32 = 80;
  constant MCAST_LEAVE_GROUP (line 1534) | pub const MCAST_LEAVE_GROUP: u32 = 81;
  constant MCAST_JOIN_SOURCE_GROUP (line 1535) | pub const MCAST_JOIN_SOURCE_GROUP: u32 = 82;
  constant MCAST_LEAVE_SOURCE_GROUP (line 1536) | pub const MCAST_LEAVE_SOURCE_GROUP: u32 = 83;
  constant MCAST_BLOCK_SOURCE (line 1537) | pub const MCAST_BLOCK_SOURCE: u32 = 84;
  constant MCAST_UNBLOCK_SOURCE (line 1538) | pub const MCAST_UNBLOCK_SOURCE: u32 = 85;
  constant IP_FLOWID (line 1539) | pub const IP_FLOWID: u32 = 90;
  constant IP_FLOWTYPE (line 1540) | pub const IP_FLOWTYPE: u32 = 91;
  constant IP_RSSBUCKETID (line 1541) | pub const IP_RSSBUCKETID: u32 = 92;
  constant IP_RECVFLOWID (line 1542) | pub const IP_RECVFLOWID: u32 = 93;
  constant IP_RECVRSSBUCKETID (line 1543) | pub const IP_RECVRSSBUCKETID: u32 = 94;
  constant IP_DEFAULT_MULTICAST_TTL (line 1544) | pub const IP_DEFAULT_MULTICAST_TTL: u32 = 1;
  constant IP_DEFAULT_MULTICAST_LOOP (line 1545) | pub const IP_DEFAULT_MULTICAST_LOOP: u32 = 1;
  constant IP_MAX_MEMBERSHIPS (line 1546) | pub const IP_MAX_MEMBERSHIPS: u32 = 4095;
  constant IP_MAX_GROUP_SRC_FILTER (line 1547) | pub const IP_MAX_GROUP_SRC_FILTER: u32 = 512;
  constant IP_MAX_SOCK_SRC_FILTER (line 1548) | pub const IP_MAX_SOCK_SRC_FILTER: u32 = 128;
  constant IP_MAX_SOCK_MUTE_FILTER (line 1549) | pub const IP_MAX_SOCK_MUTE_FILTER: u32 = 128;
  constant MCAST_UNDEFINED (line 1550) | pub const MCAST_UNDEFINED: u32 = 0;
  constant MCAST_INCLUDE (line 1551) | pub const MCAST_INCLUDE: u32 = 1;
  constant MCAST_EXCLUDE (line 1552) | pub const MCAST_EXCLUDE: u32 = 2;
  constant IP_PORTRANGE_DEFAULT (line 1553) | pub const IP_PORTRANGE_DEFAULT: u32 = 0;
  constant IP_PORTRANGE_HIGH (line 1554) | pub const IP_PORTRANGE_HIGH: u32 = 1;
  constant IP_PORTRANGE_LOW (line 1555) | pub const IP_PORTRANGE_LOW: u32 = 2;
  constant IPCTL_FORWARDING (line 1556) | pub const IPCTL_FORWARDING: u32 = 1;
  constant IPCTL_SENDREDIRECTS (line 1557) | pub const IPCTL_SENDREDIRECTS: u32 = 2;
  constant IPCTL_DEFTTL (line 1558) | pub const IPCTL_DEFTTL: u32 = 3;
  constant IPCTL_SOURCEROUTE (line 1559) | pub const IPCTL_SOURCEROUTE: u32 = 8;
  constant IPCTL_DIRECTEDBROADCAST (line 1560) | pub const IPCTL_DIRECTEDBROADCAST: u32 = 9;
  constant IPCTL_INTRQMAXLEN (line 1561) | pub const IPCTL_INTRQMAXLEN: u32 = 10;
  constant IPCTL_INTRQDROPS (line 1562) | pub const IPCTL_INTRQDROPS: u32 = 11;
  constant IPCTL_STATS (line 1563) | pub const IPCTL_STATS: u32 = 12;
  constant IPCTL_ACCEPTSOURCEROUTE (line 1564) | pub const IPCTL_ACCEPTSOURCEROUTE: u32 = 13;
  constant IPCTL_FASTFORWARDING (line 1565) | pub const IPCTL_FASTFORWARDING: u32 = 14;
  constant IPCTL_GIF_TTL (line 1566) | pub const IPCTL_GIF_TTL: u32 = 16;
  constant IPCTL_INTRDQMAXLEN (line 1567) | pub const IPCTL_INTRDQMAXLEN: u32 = 17;
  constant IPCTL_INTRDQDROPS (line 1568) | pub const IPCTL_INTRDQDROPS: u32 = 18;
  constant __KAME_VERSION (line 1569) | pub const __KAME_VERSION: &[u8; 8] = b"FreeBSD\0";
  constant IPV6PORT_RESERVED (line 1570) | pub const IPV6PORT_RESERVED: u32 = 1024;
  constant IPV6PORT_ANONMIN (line 1571) | pub const IPV6PORT_ANONMIN: u32 = 49152;
  constant IPV6PORT_ANONMAX (line 1572) | pub const IPV6PORT_ANONMAX: u32 = 65535;
  constant IPV6PORT_RESERVEDMIN (line 1573) | pub const IPV6PORT_RESERVEDMIN: u32 = 600;
  constant IPV6PORT_RESERVEDMAX (line 1574) | pub const IPV6PORT_RESERVEDMAX: u32 = 1023;
  constant INET6_ADDRSTRLEN (line 1575) | pub const INET6_ADDRSTRLEN: u32 = 46;
  constant __IPV6_ADDR_SCOPE_NODELOCAL (line 1576) | pub const __IPV6_ADDR_SCOPE_NODELOCAL: u32 = 1;
  constant __IPV6_ADDR_SCOPE_INTFACELOCAL (line 1577) | pub const __IPV6_ADDR_SCOPE_INTFACELOCAL: u32 = 1;
  constant __IPV6_ADDR_SCOPE_LINKLOCAL (line 1578) | pub const __IPV6_ADDR_SCOPE_LINKLOCAL: u32 = 2;
  constant __IPV6_ADDR_SCOPE_SITELOCAL (line 1579) | pub const __IPV6_ADDR_SCOPE_SITELOCAL: u32 = 5;
  constant __IPV6_ADDR_SCOPE_ORGLOCAL (line 1580) | pub const __IPV6_ADDR_SCOPE_ORGLOCAL: u32 = 8;
  constant __IPV6_ADDR_SCOPE_GLOBAL (line 1581) | pub const __IPV6_ADDR_SCOPE_GLOBAL: u32 = 14;
  constant IPV6_SOCKOPT_RESERVED1 (line 1582) | pub const IPV6_SOCKOPT_RESERVED1: u32 = 3;
  constant IPV6_UNICAST_HOPS (line 1583) | pub const IPV6_UNICAST_HOPS: u32 = 4;
  constant IPV6_MULTICAST_IF (line 1584) | pub const IPV6_MULTICAST_IF: u32 = 9;
  constant IPV6_MULTICAST_HOPS (line 1585) | pub const IPV6_MULTICAST_HOPS: u32 = 10;
  constant IPV6_MULTICAST_LOOP (line 1586) | pub const IPV6_MULTICAST_LOOP: u32 = 11;
  constant IPV6_JOIN_GROUP (line 1587) | pub const IPV6_JOIN_GROUP: u32 = 12;
  constant IPV6_LEAVE_GROUP (line 1588) | pub const IPV6_LEAVE_GROUP: u32 = 13;
  constant IPV6_PORTRANGE (line 1589) | pub const IPV6_PORTRANGE: u32 = 14;
  constant ICMP6_FILTER (line 1590) | pub const ICMP6_FILTER: u32 = 18;
  constant IPV6_CHECKSUM (line 1591) | pub const IPV6_CHECKSUM: u32 = 26;
  constant IPV6_V6ONLY (line 1592) | pub const IPV6_V6ONLY: u32 = 27;
  constant IPV6_BINDV6ONLY (line 1593) | pub const IPV6_BINDV6ONLY: u32 = 27;
  constant IPV6_IPSEC_POLICY (line 1594) | pub const IPV6_IPSEC_POLICY: u32 = 28;
  constant IPV6_FW_ADD (line 1595) | pub const IPV6_FW_ADD: u32 = 30;
  constant IPV6_FW_DEL (line 1596) | pub const IPV6_FW_DEL: u32 = 31;
  constant IPV6_FW_FLUSH (line 1597) | pub const IPV6_FW_FLUSH: u32 = 32;
  constant IPV6_FW_ZERO (line 1598) | pub const IPV6_FW_ZERO: u32 = 33;
  constant IPV6_FW_GET (line 1599) | pub const IPV6_FW_GET: u32 = 34;
  constant IPV6_RTHDRDSTOPTS (line 1600) | pub const IPV6_RTHDRDSTOPTS: u32 = 35;
  constant IPV6_RECVPKTINFO (line 1601) | pub const IPV6_RECVPKTINFO: u32 = 36;
  constant IPV6_RECVHOPLIMIT (line 1602) | pub const IPV6_RECVHOPLIMIT: u32 = 37;
  constant IPV6_RECVRTHDR (line 1603) | pub const IPV6_RECVRTHDR: u32 = 38;
  constant IPV6_RECVHOPOPTS (line 1604) | pub const IPV6_RECVHOPOPTS: u32 = 39;
  constant IPV6_RECVDSTOPTS (line 1605) | pub const IPV6_RECVDSTOPTS: u32 = 40;
  constant IPV6_USE_MIN_MTU (line 1606) | pub const IPV6_USE_MIN_MTU: u32 = 42;
  constant IPV6_RECVPATHMTU (line 1607) | pub const IPV6_RECVPATHMTU: u32 = 43;
  constant IPV6_PATHMTU (line 1608) | pub const IPV6_PATHMTU: u32 = 44;
  constant IPV6_PKTINFO (line 1609) | pub const IPV6_PKTINFO: u32 = 46;
  constant IPV6_HOPLIMIT (line 1610) | pub const IPV6_HOPLIMIT: u32 = 47;
  constant IPV6_NEXTHOP (line 1611) | pub const IPV6_NEXTHOP: u32 = 48;
  constant IPV6_HOPOPTS (line 1612) | pub const IPV6_HOPOPTS: u32 = 49;
  constant IPV6_DSTOPTS (line 1613) | pub const IPV6_DSTOPTS: u32 = 50;
  constant IPV6_RTHDR (line 1614) | pub const IPV6_RTHDR: u32 = 51;
  constant IPV6_RECVTCLASS (line 1615) | pub const IPV6_RECVTCLASS: u32 = 57;
  constant IPV6_AUTOFLOWLABEL (line 1616) | pub const IPV6_AUTOFLOWLABEL: u32 = 59;
  constant IPV6_TCLASS (line 1617) | pub const IPV6_TCLASS: u32 = 61;
  constant IPV6_DONTFRAG (line 1618) | pub const IPV6_DONTFRAG: u32 = 62;
  constant IPV6_PREFER_TEMPADDR (line 1619) | pub const IPV6_PREFER_TEMPADDR: u32 = 63;
  constant IPV6_BINDANY (line 1620) | pub const IPV6_BINDANY: u32 = 64;
  constant IPV6_FLOWID (line 1621) | pub const IPV6_FLOWID: u32 = 67;
  constant IPV6_FLOWTYPE (line 1622) | pub const IPV6_FLOWTYPE: u32 = 68;
  constant IPV6_RSSBUCKETID (line 1623) | pub const IPV6_RSSBUCKETID: u32 = 69;
  constant IPV6_RECVFLOWID (line 1624) | pub const IPV6_RECVFLOWID: u32 = 70;
  constant IPV6_RECVRSSBUCKETID (line 1625) | pub const IPV6_RECVRSSBUCKETID: u32 = 71;
  constant IPV6_ORIGDSTADDR (line 1626) | pub const IPV6_ORIGDSTADDR: u32 = 72;
  constant IPV6_RECVORIGDSTADDR (line 1627) | pub const IPV6_RECVORIGDSTADDR: u32 = 72;
  constant IPV6_MSFILTER (line 1628) | pub const IPV6_MSFILTER: u32 = 74;
  constant IPV6_VLAN_PCP (line 1629) | pub const IPV6_VLAN_PCP: u32 = 75;
  constant IPV6_RTHDR_LOOSE (line 1630) | pub const IPV6_RTHDR_LOOSE: u32 = 0;
  constant IPV6_RTHDR_STRICT (line 1631) | pub const IPV6_RTHDR_STRICT: u32 = 1;
  constant IPV6_RTHDR_TYPE_0 (line 1632) | pub const IPV6_RTHDR_TYPE_0: u32 = 0;
  constant IPV6_DEFAULT_MULTICAST_HOPS (line 1633) | pub const IPV6_DEFAULT_MULTICAST_HOPS: u32 = 1;
  constant IPV6_DEFAULT_MULTICAST_LOOP (line 1634) | pub const IPV6_DEFAULT_MULTICAST_LOOP: u32 = 1;
  constant IPV6_MAX_MEMBERSHIPS (line 1635) | pub const IPV6_MAX_MEMBERSHIPS: u32 = 4095;
  constant IPV6_MAX_GROUP_SRC_FILTER (line 1636) | pub const IPV6_MAX_GROUP_SRC_FILTER: u32 = 512;
  constant IPV6_MAX_SOCK_SRC_FILTER (line 1637) | pub const IPV6_MAX_SOCK_SRC_FILTER: u32 = 128;
  constant IPV6_PORTRANGE_DEFAULT (line 1638) | pub const IPV6_PORTRANGE_DEFAULT: u32 = 0;
  constant IPV6_PORTRANGE_HIGH (line 1639) | pub const IPV6_PORTRANGE_HIGH: u32 = 1;
  constant IPV6_PORTRANGE_LOW (line 1640) | pub const IPV6_PORTRANGE_LOW: u32 = 2;
  constant IPV6PROTO_MAXID (line 1641) | pub const IPV6PROTO_MAXID: u32 = 104;
  constant IPV6CTL_FORWARDING (line 1642) | pub const IPV6CTL_FORWARDING: u32 = 1;
  constant IPV6CTL_SENDREDIRECTS (line 1643) | pub const IPV6CTL_SENDREDIRECTS: u32 = 2;
  constant IPV6CTL_DEFHLIM (line 1644) | pub const IPV6CTL_DEFHLIM: u32 = 3;
  constant IPV6CTL_FORWSRCRT (line 1645) | pub const IPV6CTL_FORWSRCRT: u32 = 5;
  constant IPV6CTL_STATS (line 1646) | pub const IPV6CTL_STATS: u32 = 6;
  constant IPV6CTL_MRTSTATS (line 1647) | pub const IPV6CTL_MRTSTATS: u32 = 7;
  constant IPV6CTL_MRTPROTO (line 1648) | pub const IPV6CTL_MRTPROTO: u32 = 8;
  constant IPV6CTL_MAXFRAGPACKETS (line 1649) | pub const IPV6CTL_MAXFRAGPACKETS: u32 = 9;
  constant IPV6CTL_SOURCECHECK (line 1650) | pub const IPV6CTL_SOURCECHECK: u32 = 10;
  constant IPV6CTL_SOURCECHECK_LOGINT (line 1651) | pub const IPV6CTL_SOURCECHECK_LOGINT: u32 = 11;
  constant IPV6CTL_ACCEPT_RTADV (line 1652) | pub const IPV6CTL_ACCEPT_RTADV: u32 = 12;
  constant IPV6CTL_LOG_INTERVAL (line 1653) | pub const IPV6CTL_LOG_INTERVAL: u32 = 14;
  constant IPV6CTL_HDRNESTLIMIT (line 1654) | pub const IPV6CTL_HDRNESTLIMIT: u32 = 15;
  constant IPV6CTL_DAD_COUNT (line 1655) | pub const IPV6CTL_DAD_COUNT: u32 = 16;
  constant IPV6CTL_AUTO_FLOWLABEL (line 1656) | pub const IPV6CTL_AUTO_FLOWLABEL: u32 = 17;
  constant IPV6CTL_DEFMCASTHLIM (line 1657) | pub const IPV6CTL_DEFMCASTHLIM: u32 = 18;
  constant IPV6CTL_GIF_HLIM (line 1658) | pub const IPV6CTL_GIF_HLIM: u32 = 19;
  constant IPV6CTL_KAME_VERSION (line 1659) | pub const IPV6CTL_KAME_VERSION: u32 = 20;
  constant IPV6CTL_USE_DEPRECATED (line 1660) | pub const IPV6CTL_USE_DEPRECATED: u32 = 21;
  constant IPV6CTL_RR_PRUNE (line 1661) | pub const IPV6CTL_RR_PRUNE: u32 = 22;
  constant IPV6CTL_V6ONLY (line 1662) | pub const IPV6CTL_V6ONLY: u32 = 24;
  constant IPV6CTL_USETEMPADDR (line 1663) | pub const IPV6CTL_USETEMPADDR: u32 = 32;
  constant IPV6CTL_TEMPPLTIME (line 1664) | pub const IPV6CTL_TEMPPLTIME: u32 = 33;
  constant IPV6CTL_TEMPVLTIME (line 1665) | pub const IPV6CTL_TEMPVLTIME: u32 = 34;
  constant IPV6CTL_AUTO_LINKLOCAL (line 1666) | pub const IPV6CTL_AUTO_LINKLOCAL: u32 = 35;
  constant IPV6CTL_RIP6STATS (line 1667) | pub const IPV6CTL_RIP6STATS: u32 = 36;
  constant IPV6CTL_PREFER_TEMPADDR (line 1668) | pub const IPV6CTL_PREFER_TEMPADDR: u32 = 37;
  constant IPV6CTL_ADDRCTLPOLICY (line 1669) | pub const IPV6CTL_ADDRCTLPOLICY: u32 = 38;
  constant IPV6CTL_USE_DEFAULTZONE (line 1670) | pub const IPV6CTL_USE_DEFAULTZONE: u32 = 39;
  constant IPV6CTL_MAXFRAGS (line 1671) | pub const IPV6CTL_MAXFRAGS: u32 = 41;
  constant IPV6CTL_MCAST_PMTU (line 1672) | pub const IPV6CTL_MCAST_PMTU: u32 = 44;
  constant IPV6CTL_STEALTH (line 1673) | pub const IPV6CTL_STEALTH: u32 = 45;
  constant ICMPV6CTL_ND6_ONLINKNSRFC4861 (line 1674) | pub const ICMPV6CTL_ND6_ONLINKNSRFC4861: u32 = 47;
  constant IPV6CTL_NO_RADR (line 1675) | pub const IPV6CTL_NO_RADR: u32 = 48;
  constant IPV6CTL_NORBIT_RAIF (line 1676) | pub const IPV6CTL_NORBIT_RAIF: u32 = 49;
  constant IPV6CTL_RFC6204W3 (line 1677) | pub const IPV6CTL_RFC6204W3: u32 = 50;
  constant IPV6CTL_INTRQMAXLEN (line 1678) | pub const IPV6CTL_INTRQMAXLEN: u32 = 51;
  constant IPV6CTL_INTRDQMAXLEN (line 1679) | pub const IPV6CTL_INTRDQMAXLEN: u32 = 52;
  constant IPV6CTL_MAXFRAGSPERPACKET (line 1680) | pub const IPV6CTL_MAXFRAGSPERPACKET: u32 = 53;
  constant IPV6CTL_MAXFRAGBUCKETSIZE (line 1681) | pub const IPV6CTL_MAXFRAGBUCKETSIZE: u32 = 54;
  constant IPV6CTL_MAXID (line 1682) | pub const IPV6CTL_MAXID: u32 = 55;
  constant PF_MD5_DIGEST_LENGTH (line 1683) | pub const PF_MD5_DIGEST_LENGTH: u32 = 16;
  constant PFTM_TCP_FIRST_PACKET_VAL (line 1684) | pub const PFTM_TCP_FIRST_PACKET_VAL: u32 = 120;
  constant PFTM_TCP_OPENING_VAL (line 1685) | pub const PFTM_TCP_OPENING_VAL: u32 = 30;
  constant PFTM_TCP_ESTABLISHED_VAL (line 1686) | pub const PFTM_TCP_ESTABLISHED_VAL: u32 = 86400;
  constant PFTM_TCP_CLOSING_VAL (line 1687) | pub const PFTM_TCP_CLOSING_VAL: u32 = 900;
  constant PFTM_TCP_FIN_WAIT_VAL (line 1688) | pub const PFTM_TCP_FIN_WAIT_VAL: u32 = 45;
  constant PFTM_TCP_CLOSED_VAL (line 1689) | pub const PFTM_TCP_CLOSED_VAL: u32 = 90;
  constant PFTM_UDP_FIRST_PACKET_VAL (line 1690) | pub const PFTM_UDP_FIRST_PACKET_VAL: u32 = 60;
  constant PFTM_UDP_SINGLE_VAL (line 1691) | pub const PFTM_UDP_SINGLE_VAL: u32 = 30;
  constant PFTM_UDP_MULTIPLE_VAL (line 1692) | pub const PFTM_UDP_MULTIPLE_VAL: u32 = 60;
  constant PFTM_ICMP_FIRST_PACKET_VAL (line 1693) | pub const PFTM_ICMP_FIRST_PACKET_VAL: u32 = 20;
  constant PFTM_ICMP_ERROR_REPLY_VAL (line 1694) | pub const PFTM_ICMP_ERROR_REPLY_VAL: u32 = 10;
  constant PFTM_OTHER_FIRST_PACKET_VAL (line 1695) | pub const PFTM_OTHER_FIRST_PACKET_VAL: u32 = 60;
  constant PFTM_OTHER_SINGLE_VAL (line 1696) | pub const PFTM_OTHER_SINGLE_VAL: u32 = 30;
  constant PFTM_OTHER_MULTIPLE_VAL (line 1697) | pub const PFTM_OTHER_MULTIPLE_VAL: u32 = 60;
  constant PFTM_FRAG_VAL (line 1698) | pub const PFTM_FRAG_VAL: u32 = 30;
  constant PFTM_INTERVAL_VAL (line 1699) | pub const PFTM_INTERVAL_VAL: u32 = 10;
  constant PFTM_SRC_NODE_VAL (line 1700) | pub const PFTM_SRC_NODE_VAL: u32 = 0;
  constant PFTM_TS_DIFF_VAL (line 1701) | pub const PFTM_TS_DIFF_VAL: u32 = 30;
  constant PF_POOL_IDMASK (line 1702) | pub const PF_POOL_IDMASK: u32 = 15;
  constant PF_POOL_TYPEMASK (line 1703) | pub const PF_POOL_TYPEMASK: u32 = 15;
  constant PF_POOL_STICKYADDR (line 1704) | pub const PF_POOL_STICKYADDR: u32 = 32;
  constant PF_WSCALE_FLAG (line 1705) | pub const PF_WSCALE_FLAG: u32 = 128;
  constant PF_WSCALE_MASK (line 1706) | pub const PF_WSCALE_MASK: u32 = 15;
  constant PF_LOG (line 1707) | pub const PF_LOG: u32 = 1;
  constant PF_LOG_ALL (line 1708) | pub const PF_LOG_ALL: u32 = 2;
  constant PF_LOG_SOCKET_LOOKUP (line 1709) | pub const PF_LOG_SOCKET_LOOKUP: u32 = 4;
  constant PF_LOG_FORCE (line 1710) | pub const PF_LOG_FORCE: u32 = 8;
  constant PFRES_MATCH (line 1711) | pub const PFRES_MATCH: u32 = 0;
  constant PFRES_BADOFF (line 1712) | pub const PFRES_BADOFF: u32 = 1;
  constant PFRES_FRAG (line 1713) | pub const PFRES_FRAG: u32 = 2;
  constant PFRES_SHORT (line 1714) | pub const PFRES_SHORT: u32 = 3;
  constant PFRES_NORM (line 1715) | pub const PFRES_NORM: u32 = 4;
  constant PFRES_MEMORY (line 1716) | pub const PFRES_MEMORY: u32 = 5;
  constant PFRES_TS (line 1717) | pub const PFRES_TS: u32 = 6;
  constant PFRES_CONGEST (line 1718) | pub const PFRES_CONGEST: u32 = 7;
  constant PFRES_IPOPTIONS (line 1719) | pub const PFRES_IPOPTIONS: u32 = 8;
  constant PFRES_PROTCKSUM (line 1720) | pub const PFRES_PROTCKSUM: u32 = 9;
  constant PFRES_BADSTATE (line 1721) | pub const PFRES_BADSTATE: u32 = 10;
  constant PFRES_STATEINS (line 1722) | pub const PFRES_STATEINS: u32 = 11;
  constant PFRES_MAXSTATES (line 1723) | pub const PFRES_MAXSTATES: u32 = 12;
  constant PFRES_SRCLIMIT (line 1724) | pub const PFRES_SRCLIMIT: u32 = 13;
  constant PFRES_SYNPROXY (line 1725) | pub const PFRES_SYNPROXY: u32 = 14;
  constant PFRES_MAPFAILED (line 1726) | pub const PFRES_MAPFAILED: u32 = 15;
  constant PFRES_MAX (line 1727) | pub const PFRES_MAX: u32 = 16;
  constant LCNT_STATES (line 1728) | pub const LCNT_STATES: u32 = 0;
  constant LCNT_SRCSTATES (line 1729) | pub const LCNT_SRCSTATES: u32 = 1;
  constant LCNT_SRCNODES (line 1730) | pub const LCNT_SRCNODES: u32 = 2;
  constant LCNT_SRCCONN (line 1731) | pub const LCNT_SRCCONN: u32 = 3;
  constant LCNT_SRCCONNRATE (line 1732) | pub const LCNT_SRCCONNRATE: u32 = 4;
  constant LCNT_OVERLOAD_TABLE (line 1733) | pub const LCNT_OVERLOAD_TABLE: u32 = 5;
  constant LCNT_OVERLOAD_FLUSH (line 1734) | pub const LCNT_OVERLOAD_FLUSH: u32 = 6;
  constant LCNT_MAX (line 1735) | pub const LCNT_MAX: u32 = 7;
  constant KLCNT_SYNFLOODS (line 1736) | pub const KLCNT_SYNFLOODS: u32 = 7;
  constant KLCNT_SYNCOOKIES_SENT (line 1737) | pub const KLCNT_SYNCOOKIES_SENT: u32 = 8;
  constant KLCNT_SYNCOOKIES_VALID (line 1738) | pub const KLCNT_SYNCOOKIES_VALID: u32 = 9;
  constant KLCNT_MAX (line 1739) | pub const KLCNT_MAX: u32 = 10;
  constant FCNT_STATE_SEARCH (line 1740) | pub const FCNT_STATE_SEARCH: u32 = 0;
  constant FCNT_STATE_INSERT (line 1741) | pub const FCNT_STATE_INSERT: u32 = 1;
  constant FCNT_STATE_REMOVALS (line 1742) | pub const FCNT_STATE_REMOVALS: u32 = 2;
  constant FCNT_MAX (line 1743) | pub const FCNT_MAX: u32 = 3;
  constant SCNT_SRC_NODE_SEARCH (line 1744) | pub const SCNT_SRC_NODE_SEARCH: u32 = 0;
  constant SCNT_SRC_NODE_INSERT (line 1745) | pub const SCNT_SRC_NODE_INSERT: u32 = 1;
  constant SCNT_SRC_NODE_REMOVALS (line 1746) | pub const SCNT_SRC_NODE_REMOVALS: u32 = 2;
  constant SCNT_MAX (line 1747) | pub const SCNT_MAX: u32 = 3;
  constant PF_TABLE_NAME_SIZE (line 1748) | pub const PF_TABLE_NAME_SIZE: u32 = 32;
  constant PF_QNAME_SIZE (line 1749) | pub const PF_QNAME_SIZE: u32 = 64;
  constant PF_REASS_ENABLED (line 1750) | pub const PF_REASS_ENABLED: u32 = 1;
  constant PF_REASS_NODF (line 1751) | pub const PF_REASS_NODF: u32 = 2;
  constant PFI_AFLAG_NETWORK (line 1752) | pub const PFI_AFLAG_NETWORK: u32 = 1;
  constant PFI_AFLAG_BROADCAST (line 1753) | pub const PFI_AFLAG_BROADCAST: u32 = 2;
  constant PFI_AFLAG_PEER (line 1754) | pub const PFI_AFLAG_PEER: u32 = 4;
  constant PFI_AFLAG_MODEMASK (line 1755) | pub const PFI_AFLAG_MODEMASK: u32 = 7;
  constant PFI_AFLAG_NOALIAS (line 1756) | pub const PFI_AFLAG_NOALIAS: u32 = 8;
  constant PF_OSFP_EXPANDED (line 1757) | pub const PF_OSFP_EXPANDED: u32 = 1;
  constant PF_OSFP_GENERIC (line 1758) | pub const PF_OSFP_GENERIC: u32 = 2;
  constant PF_OSFP_NODETAIL (line 1759) | pub const PF_OSFP_NODETAIL: u32 = 4;
  constant PF_OSFP_LEN (line 1760) | pub const PF_OSFP_LEN: u32 = 32;
  constant _FP_RESERVED_BIT (line 1761) | pub const _FP_RESERVED_BIT: u32 = 1;
  constant _FP_UNUSED_BITS (line 1762) | pub const _FP_UNUSED_BITS: u32 = 1;
  constant _FP_CLASS_BITS (line 1763) | pub const _FP_CLASS_BITS: u32 = 10;
  constant _FP_VERSION_BITS (line 1764) | pub const _FP_VERSION_BITS: u32 = 10;
  constant _FP_SUBTYPE_BITS (line 1765) | pub const _FP_SUBTYPE_BITS: u32 = 10;
  constant PF_OSFP_WSIZE_MOD (line 1766) | pub const PF_OSFP_WSIZE_MOD: u32 = 1;
  constant PF_OSFP_WSIZE_DC (line 1767) | pub const PF_OSFP_WSIZE_DC: u32 = 2;
  constant PF_OSFP_WSIZE_MSS (line 1768) | pub const PF_OSFP_WSIZE_MSS: u32 = 4;
  constant PF_OSFP_WSIZE_MTU (line 1769) | pub const PF_OSFP_WSIZE_MTU: u32 = 8;
  constant PF_OSFP_PSIZE_MOD (line 1770) | pub const PF_OSFP_PSIZE_MOD: u32 = 16;
  constant PF_OSFP_PSIZE_DC (line 1771) | pub const PF_OSFP_PSIZE_DC: u32 = 32;
  constant PF_OSFP_WSCALE (line 1772) | pub const PF_OSFP_WSCALE: u32 = 64;
  constant PF_OSFP_WSCALE_MOD (line 1773) | pub const PF_OSFP_WSCALE_MOD: u32 = 128;
  constant PF_OSFP_WSCALE_DC (line 1774) | pub const PF_OSFP_WSCALE_DC: u32 = 256;
  constant PF_OSFP_MSS (line 1775) | pub const PF_OSFP_MSS: u32 = 512;
  constant PF_OSFP_MSS_MOD (line 1776) | pub const PF_OSFP_MSS_MOD: u32 = 1024;
  constant PF_OSFP_MSS_DC (line 1777) | pub const PF_OSFP_MSS_DC: u32 = 2048;
  constant PF_OSFP_DF (line 1778) | pub const PF_OSFP_DF: u32 = 4096;
  constant PF_OSFP_TS0 (line 1779) | pub const PF_OSFP_TS0: u32 = 8192;
  constant PF_OSFP_INET6 (line 1780) | pub const PF_OSFP_INET6: u32 = 16384;
  constant PF_OSFP_MAXTTL_OFFSET (line 1781) | pub const PF_OSFP_MAXTTL_OFFSET: u32 = 40;
  constant PF_OSFP_TCPOPT_NOP (line 1782) | pub const PF_OSFP_TCPOPT_NOP: u32 = 0;
  constant PF_OSFP_TCPOPT_WSCALE (line 1783) | pub const PF_OSFP_TCPOPT_WSCALE: u32 = 1;
  constant PF_OSFP_TCPOPT_MSS (line 1784) | pub const PF_OSFP_TCPOPT_MSS: u32 = 2;
  constant PF_OSFP_TCPOPT_SACK (line 1785) | pub const PF_OSFP_TCPOPT_SACK: u32 = 3;
  constant PF_OSFP_TCPOPT_TS (line 1786) | pub const PF_OSFP_TCPOPT_TS: u32 = 4;
  constant PF_OSFP_TCPOPT_BITS (line 1787) | pub const PF_OSFP_TCPOPT_BITS: u32 = 3;
  constant PF_ANCHOR_NAME_SIZE (line 1788) | pub const PF_ANCHOR_NAME_SIZE: u32 = 64;
  constant PF_SKIP_IFP (line 1789) | pub const PF_SKIP_IFP: u32 = 0;
  constant PF_SKIP_DIR (line 1790) | pub const PF_SKIP_DIR: u32 = 1;
  constant PF_SKIP_AF (line 1791) | pub const PF_SKIP_AF: u32 = 2;
  constant PF_SKIP_PROTO (line 1792) | pub const PF_SKIP_PROTO: u32 = 3;
  constant PF_SKIP_SRC_ADDR (line 1793) | pub const PF_SKIP_SRC_ADDR: u32 = 4;
  constant PF_SKIP_SRC_PORT (line 1794) | pub const PF_SKIP_SRC_PORT: u32 = 5;
  constant PF_SKIP_DST_ADDR (line 1795) | pub const PF_SKIP_DST_ADDR: u32 = 6;
  constant PF_SKIP_DST_PORT (line 1796) | pub const PF_SKIP_DST_PORT: u32 = 7;
  constant PF_SKIP_COUNT (line 1797) | pub const PF_SKIP_COUNT: u32 = 8;
  constant PF_RULE_LABEL_SIZE (line 1798) | pub const PF_RULE_LABEL_SIZE: u32 = 64;
  constant PF_RULE_MAX_LABEL_COUNT (line 1799) | pub const PF_RULE_MAX_LABEL_COUNT: u32 = 5;
  constant PF_TAG_NAME_SIZE (line 1800) | pub const PF_TAG_NAME_SIZE: u32 = 64;
  constant PF_STATE_NORMAL (line 1801) | pub const PF_STATE_NORMAL: u32 = 1;
  constant PF_STATE_MODULATE (line 1802) | pub const PF_STATE_MODULATE: u32 = 2;
  constant PF_STATE_SYNPROXY (line 1803) | pub const PF_STATE_SYNPROXY: u32 = 3;
  constant PF_FLUSH (line 1804) | pub const PF_FLUSH: u32 = 1;
  constant PF_FLUSH_GLOBAL (line 1805) | pub const PF_FLUSH_GLOBAL: u32 = 2;
  constant PF_PRIO_ZERO (line 1806) | pub const PF_PRIO_ZERO: u32 = 255;
  constant PF_PRIO_MAX (line 1807) | pub const PF_PRIO_MAX: u32 = 7;
  constant PFRULE_DROP (line 1808) | pub const PFRULE_DROP: u32 = 0;
  constant PFRULE_RETURNRST (line 1809) | pub const PFRULE_RETURNRST: u32 = 1;
  constant PFRULE_FRAGMENT (line 1810) | pub const PFRULE_FRAGMENT: u32 = 2;
  constant PFRULE_RETURNICMP (line 1811) | pub const PFRULE_RETURNICMP: u32 = 4;
  constant PFRULE_RETURN (line 1812) | pub const PFRULE_RETURN: u32 = 8;
  constant PFRULE_NOSYNC (line 1813) | pub const PFRULE_NOSYNC: u32 = 16;
  constant PFRULE_SRCTRACK (line 1814) | pub const PFRULE_SRCTRACK: u32 = 32;
  constant PFRULE_RULESRCTRACK (line 1815) | pub const PFRULE_RULESRCTRACK: u32 = 64;
  constant PFRULE_NODF (line 1816) | pub const PFRULE_NODF: u32 = 256;
  constant PFRULE_FRAGMENT_NOREASS (line 1817) | pub const PFRULE_FRAGMENT_NOREASS: u32 = 512;
  constant PFRULE_RANDOMID (line 1818) | pub const PFRULE_RANDOMID: u32 = 2048;
  constant PFRULE_REASSEMBLE_TCP (line 1819) | pub const PFRULE_REASSEMBLE_TCP: u32 = 4096;
  constant PFRULE_SET_TOS (line 1820) | pub const PFRULE_SET_TOS: u32 = 8192;
  constant PFRULE_IFBOUND (line 1821) | pub const PFRULE_IFBOUND: u32 = 65536;
  constant PFRULE_STATESLOPPY (line 1822) | pub const PFRULE_STATESLOPPY: u32 = 131072;
  constant PFRULE_DN_IS_PIPE (line 1823) | pub const PFRULE_DN_IS_PIPE: u32 = 64;
  constant PFRULE_DN_IS_QUEUE (line 1824) | pub const PFRULE_DN_IS_QUEUE: u32 = 128;
  constant PFSTATE_ALLOWOPTS (line 1825) | pub const PFSTATE_ALLOWOPTS: u32 = 1;
  constant PFSTATE_SLOPPY (line 1826) | pub const PFSTATE_SLOPPY: u32 = 2;
  constant PFSTATE_NOSYNC (line 1827) | pub const PFSTATE_NOSYNC: u32 = 8;
  constant PFSTATE_ACK (line 1828) | pub const PFSTATE_ACK: u32 = 16;
  constant PFSTATE_NODF (line 1829) | pub const PFSTATE_NODF: u32 = 32;
  constant PFSTATE_SETTOS (line 1830) | pub const PFSTATE_SETTOS: u32 = 64;
  constant PFSTATE_RANDOMID (line 1831) | pub const PFSTATE_RANDOMID: u32 = 128;
  constant PFSTATE_SCRUB_TCP (line 1832) | pub const PFSTATE_SCRUB_TCP: u32 = 256;
  constant PFSTATE_SETPRIO (line 1833) | pub const PFSTATE_SETPRIO: u32 = 512;
  constant PFSTATE_DN_IS_PIPE (line 1834) | pub const PFSTATE_DN_IS_PIPE: u32 = 16384;
  constant PFSTATE_DN_IS_QUEUE (line 1835) | pub const PFSTATE_DN_IS_QUEUE: u32 = 32768;
  constant PFSTATE_SCRUBMASK (line 1836) | pub const PFSTATE_SCRUBMASK: u32 = 416;
  constant PFSTATE_SETMASK (line 1837) | pub const PFSTATE_SETMASK: u32 = 576;
  constant PFSTATE_HIWAT (line 1838) | pub const PFSTATE_HIWAT: u32 = 100000;
  constant PFSTATE_ADAPT_START (line 1839) | pub const PFSTATE_ADAPT_START: u32 = 60000;
  constant PFSTATE_ADAPT_END (line 1840) | pub const PFSTATE_ADAPT_END: u32 = 120000;
  constant PF_THRESHOLD_MULT (line 1841) | pub const PF_THRESHOLD_MULT: u32 = 1000;
  constant PF_THRESHOLD_MAX (line 1842) | pub const PF_THRESHOLD_MAX: u32 = 4294967;
  constant PFSNODE_HIWAT (line 1843) | pub const PFSNODE_HIWAT: u32 = 10000;
  constant PFALTQ_FLAG_IF_REMOVED (line 1844) | pub const PFALTQ_FLAG_IF_REMOVED: u32 = 1;
  constant PF_ALTQ_VERSION (line 1845) | pub const PF_ALTQ_VERSION: u32 = 1;
  constant PFSS_TIMESTAMP (line 1846) | pub const PFSS_TIMESTAMP: u32 = 1;
  constant PFSS_PAWS (line 1847) | pub const PFSS_PAWS: u32 = 16;
  constant PFSS_PAWS_IDLED (line 1848) | pub const PFSS_PAWS_IDLED: u32 = 32;
  constant PFSS_DATA_TS (line 1849) | pub const PFSS_DATA_TS: u32 = 64;
  constant PFSS_DATA_NOTS (line 1850) | pub const PFSS_DATA_NOTS: u32 = 128;
  constant PF_SCRUB_FLAG_VALID (line 1851) | pub const PF_SCRUB_FLAG_VALID: u32 = 1;
  constant PF_STATE_VERSION (line 1852) | pub const PF_STATE_VERSION: u32 = 20230404;
  constant PFSYNC_SCRUB_FLAG_VALID (line 1853) | pub const PFSYNC_SCRUB_FLAG_VALID: u32 = 1;
  constant PFSYNC_FLAG_SRCNODE (line 1854) | pub const PFSYNC_FLAG_SRCNODE: u32 = 4;
  constant PFSYNC_FLAG_NATSRCNODE (line 1855) | pub const PFSYNC_FLAG_NATSRCNODE: u32 = 8;
  constant PF_RESERVED_ANCHOR (line 1856) | pub const PF_RESERVED_ANCHOR: &[u8; 4] = b"_pf\0";
  constant PFR_TFLAG_PERSIST (line 1857) | pub const PFR_TFLAG_PERSIST: u32 = 1;
  constant PFR_TFLAG_CONST (line 1858) | pub const PFR_TFLAG_CONST: u32 = 2;
  constant PFR_TFLAG_ACTIVE (line 1859) | pub const PFR_TFLAG_ACTIVE: u32 = 4;
  constant PFR_TFLAG_INACTIVE (line 1860) | pub const PFR_TFLAG_INACTIVE: u32 = 8;
  constant PFR_TFLAG_REFERENCED (line 1861) | pub const PFR_TFLAG_REFERENCED: u32 = 16;
  constant PFR_TFLAG_REFDANCHOR (line 1862) | pub const PFR_TFLAG_REFDANCHOR: u32 = 32;
  constant PFR_TFLAG_COUNTERS (line 1863) | pub const PFR_TFLAG_COUNTERS: u32 = 64;
  constant PFR_TFLAG_USRMASK (line 1864) | pub const PFR_TFLAG_USRMASK: u32 = 67;
  constant PFR_TFLAG_SETMASK (line 1865) | pub const PFR_TFLAG_SETMASK: u32 = 60;
  constant PFR_TFLAG_ALLMASK (line 1866) | pub const PFR_TFLAG_ALLMASK: u32 = 127;
  constant PFI_IFLAG_REFS (line 1867) | pub const PFI_IFLAG_REFS: u32 = 1;
  constant PFI_IFLAG_SKIP (line 1868) | pub const PFI_IFLAG_SKIP: u32 = 256;
  constant PF_DPORT_RANGE (line 1869) | pub const PF_DPORT_RANGE: u32 = 1;
  constant PF_RPORT_RANGE (line 1870) | pub const PF_RPORT_RANGE: u32 = 2;
  constant PFUDPS_NO_TRAFFIC (line 1871) | pub const PFUDPS_NO_TRAFFIC: u32 = 0;
  constant PFUDPS_SINGLE (line 1872) | pub const PFUDPS_SINGLE: u32 = 1;
  constant PFUDPS_MULTIPLE (line 1873) | pub const PFUDPS_MULTIPLE: u32 = 2;
  constant PFUDPS_NSTATES (line 1874) | pub const PFUDPS_NSTATES: u32 = 3;
  constant PFOTHERS_NO_TRAFFIC (line 1875) | pub const PFOTHERS_NO_TRAFFIC: u32 = 0;
  constant PFOTHERS_SINGLE (line 1876) | pub const PFOTHERS_SINGLE: u32 = 1;
  constant PFOTHERS_MULTIPLE (line 1877) | pub const PFOTHERS_MULTIPLE: u32 = 2;
  constant PFOTHERS_NSTATES (line 1878) | pub const PFOTHERS_NSTATES: u32 = 3;
  constant PF_SYNCOOKIES_HIWATPCT (line 1879) | pub const PF_SYNCOOKIES_HIWATPCT: u32 = 25;
  constant PF_SYNCOOKIES_LOWATPCT (line 1880) | pub const PF_SYNCOOKIES_LOWATPCT: u32 = 12;
  constant PFFRAG_FRENT_HIWAT (line 1881) | pub const PFFRAG_FRENT_HIWAT: u32 = 5000;
  constant PFR_KENTRY_HIWAT (line 1882) | pub const PFR_KENTRY_HIWAT: u32 = 200000;
  constant PF_FRAG_ENTRY_POINTS (line 1883) | pub const PF_FRAG_ENTRY_POINTS: u32 = 16;
  constant PF_FRAG_ENTRY_LIMIT (line 1884) | pub const PF_FRAG_ENTRY_LIMIT: u32 = 64;
  constant PFIOC_ALTQ_VERSION (line 1885) | pub const PFIOC_ALTQ_VERSION: u32 = 1;
  constant PFIOC_QSTATS_VERSION (line 1886) | pub const PFIOC_QSTATS_VERSION: u32 = 1;
  constant PFR_FLAG_ATOMIC (line 1887) | pub const PFR_FLAG_ATOMIC: u32 = 1;
  constant PFR_FLAG_DUMMY (line 1888) | pub const PFR_FLAG_DUMMY: u32 = 2;
  constant PFR_FLAG_FEEDBACK (line 1889) | pub const PFR_FLAG_FEEDBACK: u32 = 4;
  constant PFR_FLAG_CLSTATS (line 1890) | pub const PFR_FLAG_CLSTATS: u32 = 8;
  constant PFR_FLAG_ADDRSTOO (line 1891) | pub const PFR_FLAG_ADDRSTOO: u32 = 16;
  constant PFR_FLAG_REPLACE (line 1892) | pub const PFR_FLAG_REPLACE: u32 = 32;
  constant PFR_FLAG_ALLRSETS (line 1893) | pub const PFR_FLAG_ALLRSETS: u32 = 64;
  constant PFR_FLAG_ALLMASK (line 1894) | pub const PFR_FLAG_ALLMASK: u32 = 127;
  constant PF_IFSPEED_VERSION (line 1895) | pub const PF_IFSPEED_VERSION: u32 = 1;
  type __int8_t (line 1896) | pub type __int8_t = ::std::os::raw::c_schar;
  type __uint8_t (line 1897) | pub type __uint8_t = ::std::os::raw::c_uchar;
  type __int16_t (line 1898) | pub type __int16_t = ::std::os::raw::c_short;
  type __uint16_t (line 1899) | pub type __uint16_t = ::std::os::raw::c_ushort;
  type __int32_t (line 1900) | pub type __int32_t = ::std::os::raw::c_int;
  type __uint32_t (line 1901) | pub type __uint32_t = ::std::os::raw::c_uint;
  type __int64_t (line 1902) | pub type __int64_t = ::std::os::raw::c_long;
  type __uint64_t (line 1903) | pub type __uint64_t = ::std::os::raw::c_ulong;
  type __int_least8_t (line 1904) | pub type __int_least8_t = __int8_t;
  type __int_least16_t (line 1905) | pub type __int_least16_t = __int16_t;
  type __int_least32_t (line 1906) | pub type __int_least32_t = __int32_t;
  type __int_least64_t (line 1907) | pub type __int_least64_t = __int64_t;
  type __intmax_t (line 1908) | pub type __intmax_t = __int64_t;
  type __uint_least8_t (line 1909) | pub type __uint_least8_t = __uint8_t;
  type __uint_least16_t (line 1910) | pub type __uint_least16_t = __uint16_t;
  type __uint_least32_t (line 1911) | pub type __uint_least32_t = __uint32_t;
  type __uint_least64_t (line 1912) | pub type __uint_least64_t = __uint64_t;
  type __uintmax_t (line 1913) | pub type __uintmax_t = __uint64_t;
  type __intptr_t (line 1914) | pub type __intptr_t = __int64_t;
  type __intfptr_t (line 1915) | pub type __intfptr_t = __int64_t;
  type __uintptr_t (line 1916) | pub type __uintptr_t = __uint64_t;
  type __uintfptr_t (line 1917) | pub type __uintfptr_t = __uint64_t;
  type __vm_offset_t (line 1918) | pub type __vm_offset_t = __uint64_t;
  type __vm_size_t (line 1919) | pub type __vm_size_t = __uint64_t;
  type __size_t (line 1920) | pub type __size_t = __uint64_t;
  type __ssize_t (line 1921) | pub type __ssize_t = __int64_t;
  type __ptrdiff_t (line 1922) | pub type __ptrdiff_t = __int64_t;
  type __clock_t (line 1923) | pub type __clock_t = __int32_t;
  type __critical_t (line 1924) | pub type __critical_t = __int64_t;
  type __double_t (line 1925) | pub type __double_t = f64;
  type __float_t (line 1926) | pub type __float_t = f32;
  type __int_fast8_t (line 1927) | pub type __int_fast8_t = __int32_t;
  type __int_fast16_t (line 1928) | pub type __int_fast16_t = __int32_t;
  type __int_fast32_t (line 1929) | pub type __int_fast32_t = __int32_t;
  type __int_fast64_t (line 1930) | pub type __int_fast64_t = __int64_t;
  type __register_t (line 1931) | pub type __register_t = __int64_t;
  type __segsz_t (line 1932) | pub type __segsz_t = __int64_t;
  type __time_t (line 1933) | pub type __time_t = __int64_t;
  type __uint_fast8_t (line 1934) | pub type __uint_fast8_t = __uint32_t;
  type __uint_fast16_t (line 1935) | pub type __uint_fast16_t = __uint32_t;
  type __uint_fast32_t (line 1936) | pub type __uint_fast32_t = __uint32_t;
  type __uint_fast64_t (line 1937) | pub type __uint_fast64_t = __uint64_t;
  type __u_register_t (line 1938) | pub type __u_register_t = __uint64_t;
  type __vm_paddr_t (line 1939) | pub type __vm_paddr_t = __uint64_t;
  type ___wchar_t (line 1940) | pub type ___wchar_t = ::std::os::raw::c_int;
  type __blksize_t (line 1941) | pub type __blksize_t = __int32_t;
  type __blkcnt_t (line 1942) | pub type __blkcnt_t = __int64_t;
  type __clockid_t (line 1943) | pub type __clockid_t = __int32_t;
  type __fflags_t (line 1944) | pub type __fflags_t = __uint32_t;
  type __fsblkcnt_t (line 1945) | pub type __fsblkcnt_t = __uint64_t;
  type __fsfilcnt_t (line 1946) | pub type __fsfilcnt_t = __uint64_t;
  type __gid_t (line 1947) | pub type __gid_t = __uint32_t;
  type __id_t (line 1948) | pub type __id_t = __int64_t;
  type __ino_t (line 1949) | pub type __ino_t = __uint64_t;
  type __key_t (line 1950) | pub type __key_t = ::std::os::raw::c_long;
  type __lwpid_t (line 1951) | pub type __lwpid_t = __int32_t;
  type __mode_t (line 1952) | pub type __mode_t = __uint16_t;
  type __accmode_t (line 1953) | pub type __accmode_t = ::std::os::raw::c_int;
  type __nl_item (line 1954) | pub type __nl_item = ::std::os::raw::c_int;
  type __nlink_t (line 1955) | pub type __nlink_t = __uint64_t;
  type __off_t (line 1956) | pub type __off_t = __int64_t;
  type __off64_t (line 1957) | pub type __off64_t = __int64_t;
  type __pid_t (line 1958) | pub type __pid_t = __int32_t;
  type __sbintime_t (line 1959) | pub type __sbintime_t = __int64_t;
  type __rlim_t (line 1960) | pub type __rlim_t = __int64_t;
  type __sa_family_t (line 1961) | pub type __sa_family_t = __uint8_t;
  type __socklen_t (line 1962) | pub type __socklen_t = __uint32_t;
  type __suseconds_t (line 1963) | pub type __suseconds_t = ::std::os::raw::c_long;
  type __timer (line 1966) | pub struct __timer {
  type __timer_t (line 1969) | pub type __timer_t = *mut __timer;
  type __mq (line 1972) | pub struct __mq {
  type __mqd_t (line 1975) | pub type __mqd_t = *mut __mq;
  type __uid_t (line 1976) | pub type __uid_t = __uint32_t;
  type __useconds_t (line 1977) | pub type __useconds_t = ::std::os::raw::c_uint;
  type __cpuwhich_t (line 1978) | pub type __cpuwhich_t = ::std::os::raw::c_int;
  type __cpulevel_t (line 1979) | pub type __cpulevel_t = ::std::os::raw::c_int;
  type __cpusetid_t (line 1980) | pub type __cpusetid_t = ::std::os::raw::c_int;
  type __daddr_t (line 1981) | pub type __daddr_t = __int64_t;
  type __ct_rune_t (line 1982) | pub type __ct_rune_t = ::std::os::raw::c_int;
  type __rune_t (line 1983) | pub type __rune_t = __ct_rune_t;
  type __wint_t (line 1984) | pub type __wint_t = __ct_rune_t;
  type __char16_t (line 1985) | pub type __char16_t = __uint_least16_t;
  type __char32_t (line 1986) | pub type __char32_t = __uint_least32_t;
  type __max_align_t (line 1990) | pub struct __max_align_t {
  function bindgen_test_layout___max_align_t (line 1996) | fn bindgen_test_layout___max_align_t() {
  type __dev_t (line 2030) | pub type __dev_t = __uint64_t;
  type __fixpt_t (line 2031) | pub type __fixpt_t = __uint32_t;
  function bindgen_test_layout___mbstate_t (line 2039) | fn bindgen_test_layout___mbstate_t() {
  type __rman_res_t (line 2073) | pub type __rman_res_t = __uintmax_t;
  type __va_list (line 2074) | pub type __va_list = __builtin_va_list;
  type __gnuc_va_list (line 2075) | pub type __gnuc_va_list = __va_list;
  type pthread (line 2078) | pub struct pthread {
  type pthread_attr (line 2083) | pub struct pthread_attr {
  type pthread_cond (line 2088) | pub struct pthread_cond {
  type pthread_cond_attr (line 2093) | pub struct pthread_cond_attr {
  type pthread_mutex (line 2098) | pub struct pthread_mutex {
  type pthread_mutex_attr (line 2103) | pub struct pthread_mutex_attr {
  type pthread_rwlock (line 2108) | pub struct pthread_rwlock {
  type pthread_rwlockattr (line 2113) | pub struct pthread_rwlockattr {
  type pthread_barrier (line 2118) | pub struct pthread_barrier {
  type pthread_barrier_attr (line 2123) | pub struct pthread_barrier_attr {
  type pthread_spinlock (line 2128) | pub struct pthread_spinlock {
  type pthread_t (line 2131) | pub type pthread_t = *mut pthread;
  type pthread_attr_t (line 2132) | pub type pthread_attr_t = *mut pthread_attr;
  type pthread_mutex_t (line 2133) | pub type pthread_mutex_t = *mut pthread_mutex;
  type pthread_mutexattr_t (line 2134) | pub type pthread_mutexattr_t = *mut pthread_mutex_attr;
  type pthread_cond_t (line 2135) | pub type pthread_cond_t = *mut pthread_cond;
  type pthread_condattr_t (line 2136) | pub type pthread_condattr_t = *mut pthread_cond_attr;
  type pthread_key_t (line 2137) | pub type pthread_key_t = ::std::os::raw::c_int;
  type pthread_once_t (line 2138) | pub type pthread_once_t = pthread_once;
  type pthread_rwlock_t (line 2139) | pub type pthread_rwlock_t = *mut pthread_rwlock;
  type pthread_rwlockattr_t (line 2140) | pub type pthread_rwlockattr_t 
Condensed preview — 282 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3,647K chars).
[
  {
    "path": ".circleci/config.yml",
    "chars": 10210,
    "preview": "version: 2.1\n\norbs:\n    windows: circleci/windows@5.1.1\n\njobs:\n    build-linux:\n        docker:\n            - image: cir"
  },
  {
    "path": ".dockerignore",
    "chars": 67,
    "preview": "**/.git\n.circleci\n.devcontainer\n.github\n.ssh\n.vscode\n**/target\ndev\n"
  },
  {
    "path": ".github/dependabot.yml",
    "chars": 127,
    "preview": "version: 2\nupdates:\n- package-ecosystem: cargo\n  directory: \"/\"\n  schedule:\n    interval: weekly\n  open-pull-requests-li"
  },
  {
    "path": ".github/workflows/build-and-test.yml",
    "chars": 2712,
    "preview": "name: Build & Test\n\non: [push, pull_request]\n\nenv:\n  CARGO_TERM_COLOR: always\n  RUST_LOG: \"trace\"\n\njobs:\n  build-and-tes"
  },
  {
    "path": ".github/workflows/build-docker-image.yml",
    "chars": 1044,
    "preview": "name: Build Docker Images\non:\n  push:\n    tags:\n      - v*\n  workflow_dispatch:\n\njobs:\n  build-docker-image:\n    runs-on"
  },
  {
    "path": ".github/workflows/build-msrv.yml",
    "chars": 3611,
    "preview": "name: Build MSRV\n\non: [push, pull_request]\n\nenv:\n  CARGO_TERM_COLOR: always\n  RUST_LOG: \"trace\"\n\njobs:\n  build-msrv-shad"
  },
  {
    "path": ".github/workflows/build-nightly-release.yml",
    "chars": 5126,
    "preview": "name: Build Nightly Releases\non:\n  push:\n    branches: [master]\n  workflow_dispatch:\n\nenv:\n  CARGO_TERM_COLOR: always\n\nj"
  },
  {
    "path": ".github/workflows/build-release.yml",
    "chars": 7112,
    "preview": "name: Build Releases\non:\n  push:\n    tags:\n      - v*\n  workflow_dispatch:\n    inputs:\n      tag:\n        description: '"
  },
  {
    "path": ".github/workflows/clippy-check.yml",
    "chars": 897,
    "preview": "name: Clippy Check\n\non: [push, pull_request]\n\nenv:\n  CARGO_TERM_COLOR: always\n  RUST_LOG: \"trace\"\n\njobs:\n  clippy-check:"
  },
  {
    "path": ".github/workflows/deny-check.yml",
    "chars": 473,
    "preview": "name: Cargo Deny Check\non: [push, pull_request]\njobs:\n  deny-check:\n    runs-on: ubuntu-latest\n    strategy:\n      matri"
  },
  {
    "path": ".gitignore",
    "chars": 174,
    "preview": "target\n/build/release\n/build/target\n/build/install\n/build/*.sha256\n/dev\n/*.log\n/debian/*.log\n/.vscode\n/*.json\n/restart.s"
  },
  {
    "path": ".travis.yml",
    "chars": 1954,
    "preview": "sudo: false\nlanguage: rust\njobs:\n  include:\n    - os: windows\n      rust: stable\n\n    - os: osx\n      rust: stable\n     "
  },
  {
    "path": "Cargo.toml",
    "chars": 7273,
    "preview": "[package]\nname = \"shadowsocks-rust\"\nversion = \"1.24.0\"\nauthors = [\"Shadowsocks Contributors\"]\ndescription = \"shadowsocks"
  },
  {
    "path": "Cross-centos.toml",
    "chars": 373,
    "preview": "[build.env]\npassthrough = [\"RUSTFLAGS\"]\n\n# WARN: GCC 4.8.2 doesn't support <stdatomic.h>\n[target.x86_64-unknown-linux-gn"
  },
  {
    "path": "Cross.toml",
    "chars": 1380,
    "preview": "[build]\n# dockerfile = \"./docker/linux-cross/Dockerfile\"\n# pre-build = [\n#     \"curl --proto '=https' --tlsv1.2 -sSf htt"
  },
  {
    "path": "Dockerfile",
    "chars": 2513,
    "preview": "FROM --platform=$BUILDPLATFORM rust:1.94.0-alpine3.22 AS builder\n\nARG TARGETARCH\n\nRUN set -x \\\n    && apk add --no-cache"
  },
  {
    "path": "LICENSE",
    "chars": 1099,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2017 Y. T. CHUNG <zonyitoo@gmail.com>\n\nPermission is hereby granted, free of charge"
  },
  {
    "path": "Makefile",
    "chars": 801,
    "preview": "PREFIX ?= /usr/local/bin\nTARGET ?= debug\n\n.PHONY: all build install uninstall clean\nall: build\n\nbuild:\nifeq (${TARGET}, "
  },
  {
    "path": "README.md",
    "chars": 46845,
    "preview": "# shadowsocks\n\n[![License](https://img.shields.io/github/license/zonyitoo/shadowsocks-rust.svg)](https://github.com/zony"
  },
  {
    "path": "acl/genacl_proxy_gfw_bypass_china_ip.py",
    "chars": 2008,
    "preview": "#!/usr/bin/env python3\n\nfrom urllib import request, parse\nimport logging\nimport sys\nimport json\nfrom datetime import dat"
  },
  {
    "path": "appveyor.yml",
    "chars": 773,
    "preview": "environment:\n  SSL_CERT_FILE: \"C:\\\\OpenSSL\\\\cacert.pem\"\n\n  matrix:\n    - TARGET: x86_64-pc-windows-msvc\n      BITS: 64\n "
  },
  {
    "path": "bin/sslocal.rs",
    "chars": 676,
    "preview": "//! This is a binary running in the local environment\n//!\n//! You have to provide all needed configuration attributes vi"
  },
  {
    "path": "bin/ssmanager.rs",
    "chars": 791,
    "preview": "//! This is a binary running in the server environment\n//!\n//! You have to provide all needed configuration attributes v"
  },
  {
    "path": "bin/ssserver.rs",
    "chars": 788,
    "preview": "//! This is a binary running in the server environment\n//!\n//! You have to provide all needed configuration attributes v"
  },
  {
    "path": "bin/ssservice.rs",
    "chars": 2316,
    "preview": "//! This is a binary running in both local and server environment\n//!\n//! You have to provide all needed configuration a"
  },
  {
    "path": "bin/ssurl.rs",
    "chars": 4824,
    "preview": "//! SIP002 and SIP008 URL Schemes\n//!\n//! SS-URI = \"ss://\" userinfo \"@\" hostname \":\" port [ \"/\" ] [ \"?\" plugin ] [ \"#\" t"
  },
  {
    "path": "bin/sswinservice.rs",
    "chars": 7073,
    "preview": "use std::{\n    ffi::OsString,\n    future::Future,\n    sync::atomic::{AtomicU32, Ordering},\n    time::Duration,\n};\n\nuse c"
  },
  {
    "path": "build/README.md",
    "chars": 523,
    "preview": "## Build Standalone Binaries\n\n### Build with `cross`\n\n- Install [`cross`](https://github.com/rust-embedded/cross)\n\n```ba"
  },
  {
    "path": "build/build-host-release",
    "chars": 2957,
    "preview": "#!/bin/bash\n\nBUILD_TARGET=\"\"\nBUILD_FEATURES=()\nwhile getopts \"t:f:\" opt; do\n    case $opt in\n        t)\n            BUIL"
  },
  {
    "path": "build/build-host-release.ps1",
    "chars": 1984,
    "preview": "#!pwsh\n<#\n    OpenSSL is already installed on windows-latest virtual environment.\n    If you need OpenSSL, consider inst"
  },
  {
    "path": "build/build-release",
    "chars": 3654,
    "preview": "#!/bin/bash\n\nCUR_DIR=$( cd $( dirname $0 ) && pwd )\nVERSION=$(grep -E '^version' ${CUR_DIR}/../Cargo.toml | awk '{print "
  },
  {
    "path": "cargo-publish.sh",
    "chars": 565,
    "preview": "#!/bin/bash -e\n\nset -x\n\nROOT_DIR=$(dirname $0)\ncd ${ROOT_DIR:?}\n\npackage_ordered=\"crates/shadowsocks crates/shadowsocks-"
  },
  {
    "path": "clippy.toml",
    "chars": 14,
    "preview": "msrv = \"1.88\"\n"
  },
  {
    "path": "configs/genipset.py",
    "chars": 2787,
    "preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\nimport sys\nimport time\n\n\nAPNIC_DELEGATED_LATEST = \"https://ftp.apnic.net/a"
  },
  {
    "path": "configs/iptables_mixed.sh",
    "chars": 8369,
    "preview": "#!/bin/bash\n\niptables-save | grep -v shadowsocks- | iptables-restore\nip6tables-save | grep -v shadowsocks- | ip6tables-r"
  },
  {
    "path": "configs/iptables_tproxy.sh",
    "chars": 8254,
    "preview": "#!/bin/bash\n\niptables-save | grep -v shadowsocks- | iptables-restore\nip6tables-save | grep -v shadowsocks- | ip6tables-r"
  },
  {
    "path": "configs/log4rs.yaml",
    "chars": 465,
    "preview": "refresh_rate: 30 seconds\nappenders:\n  stdout:\n    kind: console\n    encoder:\n      pattern: \"{d} {h({l}):<5} {m}{n}\"\n  f"
  },
  {
    "path": "configs/org.shadowsocks.shadowsocks-rust.plist",
    "chars": 1101,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
  },
  {
    "path": "configs/shadowsocks.procd.sh",
    "chars": 5364,
    "preview": "#!/bin/sh /etc/rc.common\n\nSTART=30\n\nUSE_PROCD=1\n\nEXTRA_COMMANDS=\"set_firewall destroy\"\nEXTRA_HELP=<<EOF\n\tset_firewall Se"
  },
  {
    "path": "crates/shadowsocks/Cargo.toml",
    "chars": 3350,
    "preview": "[package]\nname = \"shadowsocks\"\nversion = \"1.24.0\"\nauthors = [\"Shadowsocks Contributors\"]\ndescription = \"shadowsocks is a"
  },
  {
    "path": "crates/shadowsocks/LICENSE",
    "chars": 1099,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2017 Y. T. CHUNG <zonyitoo@gmail.com>\n\nPermission is hereby granted, free of charge"
  },
  {
    "path": "crates/shadowsocks/README.md",
    "chars": 477,
    "preview": "# shadowsocks\n\n[![License](https://img.shields.io/github/license/zonyitoo/shadowsocks-rust.svg)](https://github.com/zony"
  },
  {
    "path": "crates/shadowsocks/src/config.rs",
    "chars": 41769,
    "preview": "//! Configuration\n\n#[cfg(unix)]\nuse std::path::PathBuf;\nuse std::{\n    collections::HashMap,\n    fmt::{self, Debug, Disp"
  },
  {
    "path": "crates/shadowsocks/src/context.rs",
    "chars": 5169,
    "preview": "//! Shadowsocks service context\n\nuse std::{io, net::SocketAddr, sync::Arc};\n\nuse byte_string::ByteStr;\nuse log::warn;\n\nu"
  },
  {
    "path": "crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs",
    "chars": 6658,
    "preview": "//! Asynchronous DNS resolver\n\nuse std::{\n    future::Future,\n    io,\n    net::SocketAddr,\n    ops::Deref,\n    pin::Pin,"
  },
  {
    "path": "crates/shadowsocks/src/dns_resolver/mod.rs",
    "chars": 7521,
    "preview": "//! Asynchronous DNS resolver\n#![macro_use]\n\npub use self::resolver::{DnsResolve, DnsResolver};\n\n#[cfg(feature = \"hickor"
  },
  {
    "path": "crates/shadowsocks/src/dns_resolver/resolver.rs",
    "chars": 14389,
    "preview": "//! Resolver Alternatives\n\n#[cfg(feature = \"hickory-dns\")]\nuse std::sync::Arc;\nuse std::{\n    fmt::{self, Debug},\n    io"
  },
  {
    "path": "crates/shadowsocks/src/lib.rs",
    "chars": 492,
    "preview": "//! Shadowsocks Core Library\n\n#![crate_type = \"lib\"]\n\npub use self::{\n    config::{ManagerAddr, ServerAddr, ServerConfig"
  },
  {
    "path": "crates/shadowsocks/src/manager/client.rs",
    "chars": 2173,
    "preview": "//! Manager client\n\nuse log::warn;\n\nuse crate::{config::ManagerAddr, context::Context, net::ConnectOpts, relay::udprelay"
  },
  {
    "path": "crates/shadowsocks/src/manager/datagram.rs",
    "chars": 7717,
    "preview": "//! Shadowsocks manager connecting interface\n\n#[cfg(unix)]\nuse std::io::ErrorKind;\nuse std::{fmt, io, net::SocketAddr};\n"
  },
  {
    "path": "crates/shadowsocks/src/manager/error.rs",
    "chars": 480,
    "preview": "//! Manager API errors\n\nuse std::io;\n\nuse thiserror::Error;\n\nuse super::protocol::Error as ProtocolError;\n\n/// Manager E"
  },
  {
    "path": "crates/shadowsocks/src/manager/listener.rs",
    "chars": 1440,
    "preview": "//! Manager server listener\n\nuse std::io;\n\nuse log::warn;\n\nuse crate::{config::ManagerAddr, context::Context, relay::udp"
  },
  {
    "path": "crates/shadowsocks/src/manager/mod.rs",
    "chars": 332,
    "preview": "//! Shadowsocks Server manager\n//!\n//! Service for managing multiple relay servers. [Manage Multiple Users](https://gith"
  },
  {
    "path": "crates/shadowsocks/src/manager/protocol.rs",
    "chars": 10411,
    "preview": "//! Shadowsocks server manager protocol\n\nuse std::{collections::HashMap, io, str, string::ToString};\n\nuse serde::{Deseri"
  },
  {
    "path": "crates/shadowsocks/src/net/mod.rs",
    "chars": 1332,
    "preview": "//! Network wrappers for shadowsocks' specific requirements\n\nuse std::net::SocketAddr;\n\n#[cfg(unix)]\npub use self::sys::"
  },
  {
    "path": "crates/shadowsocks/src/net/option.rs",
    "chars": 5253,
    "preview": "//! Options for connecting to remote server\n\nuse std::{net::SocketAddr, time::Duration};\n\n/// Options for connecting to "
  },
  {
    "path": "crates/shadowsocks/src/net/sys/mod.rs",
    "chars": 5981,
    "preview": "use std::{\n    io::{self, ErrorKind},\n    net::{Ipv4Addr, Ipv6Addr, SocketAddr},\n    sync::LazyLock,\n};\n\nuse cfg_if::cfg"
  },
  {
    "path": "crates/shadowsocks/src/net/sys/unix/bsd/freebsd.rs",
    "chars": 14133,
    "preview": "use std::{\n    io::{self, ErrorKind},\n    mem,\n    net::{Ipv4Addr, Ipv6Addr, SocketAddr},\n    os::unix::io::{AsRawFd, Ra"
  },
  {
    "path": "crates/shadowsocks/src/net/sys/unix/bsd/macos.rs",
    "chars": 19258,
    "preview": "use std::{\n    cell::RefCell,\n    collections::HashMap,\n    io::{self, ErrorKind},\n    mem,\n    net::{Ipv4Addr, Ipv6Addr"
  },
  {
    "path": "crates/shadowsocks/src/net/sys/unix/bsd/mod.rs",
    "chars": 361,
    "preview": "use cfg_if::cfg_if;\n\ncfg_if! {\n    if #[cfg(target_os = \"freebsd\")] {\n        mod freebsd;\n        pub use self::freebsd"
  },
  {
    "path": "crates/shadowsocks/src/net/sys/unix/bsd/others.rs",
    "chars": 26,
    "preview": "include!(\"../others.rs\");\n"
  },
  {
    "path": "crates/shadowsocks/src/net/sys/unix/linux/mod.rs",
    "chars": 19668,
    "preview": "use std::{\n    io::{self, ErrorKind},\n    mem,\n    net::{Ipv4Addr, Ipv6Addr, SocketAddr},\n    os::unix::io::{AsRawFd, Fr"
  },
  {
    "path": "crates/shadowsocks/src/net/sys/unix/mod.rs",
    "chars": 4545,
    "preview": "use std::{io, net::SocketAddr, os::fd::AsFd};\n\nuse cfg_if::cfg_if;\nuse log::warn;\nuse socket2::{Domain, Protocol, SockRe"
  },
  {
    "path": "crates/shadowsocks/src/net/sys/unix/others.rs",
    "chars": 4105,
    "preview": "use std::{\n    io::{self, ErrorKind},\n    net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},\n    ops::{Deref, DerefMut},\n   "
  },
  {
    "path": "crates/shadowsocks/src/net/sys/unix/uds.rs",
    "chars": 4051,
    "preview": "//! Android specific features\n\nuse std::{\n    io::{self, ErrorKind},\n    os::unix::io::RawFd,\n    path::Path,\n    pin::P"
  },
  {
    "path": "crates/shadowsocks/src/net/sys/windows/mod.rs",
    "chars": 19660,
    "preview": "use std::{\n    cell::RefCell,\n    collections::HashMap,\n    ffi::{CStr, CString, OsString, c_void},\n    io::{self, Error"
  },
  {
    "path": "crates/shadowsocks/src/net/tcp.rs",
    "chars": 7240,
    "preview": "//! TcpStream wrappers that supports connecting with options\n\n#[cfg(unix)]\nuse std::os::unix::io::{AsRawFd, RawFd};\n#[cf"
  },
  {
    "path": "crates/shadowsocks/src/net/udp.rs",
    "chars": 11982,
    "preview": "//! UDP socket wrappers\n\n#[cfg(any(\n    target_os = \"linux\",\n    target_os = \"android\",\n    target_os = \"macos\",\n    tar"
  },
  {
    "path": "crates/shadowsocks/src/plugin/mod.rs",
    "chars": 8075,
    "preview": "//! Plugin (SIP003)\n//!\n//! ```plain\n//! +------------+                    +---------------------------+\n//! |  SS Clien"
  },
  {
    "path": "crates/shadowsocks/src/plugin/obfs_proxy.rs",
    "chars": 1918,
    "preview": "use super::{PluginConfig, PluginMode};\nuse crate::config::ServerAddr;\nuse std::{net::SocketAddr, process::Stdio};\nuse to"
  },
  {
    "path": "crates/shadowsocks/src/plugin/ss_plugin.rs",
    "chars": 965,
    "preview": "use super::{PluginConfig, PluginMode};\nuse crate::config::ServerAddr;\nuse log::trace;\nuse std::{net::SocketAddr, process"
  },
  {
    "path": "crates/shadowsocks/src/relay/mod.rs",
    "chars": 773,
    "preview": "//! Relay server in local and server side implementations.\n\npub use self::socks5::Address;\n\npub mod socks5;\npub mod tcpr"
  },
  {
    "path": "crates/shadowsocks/src/relay/socks5.rs",
    "chars": 30028,
    "preview": "//! Socks5 protocol definition (RFC1928)\n//!\n//! Implements [SOCKS Protocol Version 5](https://www.ietf.org/rfc/rfc1928."
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/aead.rs",
    "chars": 13488,
    "preview": "//! AEAD packet I/O facilities\n//!\n//! AEAD protocol is defined in <https://shadowsocks.org/doc/aead.html>.\n//!\n//! ```p"
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/aead_2022.rs",
    "chars": 27338,
    "preview": "//! AEAD 2022 packet I/O facilities\n//!\n//! ```plain\n//! TCP Header (before encryption)\n//!\n//! +--------+--------+-----"
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/crypto_io.rs",
    "chars": 19367,
    "preview": "//! IO facilities for TCP relay\n\nuse std::{\n    fmt, io,\n    marker::Unpin,\n    pin::Pin,\n    sync::Arc,\n    task::{self"
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/mod.rs",
    "chars": 574,
    "preview": "//! TCP relay\n\npub use self::{\n    proxy_listener::ProxyListener,\n    proxy_stream::{ProxyClientStream, ProxyServerStrea"
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs",
    "chars": 3484,
    "preview": "//! A TCP listener for accepting shadowsocks' client connection\n\nuse std::{\n    io,\n    net::SocketAddr,\n    sync::{Arc,"
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs",
    "chars": 11739,
    "preview": "//! TCP stream for communicating with shadowsocks' proxy server\n\nuse std::{\n    io::{self, ErrorKind},\n    pin::Pin,\n   "
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/proxy_stream/mod.rs",
    "chars": 400,
    "preview": "//! Stream interface for communicating with shadowsocks proxy servers\n\n// pub use self::{\n//     client::{ProxyClientStr"
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/mod.rs",
    "chars": 3042,
    "preview": "//! Shadowsocks TCP protocol\n\nuse std::io;\n\nuse bytes::BufMut;\nuse tokio::io::AsyncRead;\n\nuse crate::{\n    crypto::{Ciph"
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v1.rs",
    "chars": 1005,
    "preview": "//! Shadowsocks Stream / AEAD header protocol\n\nuse std::io;\n\nuse bytes::BufMut;\nuse tokio::io::AsyncRead;\n\nuse crate::re"
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v2.rs",
    "chars": 2654,
    "preview": "//! Shadowsocks AEAD 2022 header protocol\n\nuse std::io;\n\nuse bytes::BufMut;\nuse tokio::io::{AsyncRead, AsyncReadExt};\n\nu"
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs",
    "chars": 7001,
    "preview": "//! A TCP stream for communicating with shadowsocks' proxy client\n\nuse std::{\n    io,\n    pin::Pin,\n    sync::Arc,\n    t"
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/stream.rs",
    "chars": 7537,
    "preview": "//! Stream protocol implementation\nuse std::{\n    io::{self, ErrorKind},\n    marker::Unpin,\n    pin::Pin,\n    slice,\n   "
  },
  {
    "path": "crates/shadowsocks/src/relay/tcprelay/utils.rs",
    "chars": 11413,
    "preview": "//! Utilities for TCP relay\n//!\n//! The `CopyBuffer`, `Copy` and `CopyBidirection` are borrowed from the [tokio](https:/"
  },
  {
    "path": "crates/shadowsocks/src/relay/udprelay/aead.rs",
    "chars": 3530,
    "preview": "//! Shadowsocks UDP AEAD protocol\n//!\n//! Payload with AEAD cipher\n//!\n//! ```plain\n//! UDP (after encryption, *cipherte"
  },
  {
    "path": "crates/shadowsocks/src/relay/udprelay/aead_2022.rs",
    "chars": 24056,
    "preview": "//! Shadowsocks UDP AEAD 2022 protocol\n//!\n//! Payload with AEAD 2022 cipher\n//!\n//! Client -> Server\n//!\n//! ```plain\n/"
  },
  {
    "path": "crates/shadowsocks/src/relay/udprelay/compat.rs",
    "chars": 6142,
    "preview": "use std::{\n    future::Future,\n    io,\n    net::SocketAddr,\n    ops::Deref,\n    pin::Pin,\n    task::{Context, Poll},\n};\n"
  },
  {
    "path": "crates/shadowsocks/src/relay/udprelay/crypto_io.rs",
    "chars": 7464,
    "preview": "//! Crypto protocol for ShadowSocks UDP\n//!\n//! Payload with stream cipher\n//! ```plain\n//! +-------+----------+\n//! |  "
  },
  {
    "path": "crates/shadowsocks/src/relay/udprelay/mod.rs",
    "chars": 2409,
    "preview": "//! Relay for UDP implementation\n//!\n//! ## ShadowSocks UDP protocol\n//!\n//! SOCKS5 UDP Request\n//! ```ignore\n//! +----+"
  },
  {
    "path": "crates/shadowsocks/src/relay/udprelay/options.rs",
    "chars": 546,
    "preview": "//! UDP Socket options and extra data\n\nuse std::sync::Arc;\n\nuse crate::config::ServerUser;\n\n#[derive(Debug, Clone, Defau"
  },
  {
    "path": "crates/shadowsocks/src/relay/udprelay/proxy_socket.rs",
    "chars": 21073,
    "preview": "//! UDP socket for communicating with shadowsocks' proxy server\n\n#[cfg(unix)]\nuse std::os::fd::{AsFd, AsRawFd, BorrowedF"
  },
  {
    "path": "crates/shadowsocks/src/relay/udprelay/stream.rs",
    "chars": 2734,
    "preview": "//! Shadowsocks UDP Stream Protocol\n//!\n//! Payload with stream cipher\n//! ```plain\n//! +-------+----------+\n//! |  IV  "
  },
  {
    "path": "crates/shadowsocks/src/security/mod.rs",
    "chars": 16,
    "preview": "pub mod replay;\n"
  },
  {
    "path": "crates/shadowsocks/src/security/replay/mod.rs",
    "chars": 2680,
    "preview": "use std::fmt;\n\n#[cfg(feature = \"aead-cipher-2022\")]\nuse std::time::Duration;\n\nuse cfg_if::cfg_if;\n#[cfg(feature = \"aead-"
  },
  {
    "path": "crates/shadowsocks/src/security/replay/ppbloom.rs",
    "chars": 2668,
    "preview": "use bloomfilter::Bloom;\nuse log::debug;\n\nuse crate::config::ServerType;\n\n// Entries for server's bloom filter\n//\n// Borr"
  },
  {
    "path": "crates/shadowsocks/tests/tcp.rs",
    "chars": 6368,
    "preview": "use std::{io, net::SocketAddr, sync::Arc};\n\nuse byte_string::ByteStr;\nuse futures::future;\nuse log::info;\nuse tokio::{\n "
  },
  {
    "path": "crates/shadowsocks/tests/tcp_tfo.rs",
    "chars": 2968,
    "preview": "#![cfg(any(\n    windows,\n    target_os = \"linux\",\n    target_os = \"android\",\n    target_os = \"macos\",\n    target_os = \"i"
  },
  {
    "path": "crates/shadowsocks/tests/udp.rs",
    "chars": 6575,
    "preview": "use std::{io, net::SocketAddr, sync::Arc};\n\nuse byte_string::ByteStr;\nuse log::info;\nuse tokio::{net::UdpSocket, sync::B"
  },
  {
    "path": "crates/shadowsocks-service/Cargo.toml",
    "chars": 6334,
    "preview": "[package]\nname = \"shadowsocks-service\"\nversion = \"1.24.0\"\nauthors = [\"Shadowsocks Contributors\"]\ndescription = \"shadowso"
  },
  {
    "path": "crates/shadowsocks-service/README.md",
    "chars": 953,
    "preview": "# shadowsocks-service\n\n[![License](https://img.shields.io/github/license/zonyitoo/shadowsocks-rust.svg)](https://github."
  },
  {
    "path": "crates/shadowsocks-service/src/acl/mod.rs",
    "chars": 22514,
    "preview": "//! Access Control List (ACL) for shadowsocks\n//!\n//! This is for advance controlling server behaviors in both local and"
  },
  {
    "path": "crates/shadowsocks-service/src/acl/sub_domains_tree.rs",
    "chars": 1873,
    "preview": "use std::{\n    collections::HashMap,\n    fmt::{self, Debug},\n};\n\n#[derive(Debug, Clone)]\nstruct DomainPart {\n    include"
  },
  {
    "path": "crates/shadowsocks-service/src/config.rs",
    "chars": 123278,
    "preview": "//! This is a mod for storing and parsing configuration\n//!\n//! According to shadowsocks' official documentation, the st"
  },
  {
    "path": "crates/shadowsocks-service/src/dns/mod.rs",
    "chars": 3278,
    "preview": "//! DNS resolvers\n\n#[cfg(feature = \"hickory-dns\")]\nuse hickory_resolver::config::ResolverOpts;\nuse log::trace;\nuse shado"
  },
  {
    "path": "crates/shadowsocks-service/src/lib.rs",
    "chars": 2265,
    "preview": "//! Shadowsocks Service\n//!\n//! <https://shadowsocks.org/>\n//!\n//! shadowsocks is a fast tunnel proxy that helps you byp"
  },
  {
    "path": "crates/shadowsocks-service/src/local/context.rs",
    "chars": 7132,
    "preview": "//! Shadowsocks Local Server Context\n\nuse std::sync::Arc;\n#[cfg(feature = \"local-dns\")]\nuse std::{net::IpAddr, time::Dur"
  },
  {
    "path": "crates/shadowsocks-service/src/local/dns/client_cache.rs",
    "chars": 7261,
    "preview": "//! DNS Client cache\n\n#[cfg(unix)]\nuse std::path::Path;\nuse std::{\n    collections::{HashMap, VecDeque, hash_map::Entry}"
  },
  {
    "path": "crates/shadowsocks-service/src/local/dns/config.rs",
    "chars": 1514,
    "preview": "//! DNS configurations\n\n#[cfg(unix)]\nuse std::{convert::Infallible, path::PathBuf};\nuse std::{\n    fmt::{self, Display},"
  },
  {
    "path": "crates/shadowsocks-service/src/local/dns/dns_resolver.rs",
    "chars": 5659,
    "preview": "//! Replacement of service's DNS resolver\n\nuse std::{\n    io::{self, ErrorKind},\n    net::{Ipv4Addr, Ipv6Addr, SocketAdd"
  },
  {
    "path": "crates/shadowsocks-service/src/local/dns/mod.rs",
    "chars": 194,
    "preview": "//! Customized DNS resolver\n\npub use self::{\n    config::NameServerAddr,\n    server::{Dns, DnsBuilder},\n};\n\nmod client_c"
  },
  {
    "path": "crates/shadowsocks-service/src/local/dns/server.rs",
    "chars": 33377,
    "preview": "//! Shadowsocks DNS relay local server\n//!\n//! This DNS server requires 2 upstream DNS servers, one for direct queries, "
  },
  {
    "path": "crates/shadowsocks-service/src/local/dns/upstream.rs",
    "chars": 10274,
    "preview": "//! DNS Relay Upstream\n\n#[cfg(unix)]\nuse std::path::Path;\nuse std::{\n    cmp::Ordering,\n    io::{self, ErrorKind},\n    n"
  },
  {
    "path": "crates/shadowsocks-service/src/local/fake_dns/manager.rs",
    "chars": 12309,
    "preview": "//! Fake DNS manager\n\nuse std::{\n    io,\n    iter::Cycle,\n    net::{IpAddr, Ipv4Addr, Ipv6Addr},\n    path::Path,\n    tim"
  },
  {
    "path": "crates/shadowsocks-service/src/local/fake_dns/mod.rs",
    "chars": 454,
    "preview": "//! Fake DNS\n//!\n//! Start a DNS resolver server, mapping requested names to local private network addresses.\n//! When l"
  },
  {
    "path": "crates/shadowsocks-service/src/local/fake_dns/processor.rs",
    "chars": 2646,
    "preview": "//! DNS request processor\n\nuse std::io;\n\nuse hickory_resolver::proto::{\n    op::{Header, Message, OpCode, header::Messag"
  },
  {
    "path": "crates/shadowsocks-service/src/local/fake_dns/proto.rs",
    "chars": 1389,
    "preview": "//! Data representation in Database\n\nuse std::io;\n\nuse serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize"
  },
  {
    "path": "crates/shadowsocks-service/src/local/fake_dns/server.rs",
    "chars": 3840,
    "preview": "//! Fake DNS server\n\nuse std::{\n    io,\n    net::{Ipv4Addr, Ipv6Addr},\n    path::{Path, PathBuf},\n    sync::Arc,\n    tim"
  },
  {
    "path": "crates/shadowsocks-service/src/local/fake_dns/tcp_server.rs",
    "chars": 4986,
    "preview": "//! Fake DNS TCP server\n\nuse std::{\n    io::{self, ErrorKind},\n    net::SocketAddr,\n    sync::Arc,\n    time::Duration,\n}"
  },
  {
    "path": "crates/shadowsocks-service/src/local/fake_dns/udp_server.rs",
    "chars": 2622,
    "preview": "//! Fake DNS UDP server\n\nuse std::{io, net::SocketAddr, sync::Arc, time::Duration};\n\nuse hickory_resolver::proto::op::{M"
  },
  {
    "path": "crates/shadowsocks-service/src/local/http/config.rs",
    "chars": 4474,
    "preview": "//! HTTP protocol configuration\n\nuse std::{\n    collections::HashMap,\n    fs::OpenOptions,\n    io::{self, Read},\n    pat"
  },
  {
    "path": "crates/shadowsocks-service/src/local/http/http_client.rs",
    "chars": 15452,
    "preview": "//! HTTP Client\n\nuse std::{\n    borrow::Cow,\n    collections::VecDeque,\n    fmt::Debug,\n    future::Future,\n    io::{sel"
  },
  {
    "path": "crates/shadowsocks-service/src/local/http/http_service.rs",
    "chars": 13597,
    "preview": "//! Shadowsocks HTTP Proxy server dispatcher\n\nuse std::{net::SocketAddr, str::FromStr, sync::Arc};\n\nuse bytes::Bytes;\nus"
  },
  {
    "path": "crates/shadowsocks-service/src/local/http/http_stream.rs",
    "chars": 5908,
    "preview": "//! Proxied HTTP stream\n\nuse std::{\n    io::{self, ErrorKind},\n    pin::Pin,\n    task::{self, Poll},\n};\n\nuse pin_project"
  },
  {
    "path": "crates/shadowsocks-service/src/local/http/mod.rs",
    "chars": 319,
    "preview": "//! Shadowsocks Local HTTP proxy server\n//!\n//! https://www.ietf.org/rfc/rfc2068.txt\n\npub use self::{\n    http_client::{"
  },
  {
    "path": "crates/shadowsocks-service/src/local/http/server.rs",
    "chars": 6299,
    "preview": "//! Shadowsocks Local HTTP proxy server\n//!\n//! https://www.ietf.org/rfc/rfc2068.txt\n\nuse std::{io, net::SocketAddr, syn"
  },
  {
    "path": "crates/shadowsocks-service/src/local/http/tokio_rt.rs",
    "chars": 4153,
    "preview": "use std::{\n    future::Future,\n    pin::Pin,\n    task::{Context, Poll},\n};\n\nuse pin_project::pin_project;\n\n#[derive(Debu"
  },
  {
    "path": "crates/shadowsocks-service/src/local/http/utils.rs",
    "chars": 5064,
    "preview": "//! HTTP Utilities\n\nuse std::{\n    io,\n    net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},\n    sync::Arc,\n};\n\nuse hyper::"
  },
  {
    "path": "crates/shadowsocks-service/src/local/loadbalancing/mod.rs",
    "chars": 217,
    "preview": "//! Load balancer\n\npub use self::{\n    ping_balancer::{PingBalancer, PingBalancerBuilder, ServerType},\n    server_data::"
  },
  {
    "path": "crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs",
    "chars": 34758,
    "preview": "//! Load Balancer chooses server by statistic latency data collected from active probing\n\nuse std::{\n    cmp,\n    fmt::{"
  },
  {
    "path": "crates/shadowsocks-service/src/local/loadbalancing/server_data.rs",
    "chars": 4321,
    "preview": "//! Identifier of server\n\nuse std::{\n    fmt::{self, Debug},\n    net::SocketAddr,\n    sync::{\n        Arc,\n        atomi"
  },
  {
    "path": "crates/shadowsocks-service/src/local/loadbalancing/server_stat.rs",
    "chars": 6764,
    "preview": "//! Server latency statistic\n\nuse std::{\n    collections::VecDeque,\n    time::{Duration, Instant},\n};\n\n/// Interval betw"
  },
  {
    "path": "crates/shadowsocks-service/src/local/mod.rs",
    "chars": 27389,
    "preview": "//! Shadowsocks Local Server\n\nuse std::{io, net::SocketAddr, sync::Arc, time::Duration};\n\nuse futures::future;\nuse log::"
  },
  {
    "path": "crates/shadowsocks-service/src/local/net/mod.rs",
    "chars": 233,
    "preview": "//! Shadowsocks Local Network Utilities\n\npub use self::{\n    tcp::{auto_proxy_io::AutoProxyIo, auto_proxy_stream::AutoPr"
  },
  {
    "path": "crates/shadowsocks-service/src/local/net/tcp/auto_proxy_io.rs",
    "chars": 314,
    "preview": "//! Trait of auto-proxy I/O\n\n/// Proxy I/O chooses bypass or proxy automatically\npub trait AutoProxyIo {\n    /// Check i"
  },
  {
    "path": "crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs",
    "chars": 7744,
    "preview": "//! A `ProxyStream` that bypasses or proxies data through proxy server automatically\n\nuse std::{\n    io::{self, IoSlice}"
  },
  {
    "path": "crates/shadowsocks-service/src/local/net/tcp/listener.rs",
    "chars": 725,
    "preview": "//! Local instance listener helpers\n\nuse std::io;\n\nuse shadowsocks::{config::ServerAddr, lookup_then, net::TcpListener};"
  },
  {
    "path": "crates/shadowsocks-service/src/local/net/tcp/mod.rs",
    "chars": 68,
    "preview": "pub mod auto_proxy_io;\npub mod auto_proxy_stream;\npub mod listener;\n"
  },
  {
    "path": "crates/shadowsocks-service/src/local/net/udp/association.rs",
    "chars": 22494,
    "preview": "//! UDP Association Managing\n\nuse std::{\n    cell::RefCell,\n    io,\n    marker::PhantomData,\n    net::{SocketAddr, Socke"
  },
  {
    "path": "crates/shadowsocks-service/src/local/net/udp/listener.rs",
    "chars": 721,
    "preview": "//! Local instance listener helpers\n\nuse std::io;\n\nuse shadowsocks::{config::ServerAddr, lookup_then, net::UdpSocket};\n\n"
  },
  {
    "path": "crates/shadowsocks-service/src/local/net/udp/mod.rs",
    "chars": 162,
    "preview": "#[allow(unused_imports)]\npub use self::association::{UdpAssociationManager, UdpInboundWrite, generate_client_session_id}"
  },
  {
    "path": "crates/shadowsocks-service/src/local/online_config/content_encoding.rs",
    "chars": 2647,
    "preview": "//! HTTP Body Content-Encoding\n\nuse std::io::{self, Cursor, Read};\n\nuse futures::StreamExt;\nuse http::HeaderValue;\nuse h"
  },
  {
    "path": "crates/shadowsocks-service/src/local/online_config/mod.rs",
    "chars": 9101,
    "preview": "//! Online Config (SIP008)\n//!\n//! Online Configuration Delivery URL (https://shadowsocks.org/doc/sip008.html)\n\nuse std:"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/mod.rs",
    "chars": 151,
    "preview": "//! Shadowsocks Local Transparent Proxy\n\npub use self::server::{Redir, RedirBuilder};\n\nmod redir_ext;\nmod server;\nmod sy"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/redir_ext.rs",
    "chars": 2347,
    "preview": "//! Extension trait for `TcpListener` and `UdpSocket`\n\nuse std::{\n    future::Future,\n    io,\n    net::SocketAddr,\n    p"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/server.rs",
    "chars": 4096,
    "preview": "//! Shadowsocks Transparent Proxy Local Server\n\nuse std::{io, sync::Arc, time::Duration};\n\nuse futures::{FutureExt, futu"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/sys/mod.rs",
    "chars": 623,
    "preview": "use std::io;\n\nuse cfg_if::cfg_if;\nuse socket2::SockRef;\n\ncfg_if! {\n    if #[cfg(unix)] {\n        mod unix;\n        #[all"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/sys/unix/bsd_pf.rs",
    "chars": 15876,
    "preview": "//! PacketFilter implementation for *BSD\n\nuse std::{\n    io::{self, Error, ErrorKind},\n    mem,\n    net::SocketAddr,\n   "
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/sys/unix/mod.rs",
    "chars": 1124,
    "preview": "use cfg_if::cfg_if;\n\ncfg_if! {\n    if #[cfg(any(target_os = \"macos\",\n                 target_os = \"ios\",\n               "
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/sys/unix/pfvar_bindgen_freebsd.rs",
    "chars": 635814,
    "preview": "// automatically generated by rust-bindgen 0.69.2\n\npub const BSD: u32 = 199506;\npub const BSD4_3: u32 = 1;\npub const BSD"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/sys/unix/pfvar_bindgen_macos.rs",
    "chars": 747112,
    "preview": "// automatically generated by rust-bindgen 0.69.2\n\n#[repr(C)]\n#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, Parti"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/sys/unix/pfvar_bindgen_openbsd.rs",
    "chars": 446960,
    "preview": "// automatically generated by rust-bindgen 0.69.4\n\npub const __ISO_C_VISIBLE: u32 = 2011;\npub const __XPG_VISIBLE: u32 ="
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/tcprelay/mod.rs",
    "chars": 4882,
    "preview": "//! Shadowsocks TCP transparent proxy\n\nuse std::{\n    io,\n    net::{IpAddr, SocketAddr},\n    sync::Arc,\n    time::Durati"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/tcprelay/sys/mod.rs",
    "chars": 197,
    "preview": "use cfg_if::cfg_if;\n\ncfg_if! {\n    if #[cfg(unix)] {\n        mod unix;\n        pub use self::unix::*;\n    } else if #[cf"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/bsd.rs",
    "chars": 4396,
    "preview": "use std::{\n    io::{self, Error, ErrorKind},\n    net::SocketAddr,\n};\n\nuse log::warn;\nuse shadowsocks::net::{AcceptOpts, "
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/linux.rs",
    "chars": 8946,
    "preview": "use std::{\n    io::{self, Error, ErrorKind},\n    mem,\n    net::SocketAddr,\n    os::unix::io::AsRawFd,\n};\n\nuse log::warn;"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/mod.rs",
    "chars": 468,
    "preview": "use cfg_if::cfg_if;\n\ncfg_if! {\n    if #[cfg(any(target_os = \"linux\", target_os = \"android\"))] {\n        mod linux;\n     "
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/not_supported.rs",
    "chars": 673,
    "preview": "use std::{io, net::SocketAddr};\n\nuse shadowsocks::net::AcceptOpts;\nuse tokio::net::{TcpListener, TcpStream};\n\nuse crate:"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/tcprelay/sys/windows/mod.rs",
    "chars": 768,
    "preview": "use std::{\n    io::{self, Error, ErrorKind},\n    net::SocketAddr,\n};\n\nuse shadowsocks::net::AcceptOpts;\nuse tokio::net::"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/udprelay/mod.rs",
    "chars": 11382,
    "preview": "//! UDP transparent proxy\n\nuse std::{\n    io::{self, ErrorKind},\n    net::{IpAddr, SocketAddr},\n    sync::Arc,\n    time:"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/udprelay/sys/mod.rs",
    "chars": 284,
    "preview": "use cfg_if::cfg_if;\n\ncfg_if! {\n    if #[cfg(unix)] {\n        mod unix;\n        pub use self::unix::*;\n    } else if #[cf"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/freebsd.rs",
    "chars": 11089,
    "preview": "use std::{\n    io::{self, Error, ErrorKind},\n    mem,\n    net::{SocketAddr, UdpSocket},\n    os::unix::io::AsRawFd,\n    p"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/linux.rs",
    "chars": 11129,
    "preview": "use std::{\n    io::{self, Error, ErrorKind},\n    mem,\n    net::{SocketAddr, UdpSocket},\n    os::unix::io::{AsRawFd, RawF"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/macos.rs",
    "chars": 6388,
    "preview": "use std::{\n    io::{self, Error, ErrorKind},\n    mem,\n    net::{SocketAddr, UdpSocket},\n    os::unix::io::AsRawFd,\n    t"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/mod.rs",
    "chars": 537,
    "preview": "use cfg_if::cfg_if;\n\ncfg_if! {\n    if #[cfg(any(target_os = \"linux\", target_os = \"android\"))] {\n        mod linux;\n     "
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/not_supported.rs",
    "chars": 1635,
    "preview": "use std::{\n    io,\n    net::SocketAddr,\n    task::{Context, Poll},\n};\n\nuse crate::{\n    config::RedirType,\n    local::re"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/openbsd.rs",
    "chars": 12531,
    "preview": "use std::{\n    io::{self, Error, ErrorKind},\n    mem,\n    net::{SocketAddr, UdpSocket},\n    os::unix::io::AsRawFd,\n    p"
  },
  {
    "path": "crates/shadowsocks-service/src/local/redir/udprelay/sys/windows/mod.rs",
    "chars": 1690,
    "preview": "use std::{\n    io,\n    net::SocketAddr,\n    task::{Context, Poll},\n};\n\nuse crate::{\n    config::RedirType,\n    local::re"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/client/mod.rs",
    "chars": 215,
    "preview": "//! SOCKS clients\n\n#[cfg(feature = \"local-socks4\")]\npub use self::socks4::Socks4TcpClient;\npub use self::socks5::{Socks5"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/client/socks4/mod.rs",
    "chars": 84,
    "preview": "//! SOCKS 4/4a clients\n\npub use self::tcp_client::Socks4TcpClient;\n\nmod tcp_client;\n"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/client/socks4/tcp_client.rs",
    "chars": 2079,
    "preview": "//! SOCKS 4/4a client implementation\n\nuse std::{\n    io,\n    pin::Pin,\n    task::{self, Poll},\n};\n\nuse log::trace;\nuse p"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/client/socks5/mod.rs",
    "chars": 135,
    "preview": "//! SOCKS5 clients\n\npub use self::{tcp_client::Socks5TcpClient, udp_client::Socks5UdpClient};\n\npub mod tcp_client;\npub m"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/client/socks5/tcp_client.rs",
    "chars": 3599,
    "preview": "//! TCP relay client implementation\n\nuse std::{\n    io,\n    pin::Pin,\n    task::{self, Poll},\n};\n\nuse log::trace;\nuse pi"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/client/socks5/udp_client.rs",
    "chars": 3653,
    "preview": "//! UDP relay client\n\nuse std::io::{self, Cursor};\n\nuse bytes::{BufMut, BytesMut};\nuse tokio::net::{ToSocketAddrs, UdpSo"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/config.rs",
    "chars": 3408,
    "preview": "//! SOCK protocol configuration\n\nuse std::{\n    collections::HashMap,\n    fs::OpenOptions,\n    io::{self, Read},\n    pat"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/mod.rs",
    "chars": 189,
    "preview": "//! Shadowsocks SOCKS (4/4a, 5) Local Server\n\npub use self::server::{Socks, SocksBuilder};\n\npub mod client;\npub mod conf"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/server/mod.rs",
    "chars": 6532,
    "preview": "//! Shadowsocks SOCKS Local Server\n\nuse std::{io, sync::Arc, time::Duration};\n\nuse futures::{FutureExt, future};\nuse sha"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/server/server.rs",
    "chars": 8430,
    "preview": "use std::{io, net::SocketAddr, sync::Arc, time::Duration};\n\nuse log::{error, info};\nuse shadowsocks::{ServerAddr, config"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/server/socks4/mod.rs",
    "chars": 85,
    "preview": "//! SOCKS4/4a Local Server\n\npub use self::tcprelay::Socks4TcpHandler;\n\nmod tcprelay;\n"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs",
    "chars": 4804,
    "preview": "//! Shadowsocks SOCKS4/4a Local Server\n\nuse std::{\n    io::{self, ErrorKind},\n    net::SocketAddr,\n    sync::Arc,\n};\n\nus"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/server/socks5/mod.rs",
    "chars": 162,
    "preview": "//! SOCKS5 Local Server\n\npub use self::{\n    tcprelay::Socks5TcpHandler,\n    udprelay::{Socks5UdpServer, Socks5UdpServer"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs",
    "chars": 10123,
    "preview": "//! SOCKS5 TCP Server\n\nuse std::{\n    io::{self, ErrorKind},\n    net::{Ipv4Addr, SocketAddr},\n    str,\n    sync::Arc,\n};"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/server/socks5/udprelay.rs",
    "chars": 7373,
    "preview": "//! UDP Tunnel server\n\nuse std::{\n    io::{self, Cursor},\n    net::{IpAddr, SocketAddr},\n    sync::Arc,\n    time::Durati"
  },
  {
    "path": "crates/shadowsocks-service/src/local/socks/socks4.rs",
    "chars": 12375,
    "preview": "//! Socks4a Protocol Definition\n//!\n//! <http://ftp.icm.edu.pl/packages/socks/socks4/SOCKS4.protocol>\n\n#![allow(dead_cod"
  },
  {
    "path": "crates/shadowsocks-service/src/local/tun/fake_tun.rs",
    "chars": 7358,
    "preview": "//! Fake `tun` for those platforms that doesn't support `tun`\n\n#![allow(dead_code)]\n\nuse std::{\n    io::{self, Read, Wri"
  },
  {
    "path": "crates/shadowsocks-service/src/local/tun/ip_packet.rs",
    "chars": 1570,
    "preview": "//! IP packet encapsulation\n\nuse std::net::IpAddr;\n\nuse smoltcp::wire::{IpProtocol, IpVersion, Ipv4Packet, Ipv6Packet};\n"
  },
  {
    "path": "crates/shadowsocks-service/src/local/tun/mod.rs",
    "chars": 13742,
    "preview": "//! Shadowsocks Local server serving on a Tun interface\n\n#[cfg(unix)]\nuse std::os::unix::io::RawFd;\nuse std::{\n    io, m"
  },
  {
    "path": "crates/shadowsocks-service/src/local/tun/tcp.rs",
    "chars": 22739,
    "preview": "use std::{\n    collections::HashMap,\n    future::Future,\n    io, mem,\n    net::{IpAddr, SocketAddr},\n    pin::Pin,\n    s"
  },
  {
    "path": "crates/shadowsocks-service/src/local/tun/udp.rs",
    "chars": 5438,
    "preview": "use std::{\n    io::{self, ErrorKind},\n    net::{IpAddr, SocketAddr},\n    sync::Arc,\n    time::Duration,\n};\n\nuse bytes::{"
  },
  {
    "path": "crates/shadowsocks-service/src/local/tun/virt_device.rs",
    "chars": 4167,
    "preview": "//! Virtual Device for receiving packets from tun\n\nuse std::{\n    marker::PhantomData,\n    mem,\n    ops::{Deref, DerefMu"
  },
  {
    "path": "crates/shadowsocks-service/src/local/tunnel/mod.rs",
    "chars": 129,
    "preview": "//! Shadowsocks Local Tunnel Server\n\npub use self::server::{Tunnel, TunnelBuilder};\n\npub mod server;\nmod tcprelay;\nmod u"
  },
  {
    "path": "crates/shadowsocks-service/src/local/tunnel/server.rs",
    "chars": 4949,
    "preview": "//! Shadowsocks Local Tunnel Server\n\nuse std::{io, sync::Arc, time::Duration};\n\nuse futures::{FutureExt, future};\nuse sh"
  },
  {
    "path": "crates/shadowsocks-service/src/local/tunnel/tcprelay.rs",
    "chars": 4753,
    "preview": "//! TCP Tunnel Server\n\nuse std::{io, net::SocketAddr, sync::Arc, time::Duration};\n\nuse log::{error, info, trace};\nuse sh"
  },
  {
    "path": "crates/shadowsocks-service/src/local/tunnel/udprelay.rs",
    "chars": 6030,
    "preview": "//! UDP Tunnel server\n\nuse std::{io, net::SocketAddr, sync::Arc, time::Duration};\n\nuse log::{debug, error, info};\nuse sh"
  },
  {
    "path": "crates/shadowsocks-service/src/local/utils.rs",
    "chars": 3349,
    "preview": "//! Shadowsocks Local Utilities\n\nuse std::{io, net::SocketAddr, time::Duration};\n\nuse log::{debug, trace};\nuse shadowsoc"
  },
  {
    "path": "crates/shadowsocks-service/src/manager/mod.rs",
    "chars": 3401,
    "preview": "//! Shadowsocks manager service\n//!\n//! Service for managing multiple relay servers. [Manage Multiple Users](https://git"
  },
  {
    "path": "crates/shadowsocks-service/src/manager/server.rs",
    "chars": 24117,
    "preview": "//! Shadowsocks Manager server\n\n#[cfg(unix)]\nuse std::path::PathBuf;\nuse std::{collections::HashMap, io, net::SocketAddr"
  },
  {
    "path": "crates/shadowsocks-service/src/net/flow.rs",
    "chars": 1089,
    "preview": "//! Server flow statistic\n\nuse std::sync::atomic::Ordering;\n\n#[cfg(target_has_atomic = \"64\")]\ntype FlowCounter = std::sy"
  },
  {
    "path": "crates/shadowsocks-service/src/net/launch_activate_socket.rs",
    "chars": 1221,
    "preview": "//! macOS launch activate socket\n//!\n//! <https://developer.apple.com/documentation/xpc/1505523-launch_activate_socket>\n"
  }
]

// ... and 82 more files (download for full content)

About this extraction

This page contains the full source code of the shadowsocks/shadowsocks-rust GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 282 files (3.3 MB), approximately 887.0k tokens, and a symbol index with 10153 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!