_easytier-core() {
    local i cur prev opts cmd
    COMPREPLY=()
    if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
        cur="$2"
    else
        cur="${COMP_WORDS[COMP_CWORD]}"
    fi
    prev="$3"
    cmd=""
    opts=""

    for i in "${COMP_WORDS[@]:0:COMP_CWORD}"
    do
        case "${cmd},${i}" in
            ",$1")
                cmd="easytier__core"
                ;;
            *)
                ;;
        esac
    done

    case "${cmd}" in
        easytier__core)
            opts="-w -c -i -d -p -e -n -l -m -u -r -h -V --config-server --machine-id --config-file --config-dir --network-name --network-secret --ipv4 --ipv6 --ipv6-public-addr-provider --ipv6-public-addr-auto --ipv6-public-addr-prefix --dhcp --peers --external-node --proxy-networks --listeners --mapped-listeners --no-listener --hostname --instance-name --vpn-portal --default-protocol --disable-encryption --encryption-algorithm --multi-thread --multi-thread-count --disable-ipv6 --dev-name --mtu --latency-first --exit-nodes --enable-exit-node --proxy-forward-by-system --no-tun --use-smoltcp --manual-routes --relay-network-whitelist --p2p-only --lazy-p2p --disable-p2p --disable-udp-hole-punching --disable-tcp-hole-punching --disable-sym-hole-punching --disable-upnp --enable-udp-broadcast-relay --relay-all-peer-rpc --need-p2p --socks5 --compression --bind-device --enable-kcp-proxy --disable-kcp-input --enable-quic-proxy --disable-quic-input --port-forward --accept-dns --tld-dns-zone --private-mode --foreign-relay-bps-limit --instance-recv-bps-limit --tcp-whitelist --udp-whitelist --disable-relay-kcp --disable-relay-quic --enable-relay-foreign-network-kcp --enable-relay-foreign-network-quic --stun-servers --stun-servers-v6 --secure-mode --local-private-key --local-public-key --credential --credential-file --console-log-level --file-log-level --file-log-dir --file-log-size --file-log-count --rpc-portal --rpc-portal-whitelist --gen-autocomplete --check-config --daemon --disable-env-parsing --help --version"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --config-server)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -w)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --machine-id)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --config-file)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --config-dir)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --network-name)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --network-secret)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --ipv4)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -i)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --ipv6)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --ipv6-public-addr-provider)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --ipv6-public-addr-auto)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --ipv6-public-addr-prefix)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --dhcp)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                -d)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --peers)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --external-node)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -e)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --proxy-networks)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -n)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --listeners)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -l)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --mapped-listeners)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --hostname)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --instance-name)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -m)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --vpn-portal)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --default-protocol)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --disable-encryption)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                -u)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --encryption-algorithm)
                    COMPREPLY=($(compgen -W "xor aes-gcm aes-256-gcm chacha20" -- "${cur}"))
                    return 0
                    ;;
                --multi-thread)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --multi-thread-count)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --disable-ipv6)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --dev-name)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --mtu)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --latency-first)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --exit-nodes)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --enable-exit-node)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --proxy-forward-by-system)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --no-tun)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --use-smoltcp)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --manual-routes)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --relay-network-whitelist)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --p2p-only)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --lazy-p2p)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --disable-p2p)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --disable-udp-hole-punching)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --disable-tcp-hole-punching)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --disable-sym-hole-punching)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --disable-upnp)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --enable-udp-broadcast-relay)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --relay-all-peer-rpc)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --need-p2p)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --socks5)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --compression)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --bind-device)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --enable-kcp-proxy)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --disable-kcp-input)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --enable-quic-proxy)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --disable-quic-input)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --port-forward)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --accept-dns)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --tld-dns-zone)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --private-mode)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --foreign-relay-bps-limit)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --instance-recv-bps-limit)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --tcp-whitelist)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --udp-whitelist)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --disable-relay-kcp)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --disable-relay-quic)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --enable-relay-foreign-network-kcp)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --enable-relay-foreign-network-quic)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --stun-servers)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --stun-servers-v6)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --secure-mode)
                    COMPREPLY=($(compgen -W "true false" -- "${cur}"))
                    return 0
                    ;;
                --local-private-key)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --local-public-key)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --credential)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --credential-file)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --console-log-level)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --file-log-level)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --file-log-dir)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --file-log-size)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --file-log-count)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --rpc-portal)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -r)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --rpc-portal-whitelist)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --gen-autocomplete)
                    COMPREPLY=($(compgen -W "bash elvish fish powershell zsh nu" -- "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
    esac
}

if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
    complete -F _easytier-core -o nosort -o bashdefault -o default easytier-core
else
    complete -F _easytier-core -o bashdefault -o default easytier-core
fi
