t880216t-server 1.5.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +124 -0
- package/README.md +191 -0
- package/bin/nohost.js +178 -0
- package/bin/plugin.js +70 -0
- package/bin/util.js +93 -0
- package/index.js +89 -0
- package/lib/config.js +42 -0
- package/lib/index.js +205 -0
- package/lib/main/cgi/getSettings.js +11 -0
- package/lib/main/cgi/getVersion.js +12 -0
- package/lib/main/cgi/login.js +14 -0
- package/lib/main/cgi/restart.js +5 -0
- package/lib/main/cgi/setAdmin.js +6 -0
- package/lib/main/cgi/setDomain.js +13 -0
- package/lib/main/cgi/status.js +122 -0
- package/lib/main/index.js +94 -0
- package/lib/main/router.js +79 -0
- package/lib/main/storage.js +132 -0
- package/lib/main/util.js +138 -0
- package/lib/main/whistleMgr.js +56 -0
- package/lib/main/worker.js +52 -0
- package/lib/main/workerNum.js +11 -0
- package/lib/plugins/account/whistle.share/menu.html +171 -0
- package/lib/plugins/account/whistle.share/package.json +20 -0
- package/lib/plugins/account/whistle.storage/index.js +43 -0
- package/lib/plugins/account/whistle.storage/package.json +8 -0
- package/lib/plugins/account/whistle.storage/rules.txt +1 -0
- package/lib/plugins/whistle.nohost/_rules.txt +38 -0
- package/lib/plugins/whistle.nohost/index.js +3 -0
- package/lib/plugins/whistle.nohost/initial.js +9 -0
- package/lib/plugins/whistle.nohost/lib/accountMgr.js +750 -0
- package/lib/plugins/whistle.nohost/lib/envMgr.js +114 -0
- package/lib/plugins/whistle.nohost/lib/rulesServer.js +85 -0
- package/lib/plugins/whistle.nohost/lib/tunnelRulesServer.js +71 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/account/changePassword.js +8 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/activeAccount.js +9 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/addAccount.js +8 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/allAccounts.js +9 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/changeNotice.js +8 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/changePassword.js +8 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/enableGuest.js +5 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/getAuthKey.js +3 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/getSettings.js +22 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/login.js +14 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/move.js +9 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/removeAccount.js +9 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/setAccountRules.js +5 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/setAuthKey.js +5 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/setDefaultRules.js +5 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/setEntryPatterns.js +6 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/setJsonData.js +5 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/setRulesTpl.js +5 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/setTestRules.js +5 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/admin/specPattern.js +4 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/allowlist.js +4 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/entryRules.js +4 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/follow.js +17 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/getEnv.js +12 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/list.js +43 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/patterns.js +14 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/pluginRules.js +61 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/proxy.js +42 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/proxyNetwork.js +12 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/redirect.js +10 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/selectEnv.js +30 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/cgi/unfollow.js +4 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/index.js +60 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/network.js +38 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/openAPI.js +94 -0
- package/lib/plugins/whistle.nohost/lib/uiServer/router.js +85 -0
- package/lib/plugins/whistle.nohost/lib/util.js +230 -0
- package/lib/plugins/whistle.nohost/lib/whistle.js +149 -0
- package/lib/plugins/whistle.nohost/lib/whistleMgr.js +94 -0
- package/lib/plugins/whistle.nohost/package.json +7 -0
- package/lib/plugins/whistle.nohost/rules.txt +3 -0
- package/lib/service/cgi/export.js +76 -0
- package/lib/service/cgi/import.js +33 -0
- package/lib/service/cgi/util.js +35 -0
- package/lib/service/index.js +37 -0
- package/lib/service/router.js +7 -0
- package/lib/service/server.js +25 -0
- package/lib/util/address.js +55 -0
- package/lib/util/getPort.js +19 -0
- package/lib/util/login.js +55 -0
- package/lib/util/parseDomain.js +17 -0
- package/lib/whistle.js +86 -0
- package/package.json +135 -0
- package/pnpm-workspace.yaml +6 -0
- package/public/admin.75d42731d4aa7f7a558d3abf2a375fcb.js +2 -0
- package/public/admin.75d42731d4aa7f7a558d3abf2a375fcb.js.LICENSE.txt +76 -0
- package/public/admin.html +11 -0
- package/public/button.js +2 -0
- package/public/button.js.LICENSE.txt +31 -0
- package/public/capture.7bab900f27c9bb1b0e33523e994554ae.js +2 -0
- package/public/capture.7bab900f27c9bb1b0e33523e994554ae.js.LICENSE.txt +83 -0
- package/public/capture.html +11 -0
- package/public/eed368d0656f03932671530c3132ed61.svg +1 -0
- package/public/favicon.ico +0 -0
- package/public/network.e4814ec8c966a8a789296679619ec573.js +2 -0
- package/public/network.e4814ec8c966a8a789296679619ec573.js.LICENSE.txt +76 -0
- package/public/network.html +11 -0
- package/public/select.cb638be6656d02a558f2690acd59901a.js +2 -0
- package/public/select.cb638be6656d02a558f2690acd59901a.js.LICENSE.txt +24 -0
- package/public/select.html +26 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
const { Pool } = require('socketx');
|
|
3
|
+
const { encode } = require('simpleproto');
|
|
4
|
+
const crc32 = require('crc32');
|
|
5
|
+
|
|
6
|
+
const UID_RE = /^[\w.-]{1,64}$/;
|
|
7
|
+
|
|
8
|
+
exports.uiServer = (server, { data }) => {
|
|
9
|
+
const { storageServer } = data || '';
|
|
10
|
+
const len = storageServer && storageServer.length;
|
|
11
|
+
const rules = len ? '* whistle.storage:// includeFilter://reqH:x-whistle-nohost-storage-uid=/^[\\w.-]{1,64}$/' : '';
|
|
12
|
+
server.on('request', (_, res) => {
|
|
13
|
+
res.writeHead(200, { 'content-type': 'text/plain; charset=utf8' });
|
|
14
|
+
res.end(rules);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.resStatsServer = (server, { data }) => {
|
|
19
|
+
const { storageServer } = data || '';
|
|
20
|
+
const len = storageServer && storageServer.length;
|
|
21
|
+
if (!len) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const pool = new Pool();
|
|
25
|
+
storageServer.forEach((opt) => {
|
|
26
|
+
opt.idleTimeout = 30000;
|
|
27
|
+
});
|
|
28
|
+
server.on('request', (req) => {
|
|
29
|
+
req.getSession(async (s) => {
|
|
30
|
+
if (s) {
|
|
31
|
+
const uid = s.req.headers['x-whistle-nohost-storage-uid'];
|
|
32
|
+
if (!uid || !UID_RE.test(uid)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const index = len > 1 ? (parseInt(crc32(uid), 16) % len) : 0;
|
|
36
|
+
try {
|
|
37
|
+
const socket = await pool.connect(storageServer[index]);
|
|
38
|
+
socket.write(encode(s));
|
|
39
|
+
} catch (e) {}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@whistle.storage
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
``` whistle.nohost/inject.html
|
|
3
|
+
|
|
4
|
+
<script>
|
|
5
|
+
(function() {
|
|
6
|
+
if (typeof window === 'undefined' || !window || window.self !== window.top
|
|
7
|
+
|| window.__whistle_nohost_from_imweb_is_inited__) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
window.__whistle_nohost_from_imweb_is_inited__ = true;
|
|
11
|
+
var head = document.head || document.getElementsByTagName('head')[0] || document.documentElement;
|
|
12
|
+
var script = document.createElement('script');
|
|
13
|
+
var prefixPath = window.__WHISTLE_PATH_PREFIX__;
|
|
14
|
+
if (/^\/[\w./-]+$/.test(prefixPath) && prefixPath.length <= 128) {
|
|
15
|
+
var len = prefixPath.length - 1;
|
|
16
|
+
if (prefixPath[len] === '/') {
|
|
17
|
+
prefixPath = prefixPath.substring(0, len);
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
prefixPath = '';
|
|
21
|
+
}
|
|
22
|
+
script.defer = true;
|
|
23
|
+
script.charset = 'utf8';
|
|
24
|
+
script.src = prefixPath + '/.whistle-path.5b6af7b9884e1165/whistle.nohost/button.js';
|
|
25
|
+
if (head.firstChild) {
|
|
26
|
+
head.insertBefore(script, head.firstChild);
|
|
27
|
+
} else {
|
|
28
|
+
head.appendChild(script);
|
|
29
|
+
}
|
|
30
|
+
})();
|
|
31
|
+
</script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
``` whistle.nohost/none.html
|
|
35
|
+
<script>
|
|
36
|
+
window.__whistle_nohost_from_imweb_is_inited__ = true;
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const initAccountMgr = require('./lib/accountMgr');
|
|
2
|
+
const initEnvMgr = require('./lib/envMgr');
|
|
3
|
+
const { initPlugin } = require('./lib/util');
|
|
4
|
+
|
|
5
|
+
module.exports = (options) => {
|
|
6
|
+
initPlugin(options);
|
|
7
|
+
const accountMgr = initAccountMgr(options);
|
|
8
|
+
initEnvMgr(accountMgr);
|
|
9
|
+
};
|