public static void DnsQueryRoute(IEndpointRouteBuilder endpoints) { endpoints.Map(Config.QueryPerfix, async context => { var queryDictionary = context.Request.Query; if (context.Request.Method == "POST") { await ReturnContext(context, true, DnsQuery(DnsMessage.Parse((await context.Request.BodyReader.ReadAsync()).Buffer.ToArray()), context)); } else if (queryDictionary.ContainsKey("dns")) { await ReturnContext(context, true, DnsQuery(DNSGet.FromWebBase64(context), context)); } else if (queryDictionary.ContainsKey("name")) { await ReturnContext(context, false, DnsQuery(DNSGet.FromQueryContext(context, EcsDefaultMask: Config.EcsDefaultMask), context)); } else { await context.WriteResponseAsync(Startup.IndexStr, type: "text/html"); } }); }
private static void DnsQueryRoute(IEndpointRouteBuilder endpoints) { endpoints.Map(Config.QueryPerfix, async context => { context.Response.Headers.Add("X-Powered-By", "ArashiDNSP/ONE"); var queryDictionary = context.Request.Query; if (queryDictionary.ContainsKey("dns")) { ReturnContext(context, true, DnsQuery(DNSGet.FromWebBase64(queryDictionary["dns"].ToString()), context)); } else if (queryDictionary.ContainsKey("name")) { ReturnContext(context, false, DnsQuery(DNSGet.FromQueryContext(context), context)); } else { context.Response.ContentType = "text/html"; await context.Response.WriteAsync(IndexStr); } }); }