コード例 #1
0
        private static bool HandleRule(Rule r, ref Match regexMatch, string host, int port)
        {
            bool hit = false;

            if (r.eq != null)
            {
                hit |= r.eq == host;
            }
            if (r.regex != null)
            {
                var match = Regex.Match(host, r.regex);
                if (match.Success)
                {
                    regexMatch = match;
                    hit        = true;
                }
            }
            if (r.wildcard != null)
            {
                hit |= Wildcard.IsMatch(host, r.wildcard);
            }
            if (r.port != 0)
            {
                hit |= r.port == port;
            }
            if (r.ip != null && !hit)
            {
                hit = HandleIp(host, r);
            }
            return(hit);
        }
コード例 #2
0
ファイル: WebFileAdapter.cs プロジェクト: smeoow/Naive
        private Task HandleFile(HttpConnection p, string realPath)
        {
            if (p.Url_qstr == "dlcancel")
            {
                p.Handled = true;
                p.setContentTypeTextPlain();
                //if (p.Method != "POST")
                //    return p.writeLineAsync("E: POST needed.");
                if (this.allow_netdl == false)
                {
                    return(p.writeLineAsync($"E: {strMissingPermission("netdl")}."));
                }

                if (downloadTasks.TryGetValue(realPath, out var dlTask))
                {
                    dlTask.Cancel();
                    return(p.writeLineAsync("task is canceled."));
                }
                else
                {
                    return(p.writeLineAsync("E: task not found."));
                }
            }
            foreach (var item in gzip_wildcard)
            {
                if (Wildcard.IsMatch(realPath, item))
                {
                    p.outputStream.EnableGzipIfClientSupports();
                    break;
                }
            }
            return(WebSvrHelper.HandleFileAsync(p, realPath));
        }
コード例 #3
0
 static bool MatchWildcard(string input, string pattern, SubRange sub)
 {
     return(Wildcard.IsMatch(input, pattern, sub.offset, sub.length));
 }
コード例 #4
0
 static bool MatchWildcard(string input, string pattern)
 {
     return(Wildcard.IsMatch(input, pattern));
 }