fn should_forward_by_query(context: &ServiceContext, balancer: &PingBalancer, query: &Query) -> Option<bool> {
    // No server was configured, then always resolve with local
    if balancer.is_empty() {
        return Some(false);
    }

    // Check if we are trying to make queries for remote servers
    //
    // This happens normally because VPN or TUN device receives DNS queries from local servers' plugins
    // https://github.com/shadowsocks/shadowsocks-android/issues/2722
    for server in balancer.servers() {
        let svr_cfg = server.server_config();
        if let ServerAddr::DomainName(dn, ..) = svr_cfg.addr() {
            // Convert domain name to `Name`
            // Ignore it if error occurs
            if let Ok(mut name) = Name::from_str(dn) {
                // cmp will handle FQDN in case insensitive way
                if let Ordering::Equal = query.name().cmp(&name) {
                    // It seems that query is for this server, just bypass it to local resolver
                    trace!("DNS querying name {} of server {:?}", query.name(), svr_cfg);
                    return Some(false);
                }
                // test it again with fqdn set
                name.set_fqdn(true);
                if let Ordering::Equal = query.name().cmp(&name) {
                    trace!("DNS querying name {} of server {:?}", query.name(), svr_cfg);
                    return Some(false);
                }
            }
        }
    }

    if let Some(acl) = context.acl() {
        if query.query_class() != DNSClass::IN {
            // unconditionally use default for all non-IN queries
            Some(acl.is_default_in_proxy_list())
        } else if query.query_type() == RecordType::PTR {
            Some(should_forward_by_ptr_name(acl, query.name()))
        } else {
            let result = check_name_in_proxy_list(acl, query.name());
            if result.is_none() && acl.is_ip_empty() && acl.is_host_empty() {
                Some(acl.is_default_in_proxy_list())
            } else {
                result
            }
        }
    } else {
        Some(true)
    }
}
given the query, determine whether remote/local query should be used, or inconclusive
crates/shadowsocks-service/src/local/dns/server.rs