diff --git a/internal/web/actions/default/dns/providers/createPopup.go b/internal/web/actions/default/dns/providers/createPopup.go index 44efc166..7cf5f8a2 100644 --- a/internal/web/actions/default/dns/providers/createPopup.go +++ b/internal/web/actions/default/dns/providers/createPopup.go @@ -73,6 +73,12 @@ func (this *CreatePopupAction) RunPost(params struct { ParamCustomHTTPURL string ParamCustomHTTPSecret string + // EdgeDNS API + ParamEdgeDNSAPIRole string + ParamEdgeDNSAPIHost string + ParamEdgeDNSAPIAccessKeyId string + ParamEdgeDNSAPIAccessKeySecret string + Must *actions.Must CSRF *actionutils.CSRF }) { @@ -121,6 +127,20 @@ func (this *CreatePopupAction) RunPost(params struct { Email("请输入正确格式的邮箱地址") apiParams["apiKey"] = params.ParamCloudFlareAPIKey apiParams["email"] = params.ParamCloudFlareEmail + case "edgeDNSAPI": + params.Must. + Field("paramEdgeDNSAPIHost", params.ParamEdgeDNSAPIHost). + Require("请输入API地址"). + Field("paramEdgeDNSAPIRole", params.ParamEdgeDNSAPIRole). + Require("请选择AccessKey类型"). + Field("paramEdgeDNSAPIAccessKeyId", params.ParamEdgeDNSAPIAccessKeyId). + Require("请输入AccessKey ID"). + Field("paramEdgeDNSAPIAccessKeySecret", params.ParamEdgeDNSAPIAccessKeySecret). + Require("请输入AccessKey密钥") + apiParams["host"] = params.ParamEdgeDNSAPIHost + apiParams["role"] = params.ParamEdgeDNSAPIRole + apiParams["accessKeyId"] = params.ParamEdgeDNSAPIAccessKeyId + apiParams["accessKeySecret"] = params.ParamEdgeDNSAPIAccessKeySecret case "customHTTP": params.Must. Field("paramCustomHTTPURL", params.ParamCustomHTTPURL). diff --git a/internal/web/actions/default/dns/providers/updatePopup.go b/internal/web/actions/default/dns/providers/updatePopup.go index 1f304051..ce180ca2 100644 --- a/internal/web/actions/default/dns/providers/updatePopup.go +++ b/internal/web/actions/default/dns/providers/updatePopup.go @@ -100,6 +100,12 @@ func (this *UpdatePopupAction) RunPost(params struct { ParamCustomHTTPURL string ParamCustomHTTPSecret string + // EdgeDNS API + ParamEdgeDNSAPIHost string + ParamEdgeDNSAPIRole string + ParamEdgeDNSAPIAccessKeyId string + ParamEdgeDNSAPIAccessKeySecret string + Must *actions.Must CSRF *actionutils.CSRF }) { @@ -150,6 +156,20 @@ func (this *UpdatePopupAction) RunPost(params struct { Email("请输入正确格式的邮箱地址") apiParams["apiKey"] = params.ParamCloudFlareAPIKey apiParams["email"] = params.ParamCloudFlareEmail + case "edgeDNSAPI": + params.Must. + Field("paramEdgeDNSAPIHost", params.ParamEdgeDNSAPIHost). + Require("请输入API地址"). + Field("paramEdgeDNSAPIRole", params.ParamEdgeDNSAPIRole). + Require("请选择AccessKey类型"). + Field("paramEdgeDNSAPIAccessKeyId", params.ParamEdgeDNSAPIAccessKeyId). + Require("请输入AccessKey ID"). + Field("paramEdgeDNSAPIAccessKeySecret", params.ParamEdgeDNSAPIAccessKeySecret). + Require("请输入AccessKey密钥") + apiParams["host"] = params.ParamEdgeDNSAPIHost + apiParams["role"] = params.ParamEdgeDNSAPIRole + apiParams["accessKeyId"] = params.ParamEdgeDNSAPIAccessKeyId + apiParams["accessKeySecret"] = params.ParamEdgeDNSAPIAccessKeySecret case "customHTTP": params.Must. Field("paramCustomHTTPURL", params.ParamCustomHTTPURL). diff --git a/web/public/js/components.js b/web/public/js/components.js index e22daee3..d76ef7de 100644 --- a/web/public/js/components.js +++ b/web/public/js/components.js @@ -1779,7 +1779,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
-`});let defaultGeneralHeaders=["Cache-Control","Connection","Date","Pragma","Trailer","Transfer-Encoding","Upgrade","Via","Warning"];function sortTable(n){let e=document.createElement("script");e.setAttribute("src","/js/sortable.min.js"),e.addEventListener("load",function(){let s=document.querySelector("#sortable-table");null!=s&&Sortable.create(s,{draggable:"tbody",handle:".icon.handle",onStart:function(){},onUpdate:function(e){let t=s.querySelectorAll("tbody"),i=[];t.forEach(function(e){i.push(parseInt(e.getAttribute("v-id")))}),n(i)}})}),document.head.appendChild(e)}function sortLoad(e){let t=document.createElement("script");t.setAttribute("src","/js/sortable.min.js"),t.addEventListener("load",function(){"function"==typeof e&&e()}),document.head.appendChild(t)}function emitClick(e,arguments){let t=["click"];for(let e=0;e +`});let defaultGeneralHeaders=["Cache-Control","Connection","Date","Pragma","Trailer","Transfer-Encoding","Upgrade","Via","Warning"];Vue.component("http-cond-general-header-length",{props:["v-checkpoint"],data:function(){let e=null,t=null;var i;null!=window.parent.UPDATING_RULE&&(null!=(i=window.parent.UPDATING_RULE.checkpointOptions).headers&&Array.$isArray(i.headers)&&(e=i.headers),null!=i.length&&(t=i.length)),null==e&&(e=defaultGeneralHeaders),null==t&&(t=128);let s=this;return setTimeout(function(){s.change()},100),{headers:e,length:t}},watch:{length:function(e){let t=parseInt(e);(t=isNaN(t)?0:t)<0&&(t=0),this.length=t,this.change()}},methods:{change:function(){this.vCheckpoint.options=[{code:"headers",value:this.headers},{code:"length",value:this.length}]}},template:`
@@ -3050,7 +3050,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
通用Header列表
-
`}),Vue.component("http-access-log-box",{props:["v-access-log","v-keyword","v-show-server-link"],data:function(){let e=this.vAccessLog;if(null!=e.header&&null!=e.header.Upgrade&&null!=e.header.Upgrade.values&&e.header.Upgrade.values.$contains("websocket")&&("http"==e.scheme?e.scheme="ws":"https"==e.scheme&&(e.scheme="wss")),null!=e.tags&&0 +`}),Vue.component("http-access-log-box",{props:["v-access-log","v-keyword","v-show-server-link"],data:function(){let e=this.vAccessLog;if(null!=e.header&&null!=e.header.Upgrade&&null!=e.header.Upgrade.values&&e.header.Upgrade.values.$contains("websocket")&&("http"==e.scheme?e.scheme="ws":"https"==e.scheme&&(e.scheme="wss")),null!=e.tags&&0
[{{accessLog.node.name}}节点] @@ -3058,8 +3058,19 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio [服务] [服务] - [{{accessLog.region}}] {{accessLog.remoteAddr}} [{{accessLog.timeLocal}}] "{{accessLog.requestMethod}} {{accessLog.scheme}}://{{accessLog.host}}{{accessLog.requestURI}} {{accessLog.proto}}" {{accessLog.status}} cache {{accessLog.attrs['cache.status'].toLowerCase()}} waf {{accessLog.firewallActions}} - {{tag}} + [{{accessLog.region}}] + {{accessLog.remoteAddr}} [{{accessLog.timeLocal}}] "{{accessLog.requestMethod}} {{accessLog.scheme}}://{{accessLog.host}}{{accessLog.requestURI}} {{accessLog.proto}}" {{accessLog.status}} + {{accessLog.unicodeHost}} + + + cache {{accessLog.attrs['cache.status'].toLowerCase()}} + + waf {{accessLog.firewallActions}} + + + - {{tag}} + @@ -3075,7 +3086,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio - 耗时:{{formatCost(accessLog.requestTime)}} ms   ({{accessLog.humanTime}})  
-`}),Vue.component("http-firewall-block-options-viewer",{props:["v-block-options"],data:function(){return{options:this.vBlockOptions}},template:`
+
`});var punycode=new function(){this.utf16={decode:function(e){for(var t,i,s=[],n=0,o=e.length;n>>10&1023|55296)),t=56320|1023&t),i.push(String.fromCharCode(t))}return i.join("")}};var b=2147483647;function y(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function x(e,t,i){var s;for(e=i?Math.floor(e/700):e>>1,e+=Math.floor(e/t),s=0;455= 0x80");d.push(e.charCodeAt(s))}for(n=0Math.floor((b-v)/a))throw RangeError("punycode_overflow(1)");if(v+=r*a,r<(r=l<=m?1:m+26<=l?26:l-m))break;if(a>Math.floor(b/(36-r)))throw RangeError("punycode_overflow(2)");a*=36-r}if(m=x(v-o,i=d.length+1,0===o),Math.floor(v/i)>b-h)throw RangeError("punycode_overflow(3)");h+=Math.floor(v/i),v%=i,t&&p.splice(v,0,e.charCodeAt(n-1)-65<26),d.splice(v,0,h),v++}if(t)for(v=0,c=d.length;vMath.floor((b-m)/(i+1)))throw RangeError("punycode_overflow (1)");for(m+=(n-v)*(i+1),v=n,g=0;gb)return Error("punycode_overflow(2)");if(c==v){for(o=m,a=36;!(o<(l=a<=f?1:f+26<=a?26:a-f));a+=36)h.push(String.fromCharCode(y(l+(o-l)%(36-l),0))),o=Math.floor((o-l)/(36-l));h.push(String.fromCharCode(y(o,t&&r[g]?1:0))),f=x(m,i+1,i==s),m=0,++i}}++m,++v}return h.join("")},this.ToASCII=function(e){for(var t=e.split("."),i=[],s=0;s 默认设置
状态码:{{options.statusCode}} / 提示内容:[{{options.body.length}}字符][无] / 超时时间:{{options.timeout}}秒 diff --git a/web/public/js/components.src.js b/web/public/js/components.src.js index 9fb9f3cd..a8e185ae 100755 --- a/web/public/js/components.src.js +++ b/web/public/js/components.src.js @@ -8737,6 +8737,18 @@ Vue.component("http-access-log-box", { }) } + // 域名 + accessLog.unicodeHost = "" + if (accessLog.host != null && accessLog.host.startsWith("xn--")) { + // port + let portIndex = accessLog.host.indexOf(":") + if (portIndex > 0) { + accessLog.unicodeHost = punycode.ToUnicode(accessLog.host.substring(0, portIndex)) + } else { + accessLog.unicodeHost = punycode.ToUnicode(accessLog.host) + } + } + return { accessLog: accessLog } @@ -8789,8 +8801,19 @@ Vue.component("http-access-log-box", { [服务] [服务] - [{{accessLog.region}}] {{accessLog.remoteAddr}} [{{accessLog.timeLocal}}] "{{accessLog.requestMethod}} {{accessLog.scheme}}://{{accessLog.host}}{{accessLog.requestURI}} {{accessLog.proto}}" {{accessLog.status}} cache {{accessLog.attrs['cache.status'].toLowerCase()}} waf {{accessLog.firewallActions}} - {{tag}} + [{{accessLog.region}}] + {{accessLog.remoteAddr}} [{{accessLog.timeLocal}}] "{{accessLog.requestMethod}} {{accessLog.scheme}}://{{accessLog.host}}{{accessLog.requestURI}} {{accessLog.proto}}" {{accessLog.status}} + {{accessLog.unicodeHost}} + + + cache {{accessLog.attrs['cache.status'].toLowerCase()}} + + waf {{accessLog.firewallActions}} + + + - {{tag}} + @@ -8809,6 +8832,333 @@ Vue.component("http-access-log-box", {
` }) +// Javascript Punycode converter derived from example in RFC3492. +// This implementation is created by some@domain.name and released into public domain +// 代码来自:https://stackoverflow.com/questions/183485/converting-punycode-with-dash-character-to-unicode +var punycode = new function Punycode() { + // This object converts to and from puny-code used in IDN + // + // punycode.ToASCII ( domain ) + // + // Returns a puny coded representation of "domain". + // It only converts the part of the domain name that + // has non ASCII characters. I.e. it dosent matter if + // you call it with a domain that already is in ASCII. + // + // punycode.ToUnicode (domain) + // + // Converts a puny-coded domain name to unicode. + // It only converts the puny-coded parts of the domain name. + // I.e. it dosent matter if you call it on a string + // that already has been converted to unicode. + // + // + this.utf16 = { + // The utf16-class is necessary to convert from javascripts internal character representation to unicode and back. + decode: function (input) { + var output = [], i = 0, len = input.length, value, extra; + while (i < len) { + value = input.charCodeAt(i++); + if ((value & 0xF800) === 0xD800) { + extra = input.charCodeAt(i++); + if (((value & 0xFC00) !== 0xD800) || ((extra & 0xFC00) !== 0xDC00)) { + throw new RangeError("UTF-16(decode): Illegal UTF-16 sequence"); + } + value = ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000; + } + output.push(value); + } + return output; + }, + encode: function (input) { + var output = [], i = 0, len = input.length, value; + while (i < len) { + value = input[i++]; + if ((value & 0xF800) === 0xD800) { + throw new RangeError("UTF-16(encode): Illegal UTF-16 value"); + } + if (value > 0xFFFF) { + value -= 0x10000; + output.push(String.fromCharCode(((value >>> 10) & 0x3FF) | 0xD800)); + value = 0xDC00 | (value & 0x3FF); + } + output.push(String.fromCharCode(value)); + } + return output.join(""); + } + } + + //Default parameters + var initial_n = 0x80; + var initial_bias = 72; + var delimiter = "\x2D"; + var base = 36; + var damp = 700; + var tmin = 1; + var tmax = 26; + var skew = 38; + var maxint = 0x7FFFFFFF; + + // decode_digit(cp) returns the numeric value of a basic code + // point (for use in representing integers) in the range 0 to + // base-1, or base if cp is does not represent a value. + + function decode_digit(cp) { + return cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 : cp - 97 < 26 ? cp - 97 : base; + } + + // encode_digit(d,flag) returns the basic code point whose value + // (when used for representing integers) is d, which needs to be in + // the range 0 to base-1. The lowercase form is used unless flag is + // nonzero, in which case the uppercase form is used. The behavior + // is undefined if flag is nonzero and digit d has no uppercase form. + + function encode_digit(d, flag) { + return d + 22 + 75 * (d < 26) - ((flag != 0) << 5); + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + } + + //** Bias adaptation function ** + function adapt(delta, numpoints, firsttime) { + var k; + delta = firsttime ? Math.floor(delta / damp) : (delta >> 1); + delta += Math.floor(delta / numpoints); + + for (k = 0; delta > (((base - tmin) * tmax) >> 1); k += base) { + delta = Math.floor(delta / (base - tmin)); + } + return Math.floor(k + (base - tmin + 1) * delta / (delta + skew)); + } + + // encode_basic(bcp,flag) forces a basic code point to lowercase if flag is zero, + // uppercase if flag is nonzero, and returns the resulting code point. + // The code point is unchanged if it is caseless. + // The behavior is undefined if bcp is not a basic code point. + + function encode_basic(bcp, flag) { + bcp -= (bcp - 97 < 26) << 5; + return bcp + ((!flag && (bcp - 65 < 26)) << 5); + } + + // Main decode + this.decode = function (input, preserveCase) { + // Dont use utf16 + var output = []; + var case_flags = []; + var input_length = input.length; + + var n, out, i, bias, basic, j, ic, oldi, w, k, digit, t, len; + + // Initialize the state: + + n = initial_n; + i = 0; + bias = initial_bias; + + // Handle the basic code points: Let basic be the number of input code + // points before the last delimiter, or 0 if there is none, then + // copy the first basic code points to the output. + + basic = input.lastIndexOf(delimiter); + if (basic < 0) basic = 0; + + for (j = 0; j < basic; ++j) { + if (preserveCase) case_flags[output.length] = (input.charCodeAt(j) - 65 < 26); + if (input.charCodeAt(j) >= 0x80) { + throw new RangeError("Illegal input >= 0x80"); + } + output.push(input.charCodeAt(j)); + } + + // Main decoding loop: Start just after the last delimiter if any + // basic code points were copied; start at the beginning otherwise. + + for (ic = basic > 0 ? basic + 1 : 0; ic < input_length;) { + + // ic is the index of the next character to be consumed, + + // Decode a generalized variable-length integer into delta, + // which gets added to i. The overflow checking is easier + // if we increase i as we go, then subtract off its starting + // value at the end to obtain delta. + for (oldi = i, w = 1, k = base; ; k += base) { + if (ic >= input_length) { + throw RangeError("punycode_bad_input(1)"); + } + digit = decode_digit(input.charCodeAt(ic++)); + + if (digit >= base) { + throw RangeError("punycode_bad_input(2)"); + } + if (digit > Math.floor((maxint - i) / w)) { + throw RangeError("punycode_overflow(1)"); + } + i += digit * w; + t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias; + if (digit < t) { + break; + } + if (w > Math.floor(maxint / (base - t))) { + throw RangeError("punycode_overflow(2)"); + } + w *= (base - t); + } + + out = output.length + 1; + bias = adapt(i - oldi, out, oldi === 0); + + // i was supposed to wrap around from out to 0, + // incrementing n each time, so we'll fix that now: + if (Math.floor(i / out) > maxint - n) { + throw RangeError("punycode_overflow(3)"); + } + n += Math.floor(i / out); + i %= out; + + // Insert n at position i of the output: + // Case of last character determines uppercase flag: + if (preserveCase) { + case_flags.splice(i, 0, input.charCodeAt(ic - 1) - 65 < 26); + } + + output.splice(i, 0, n); + i++; + } + if (preserveCase) { + for (i = 0, len = output.length; i < len; i++) { + if (case_flags[i]) { + output[i] = (String.fromCharCode(output[i]).toUpperCase()).charCodeAt(0); + } + } + } + return this.utf16.encode(output); + }; + + //** Main encode function ** + + this.encode = function (input, preserveCase) { + //** Bias adaptation function ** + + var n, delta, h, b, bias, j, m, q, k, t, ijv, case_flags; + + if (preserveCase) { + // Preserve case, step1 of 2: Get a list of the unaltered string + case_flags = this.utf16.decode(input); + } + // Converts the input in UTF-16 to Unicode + input = this.utf16.decode(input.toLowerCase()); + + var input_length = input.length; // Cache the length + + if (preserveCase) { + // Preserve case, step2 of 2: Modify the list to true/false + for (j = 0; j < input_length; j++) { + case_flags[j] = input[j] != case_flags[j]; + } + } + + var output = []; + + + // Initialize the state: + n = initial_n; + delta = 0; + bias = initial_bias; + + // Handle the basic code points: + for (j = 0; j < input_length; ++j) { + if (input[j] < 0x80) { + output.push( + String.fromCharCode( + case_flags ? encode_basic(input[j], case_flags[j]) : input[j] + ) + ); + } + } + + h = b = output.length; + + // h is the number of code points that have been handled, b is the + // number of basic code points + + if (b > 0) output.push(delimiter); + + // Main encoding loop: + // + while (h < input_length) { + // All non-basic code points < n have been + // handled already. Find the next larger one: + + for (m = maxint, j = 0; j < input_length; ++j) { + ijv = input[j]; + if (ijv >= n && ijv < m) m = ijv; + } + + // Increase delta enough to advance the decoder's + // state to , but guard against overflow: + + if (m - n > Math.floor((maxint - delta) / (h + 1))) { + throw RangeError("punycode_overflow (1)"); + } + delta += (m - n) * (h + 1); + n = m; + + for (j = 0; j < input_length; ++j) { + ijv = input[j]; + + if (ijv < n) { + if (++delta > maxint) return Error("punycode_overflow(2)"); + } + + if (ijv == n) { + // Represent delta as a generalized variable-length integer: + for (q = delta, k = base; ; k += base) { + t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias; + if (q < t) break; + output.push(String.fromCharCode(encode_digit(t + (q - t) % (base - t), 0))); + q = Math.floor((q - t) / (base - t)); + } + output.push(String.fromCharCode(encode_digit(q, preserveCase && case_flags[j] ? 1 : 0))); + bias = adapt(delta, h + 1, h == b); + delta = 0; + ++h; + } + } + + ++delta, ++n; + } + return output.join(""); + } + + this.ToASCII = function (domain) { + var domain_array = domain.split("."); + var out = []; + for (var i = 0; i < domain_array.length; ++i) { + var s = domain_array[i]; + out.push( + s.match(/[^A-Za-z0-9-]/) ? + "xn--" + punycode.encode(s) : + s + ); + } + return out.join("."); + } + this.ToUnicode = function (domain) { + var domain_array = domain.split("."); + var out = []; + for (var i = 0; i < domain_array.length; ++i) { + var s = domain_array[i]; + out.push( + s.match(/^xn--/) ? + punycode.decode(s.slice(4)) : + s + ); + } + return out.join("."); + } +}(); + Vue.component("http-firewall-block-options-viewer", { props: ["v-block-options"], data: function () { diff --git a/web/views/@default/dns/providers/createPopup.html b/web/views/@default/dns/providers/createPopup.html index 3efc3302..7a4c50ad 100644 --- a/web/views/@default/dns/providers/createPopup.html +++ b/web/views/@default/dns/providers/createPopup.html @@ -191,7 +191,7 @@ - + 选择域名服务集群 * @@ -204,6 +204,37 @@ + + + + API地址 * + + + + + + AccessKey类型 * + + + + + + AccessKey ID * + + + + + + AccessKey密钥 * + + + + + + diff --git a/web/views/@default/dns/providers/provider.html b/web/views/@default/dns/providers/provider.html index fe84e204..bc54a7ac 100644 --- a/web/views/@default/dns/providers/provider.html +++ b/web/views/@default/dns/providers/provider.html @@ -148,6 +148,29 @@ + + + + API地址 + {{provider.apiParams.host}} + + + AccessKey类型 + + 平台用户 + 管理员 + + + + AccessKey ID + {{provider.apiParams.accessKeyId}} + + + AccessKey密钥 + {{provider.apiParams.accessKeySecret}} + + + diff --git a/web/views/@default/dns/providers/updatePopup.html b/web/views/@default/dns/providers/updatePopup.html index 2af5e779..b5b3346c 100644 --- a/web/views/@default/dns/providers/updatePopup.html +++ b/web/views/@default/dns/providers/updatePopup.html @@ -191,7 +191,7 @@ - + 选择域名服务集群 * @@ -204,6 +204,38 @@ + + + + + API地址 * + + + + + + AccessKey类型 * + + + + + + AccessKey ID * + + + + + + AccessKey密钥 * + + + + + +