dispath优化

This commit is contained in:
UnKownOwO
2023-03-18 18:33:58 +08:00
parent fd0bd712c9
commit 93a72f797a
10 changed files with 458 additions and 145 deletions

View File

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

View File

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,346 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta name="viewport" id="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<title>请通过以下验证</title>
<style>
body {
margin: 0;
}
.title {
margin: 15px;
font-size: 18px;
line-height: 18px;
height: 18px;
}
#log {
margin: 10px;
display: none;
word-break: break-all;
}
#log.log {
display: block;
}
#log p {
}
#loading {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: none;
}
</style>
</head>
<body>
<div id="captcha"></div>
<div id="log"></div>
<div id="loading">
<svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
<path fill="#c7c5c5" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z" transform="rotate(340 25 25)">
<animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform>
</path>
</svg>
</div>
<script>
var debug = false;
var setDebug = function () {
debug = true;
logEle.className = 'log';
};
var log = function (str) {
if (!debug) {
return;
}
var p = document.createElement('p');
p.appendChild(document.createTextNode(str));
logEle.insertBefore(p, logEle.firstChild);
};
var captcha = document.getElementById('captcha');
var logEle = document.getElementById('log');
var loadingEle = document.getElementById('loading');
var head = document.getElementsByTagName('head')[0];
var query = location.href.split('?')[1];
if (!query) {
setDebug();
log('no query: ' + location.href);
}
var parse = function (str) {
var args = {};
var items = str.split('&');
for (var i = 0, len = items.length; i < len; i = i + 1) {
var temp = items[i].split('=');
args[temp[0]] = temp[1];
}
return args;
};
var args = parse(query);
if (args['title'] && args['title'] != "") {
var h3 = document.createElement('h3');
h3.className = 'title';
h3.appendChild(document.createTextNode(decodeURIComponent(args['title'])));
captcha.appendChild(h3);
}
if (!args['gt']
|| !args['challenge']
|| !args['type']
|| !args[args['type']]) {
setDebug(true);
log('args error: ' + query);
}
if (args['debug'] === 'true'
|| args['debug'] === '1') {
setDebug(true);
log(JSON.stringify(args));
}
if (debug) {
window.startTime = (new Date()).getTime();
}
var config = {
is_next: true,
mobile: true,
product: 'embed',
width: '100%',
https: location.protocol === 'https:'
};
for (var k in args) {
if (args.hasOwnProperty(k) &&
['debug', 'title', 'static_servers', args['type']].indexOf(k) === -1) {
config[k] = args[k];
}
}
var js = args[args['type']];
var static_servers = ['static.geetest.com', 'dn-staticdown.qbox.me'];
if (args['static_servers']) {
static_servers = args['static_servers'].replace(/ /g, '').split(',');
}
var errorHandler = function (err) {
log('Error Ocurred.');
try {
if (typeof JSInterface !== 'undefined') {
if (typeof JSInterface.gtError === 'function') {
JSInterface.gtError();
}
if (typeof JSInterface.gt3Error === 'function') {
JSInterface.gt3Error(JSON.stringify(err))
}
}
loadingEle.style.display = 'none'
} catch (e) {
log(e.name + ': ' + e.message);
}
try {
if (window.webkit
&& window.webkit.messageHandlers) {
err = err || {};
err.error = '1';
var message = JSON.stringify(err);
if (window.webkit.messageHandlers.gtError) {
window.webkit.messageHandlers.gtError.postMessage(message);
}
if (window.webkit.messageHandlers.gt3Error) {
window.webkit.messageHandlers.gt3Error.postMessage(message);
}
}
} catch (e) {
log(e.name + ': ' + e.message);
}
};
config.onError = errorHandler;
var handler = function (config) {
if (config.type === 'slide') {
config.type = 'slide3';
}
var captchaObj = new window.Geetest(config);
captchaObj.appendTo(captcha);
captchaObj.onSuccess(function () {
var result = JSON.stringify(captchaObj.getValidate());
log('Success validate: ' + result);
try {
if (typeof JSInterface !== 'undefined') {
JSInterface.gtCallBack('1', result, 'Success');
}
} catch (e) {
log(e.name + ': ' + e.message);
}
try {
if (window.webkit && window.webkit.messageHandlers) {
message = JSON.stringify({
code: '1',
result: result,
message: 'Success'
});
window.webkit.messageHandlers.wkWebview.postMessage(message);
}
} catch (e) {
log(e.name + ': ' + e.message);
}
});
captchaObj.onFail(function () {
var result = JSON.stringify({
geetest_challenge: ""
});
try {
if (typeof JSInterface !== 'undefined') {
JSInterface.gtCallBack('0', result, 'Fail');
}
} catch (e) {
log(e.name + ': ' + e.message);
}
try {
if (window.webkit && window.webkit.messageHandlers) {
message = JSON.stringify({
code: '0',
result: result,
message: 'Fail'
});
window.webkit.messageHandlers.wkWebview.postMessage(message);
}
} catch (e) {
log(e.name + ': ' + e.message);
}
});
captchaObj.onReady(function () {
log('load time: ' + ((new Date()).getTime() - (window.startTime || 0)));
log('Ready');
try {
loadingEle.style.display = 'none'
if (typeof JSInterface !== 'undefined') {
JSInterface.gtReady();
}
} catch (e) {
log(e.name + ': ' + e.message);
}
try {
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.gtReady) {
message = JSON.stringify({
ready: '0'
});
window.webkit.messageHandlers.gtReady.postMessage(message);
}
} catch (e) {
log(e.name + ': ' + e.message);
}
});
captchaObj.onClose(function () {
log('Close');
try {
if (typeof JSInterface !== 'undefined') {
JSInterface.gtClose();
}
} catch (e) {
log(e.name + ': ' + e.message);
}
try {
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.gtClose) {
window.webkit.messageHandlers.gtClose.postMessage(1);
}
} catch (e) {
log(e.name + ': ' + e.message);
}
});
captchaObj.onError(errorHandler);
if(typeof captchaObj.onChangeCaptcha === 'function'){
captchaObj.onChangeCaptcha(function (type) {
var notification = { aspect_radio: args[('aspect_radio_'+type)] }
try {
if (typeof JSInterface !== 'undefined') {
JSInterface.gtNotify(JSON.stringify(notification));
}
} catch (e) {
log(e.name + ': ' + e.message);
}
try {
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.gtNotify) {
window.webkit.messageHandlers.gtNotify.postMessage(JSON.stringify(notification));
}
} catch (e) {
log(e.name + ': ' + e.message);
}
loadingEle.style.display = 'block'
config.type = type
js = args[type]
init(js)
});
}
};
var normalizeDomain = function (domain) {
// return domain.replace(/^https?:\/\/|\/.*$/g, '');
// 将限制降弱些注意中山大学的域名uems.sysu.edu.cn/jwxt/geetest/
return domain.replace(/^https?:\/\/|\/$/g, '');
};
var normalizePath = function (path) {
path = path.replace(/\/+/g, '/');
if (path.indexOf('/') !== 0) {
path = '/' + path;
}
return path;
};
var loadJS = function (servers, path, test, callback) {
if (servers.length <= 0) {
callback(true);
return;
}
var s = document.createElement('script');
var loaded = false;
s.onload = s.onreadystatechange = function () {
if (!loaded &&
(!s.readyState
|| s.readyState === "loaded"
|| s.readyState === 'complete')) {
if (test()) {
loaded = true;
callback(null);
} else {
loadJS(servers.slice(1), path, test, callback);
head.removeChild(s);
}
}
};
s.onerror = function () {
loadJS(servers.slice(1), path, test, callback);
head.removeChild(s);
};
s.src = '//' + normalizeDomain(servers[0]) + normalizePath(path);
head.appendChild(s);
};
function init(js){
loadJS(static_servers, js, function () {
return window.Geetest;
}, function (err) {
if (err) {
log('load js err: static_servers=' + static_servers[0] + '&js=' + js);
errorHandler();
return;
}
handler(config);
});
}
init(js);
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -87,11 +87,11 @@ func (c *Controller) registerRouter() {
// 登录 // 登录
// hk4e-sdk-os.hoyoverse.com // hk4e-sdk-os.hoyoverse.com
// 账号登录 // 账号登录
engine.POST("/hk4e_global/mdk/shield/api/login", c.apiLogin) engine.POST("/hk4e_:name/mdk/shield/api/login", c.apiLogin)
// token登录 // token登录
engine.POST("/hk4e_global/mdk/shield/api/verify", c.apiVerify) engine.POST("/hk4e_:name/mdk/shield/api/verify", c.apiVerify)
// 获取combo token // 获取combo token
engine.POST("/hk4e_global/combo/granter/login/v2/login", c.v2Login) engine.POST("/hk4e_:name/combo/granter/login/v2/login", c.v2Login)
} }
{ {
// 日志 // 日志
@@ -101,39 +101,56 @@ func (c *Controller) registerRouter() {
engine.POST("/log", c.log8888) engine.POST("/log", c.log8888)
engine.POST("/crash/dataUpload", c.crashDataUpload) engine.POST("/crash/dataUpload", c.crashDataUpload)
} }
{
// 收集数据
engine.GET("/device-fp/api/getExtList", c.deviceExtList)
engine.POST("/device-fp/api/getFp", c.deviceFp)
}
{ {
// 返回固定数据 // 返回固定数据
// Windows // Windows
engine.GET("/hk4e_global/mdk/agreement/api/getAgreementInfos", c.getAgreementInfos) engine.GET("/hk4e_:name/mdk/agreement/api/getAgreementInfos", c.getAgreementInfos)
engine.POST("/hk4e_global/combo/granter/api/compareProtocolVersion", c.postCompareProtocolVersion) engine.POST("/hk4e_:name/combo/granter/api/compareProtocolVersion", c.postCompareProtocolVersion)
engine.POST("/account/risky/api/check", c.check) engine.POST("/account/risky/api/check", c.check)
engine.GET("/combo/box/api/config/sdk/combo", c.combo) engine.GET("/combo/box/api/config/sdk/combo", c.combo)
engine.GET("/hk4e_global/combo/granter/api/getConfig", c.getConfig) engine.GET("/hk4e_:name/combo/granter/api/getConfig", c.getConfig)
engine.GET("/hk4e_global/mdk/shield/api/loadConfig", c.loadConfig) engine.GET("/hk4e_:name/mdk/shield/api/loadConfig", c.loadConfig)
engine.POST("/data_abtest_api/config/experiment/list", c.list) engine.POST("/data_abtest_api/config/experiment/list", c.list)
engine.GET("/admin/mi18n/plat_oversea/m2020030410/m2020030410-version.json", c.version10Json)
engine.GET("/admin/mi18n/plat_oversea/m2020030410/m2020030410-zh-cn.json", c.zhCN10Json)
engine.GET("/geetestV2.html", c.geetestV2)
// Android // Android
engine.POST("/common/h5log/log/batch", c.batch) engine.POST("/common/h5log/log/batch", c.batch)
engine.GET("/hk4e_global/combo/granter/api/getFont", c.getFont) engine.GET("/hk4e_:name/combo/granter/api/getFont", c.getFont)
engine.GET("/admin/mi18n/plat_oversea/m202003049/m202003049-version.json", c.version9Json) }
engine.GET("/admin/mi18n/plat_oversea/m202003049/m202003049-zh-cn.json", c.zhCN9Json) {
engine.GET("/hk4e_global/combo/granter/api/compareProtocolVersion", c.getCompareProtocolVersion) // 静态资源
// GET https://webstatic-sea.hoyoverse.com/admin/mi18n/plat_oversea/m2020030410/m2020030410-version.json HTTP/1.1
// GET https://webstatic-sea.hoyoverse.com/admin/mi18n/plat_oversea/m2020030410/m2020030410-zh-cn.json HTTP/1.1
engine.StaticFS("/admin/mi18n/plat_oversea/m2020030410", http.Dir("./static/m2020030410"))
// GET https://webstatic-sea.hoyoverse.com/admin/mi18n/plat_os/m09291531181441/m09291531181441-version.json HTTP/1.1
// GET https://webstatic-sea.hoyoverse.com/admin/mi18n/plat_os/m09291531181441/m09291531181441-zh-cn.json HTTP/1.1
engine.StaticFS("/admin/mi18n/plat_os/m09291531181441", http.Dir("./static/m09291531181441"))
// GET https://webstatic-sea.hoyoverse.com/admin/mi18n/plat_oversea/m202003049/m202003049-version.json HTTP/1.1
// GET https://webstatic-sea.hoyoverse.com/admin/mi18n/plat_oversea/m202003049/m202003049-zh-cn.json HTTP/1.1
engine.StaticFS("/admin/mi18n/plat_oversea/m202003049", http.Dir("./static/m202003049"))
}
{
// geetest
engine.GET("/geetestV2.html", c.gtGeetestV2)
// Android geetest // Android geetest
engine.GET("/gettype.php", c.gettype) engine.GET("/favicon.ico", c.gtFaviconIco)
engine.GET("/get.php", c.get) engine.GET("/gettype.php", c.gtGetType)
engine.POST("/ajax.php", c.ajax) engine.GET("/get.php", c.gtGet)
engine.GET("/ajax.php", c.ajax) engine.POST("/ajax.php", c.gtAjax)
engine.GET("/static/appweb/app3-index.html", c.app3Index) engine.GET("/ajax.php", c.gtAjax)
engine.GET("/static/js/slide.7.8.6.js", c.slideJs) // GET https://static.geetest.com/static/appweb/app3-index.html?gt=16bddce04c7385dbb7282778c29bba3e&challenge=616018607b6940f52fbd349004038686&lang=zh-CN&title=&type=slide&api_server=api-na.geetest.com&static_servers=static.geetest.com,%20dn-staticdown.qbox.me&width=100%&timeout=10000&debug=false&aspect_radio_voice=128&aspect_radio_slide=103&aspect_radio_beeline=50&aspect_radio_pencil=128&aspect_radio_click=128&voice=/static/js/voice.1.2.0.js&slide=/static/js/slide.7.8.6.js&beeline=/static/js/beeline.1.0.1.js&pencil=/static/js/pencil.1.0.3.js&click=/static/js/click.3.0.4.js HTTP/1.1
engine.GET("/favicon.ico", c.faviconIco) // GET https://static.geetest.com/static/js/slide.7.8.6.js HTTP/1.1
engine.GET("/static/js/gct.e7810b5b525994e2fb1f89135f8df14a.js", c.js) // GET https://static.geetest.com/static/js/gct.e7810b5b525994e2fb1f89135f8df14a.js HTTP/1.1
engine.GET("/static/ant/style_https.1.2.6.css", c.css) // GET https://static.geetest.com/static/ant/style_https.1.2.6.css HTTP/1.1
engine.GET("/pictures/gt/a330cf996/a330cf996.webp", c.webp) // GET https://static.geetest.com/pictures/gt/a330cf996/a330cf996.webp HTTP/1.1
engine.GET("/pictures/gt/a330cf996/bg/86f9db021.webp", c.bgWebp) // GET https://static.geetest.com/pictures/gt/a330cf996/bg/86f9db021.webp HTTP/1.1
engine.GET("/pictures/gt/a330cf996/slice/86f9db021.png", c.slicePng) // GET https://static.geetest.com/pictures/gt/a330cf996/slice/86f9db021.png HTTP/1.1
engine.GET("/static/ant/sprite2x.1.2.6.png", c.sprite2xPng) // GET https://static.geetest.com/static/ant/sprite2x.1.2.6.png HTTP/1.1
engine.StaticFS("/static", http.Dir("./static/geetest/static"))
engine.StaticFS("/pictures", http.Dir("./static/geetest/pictures"))
} }
engine.Use(c.authorize()) engine.Use(c.authorize())
engine.POST("/gate/token/verify", c.gateTokenVerify) engine.POST("/gate/token/verify", c.gateTokenVerify)