This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
1 lines (1 loc) · 9.96 KB
/
app.js
1
(()=>{"use strict";var e={165:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(187);console.log(" _ _ _ _ _ \n /\\_\\/\\_\\ _ / /\\ / /\\ /\\ \\ \n / / / / //\\_\\ / / \\ / / \\ / \\ \\ \n /\\ \\/ \\ \\/ / // / /\\ \\__ / / /\\ \\__ / /\\ \\ \\ \n / \\____\\__/ // / /\\ \\___\\/ / /\\ \\___\\ / / /\\ \\ \\ \n / /\\/________/ \\ \\ \\ \\/___/\\ \\ \\ \\/___/ \\/_//_\\ \\ \\ \n / / /\\/_// / / \\ \\ \\ \\ \\ \\ __\\___ \\ \\ \n / / / / / /_ \\ \\ \\ _ \\ \\ \\ / /\\ \\ \\ \\ \n/ / / / / //_/\\__/ / / /_/\\__/ / / / /_/____\\ \\ \\ \n\\/_/ / / / \\ \\/___/ / \\ \\/___/ / /__________\\ \\ \\ \n \\/_/ \\_____\\/ \\_____\\/ _____________\\/ \n =-- MSS 3 Daemon --=\n"),console.log("[MSS 3] Powered By SkyWorldStudio"),console.log(`[MSS 3] Version: ${(0,s.getInfo)("version")}`),console.log("[MSS 3] Init Starting");const a=n(326);console.log("[MSS 3] Loading program settings"),(0,a.initUserConfig)(),a.userConfig.debug&&console.log("[MSS 3] Warning! Now in debugging mode, important information may be output. If not, please close this mode! ");const i=n(95);console.log("[MSS 3] "+(0,i.getMessage)("app.initLang"));const r=o(n(873));r.default.log((0,i.getMessage)("app.initLogger")),r.default.log((0,i.getMessage)("app.initOver")),r.default.debug("Server Config");const u=o(n(406)),l=o(n(4)),d=o(n(511)),f=o(n(685)),_=n(828),c=o(n(868)),g=o(n(33)),p=new u.default;p.keys=[(0,_.v4)()],p.use((0,d.default)({key:(0,_.v4)(),maxAge:864e5,overwrite:!0,httpOnly:!0,signed:!0,rolling:!1,renew:!1,secure:!1},p)),p.use((0,l.default)({multipart:!0,parsedMethods:["POST","PUT","DELETE","GET"]})),p.use((async(e,t)=>{r.default.info(`[Req] Method: ${e.method} URL: ${e.URL.href}`),r.default.info(`[Req] IP: ${e.ip} User: ${e.session.userName} UUID: ${e.session.uuid}`),await t()})),p.use(g.default),p.use(c.default.routes()).use(c.default.allowedMethods()),r.default.debug("Server Start");const S=f.default.createServer(p.callback()),y=a.userConfig.port,h=a.userConfig.address;S.listen(y,h),r.default.info("=----------------------------------------="),r.default.info((0,i.getMessage)("app.Started")),r.default.info((0,i.getMessage)("app.StartedTip")),r.default.info((0,i.getMessage)("app.StartedHost",{port:y})),r.default.info("=----------------------------------------=")},68:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=o(n(147)),a=o(n(17));t.default=new class{constructor(){this.CONFIG_PATH=a.default.join(process.cwd(),"data"),s.default.existsSync(this.CONFIG_PATH)||s.default.mkdirSync(this.CONFIG_PATH)}create(e,t,n){const o=a.default.join(this.CONFIG_PATH,e);if(s.default.existsSync(o)||s.default.mkdirSync(o),!this.checkFileName(t))throw new Error("Illegal profile name!");const i=JSON.stringify(n),r=a.default.join(o,t+".json");s.default.writeFileSync(r,i,{encoding:"utf-8"})}get(e,t,n){const o=a.default.join(this.CONFIG_PATH,e);if(s.default.existsSync(o)||s.default.mkdirSync(o),!this.checkFileName(n))throw new Error("Illegal profile name!");const i=a.default.join(o,n+".json");if(!s.default.existsSync(i))return null;const r=s.default.readFileSync(i,{encoding:"utf-8"}),u=JSON.parse(r);return this.JSONToClass(new t,u)}gets(e,t){const n=a.default.join(this.CONFIG_PATH,e);s.default.existsSync(n)||s.default.mkdirSync(n);const o=s.default.readdirSync(n),i=new Array;return o.forEach((e=>{if(e.endsWith(".json")){const o=s.default.readFileSync(a.default.join(n,e),{encoding:"utf-8"}),r=JSON.parse(o);i.push(this.JSONToClass(t,r))}})),i}set(e,t,n){const o=a.default.join(this.CONFIG_PATH,e);if(s.default.existsSync(o)||s.default.mkdirSync(o),!this.checkFileName(t))throw new Error("Illegal profile name!");s.default.writeFileSync(a.default.join(o,t+".json"),JSON.stringify(n),{encoding:"utf-8"})}JSONToClass(e,t){for(const n of Object.keys(e)){const o=t[n];void 0!==o&&(o instanceof Array?e[n]=o:o instanceof Object&&"object"==typeof o?this.JSONToClass(e[n],o):e[n]=o)}return e}checkFileName(e){const t=["\\","/",".."];for(const n of t)if(e.includes(n))return!1;return!0}}},873:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=o(n(94)),a=n(326);s.default.configure({appenders:{console:{type:"stdout",layout:{type:"pattern",pattern:"[%d{MM/dd hh:mm:ss}] [%[%p%]] %m"}},logFile:{type:"file",filename:"logs/last.log",layout:{type:"pattern",pattern:"%d %p %m"}}},categories:{default:{appenders:["console","logFile"],level:a.userConfig.debug?"debug":"info"}}});const i=s.default.getLogger("default");t.default=i},187:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getInfo=void 0;const s=o(n(147)),a="package.json";t.getInfo=function(e){if(s.default.existsSync(a)){const t=JSON.parse(s.default.readFileSync(a,{encoding:"utf-8"}));if(t[e])return t[e]}}},95:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.langs=t.i18n=t.getMessage=void 0;const s=o(n(805));t.i18n=s.default;const a=o(n(867)),i=o(n(438)),r=o(n(147)),u=o(n(17)),l=o(n(68));s.default.init({lng:"en_US",fallbackLng:["en_US"],resources:{zh_CN:{translation:a.default},en_US:{translation:i.default}}});const d=[{value:"en_US",name:"English (United States)",by:"SkyWorldStudio"},{value:"zh_CN",name:"简体中文",by:"SkyWorldStudio"}];t.langs=d;const f=u.default.join(l.default.CONFIG_PATH,"langs");r.default.existsSync(f)||r.default.mkdirSync(f);const _=r.default.readdirSync(f);let c="[MSS 3] Loaded Lang File: en_US, zh_CN";_.forEach((e=>{var t,n;if(e.endsWith(".json")){const o=e.replace(".json",""),a=r.default.readFileSync(u.default.join(f,e),{encoding:"utf-8"}),i=JSON.parse(a);s.default.addResourceBundle(o,"translation",i),s.default.reloadResources(),d.push({value:o,name:null!==(t=i.LangName)&&void 0!==t?t:"Unknown",by:null!==(n=i.LangBy)&&void 0!==n?n:"Unknown"}),c+=", "+o}})),console.log(c);const g=s.default.t;t.getMessage=g},33:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(781),a=o(n(873));t.default=async function(e,t){try{await t()}catch(t){e.body=t}if(e.cookies.set("ApplicationPowerBy","SkyWorldStudio"),e.cookies.set("Application","MinecraftServerStart3"),207!=e.status){if(e.body instanceof Error)return a.default.error(e.body),e.status=500,void(e.body=JSON.stringify({status:500,data:e.body.message,time:(new Date).getTime()}));if(!(e.body instanceof s.Stream)){if(404==e.status)return e.status=404,void(e.body=JSON.stringify({status:e.status,data:"404 Not Found",time:(new Date).getTime()}));if(400!=e.status&&403!=e.status){if("string"==typeof e.body)return e.status=200,void(e.body=JSON.stringify({status:200,data:e.body,time:(new Date).getTime()}));if(405!=e.status)return null===e.body||!1===e.body||void 0===e.body?(e.status=500,void(e.body=JSON.stringify({status:500,data:e.body||null,time:(new Date).getTime()}))):void(200!=e.status||(e.body=JSON.stringify({status:e.status,data:e.body,time:(new Date).getTime()})));e.body=JSON.stringify({status:e.status,data:"405 Method Not Allowed",time:(new Date).getTime()})}else e.body=JSON.stringify({status:e.status,data:e.body,time:(new Date).getTime()})}}}},648:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.language="en_US",this.port=2233,this.address="127.0.0.1",this.debug=!1}}},868:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(187),a=o(n(640)),i=o(n(873)),r=new a.default({prefix:"/"});i.default.debug("Register Router"),r.all("/",(async e=>(e.status=207,e.body=`MSS 3 Daemon Service v${(0,s.getInfo)("version")} | Powered By SkyWorldStudio`))),t.default=r},326:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.userConfig=t.save=t.initUserConfig=void 0;const s=o(n(68)),a=o(n(648)),i=n(95);let r=null;t.userConfig=r,t.initUserConfig=function(){t.userConfig=r=s.default.get("Configs",a.default,"default"),r||(t.userConfig=r=new a.default,s.default.create("Configs","default",r)),r.language&&i.i18n.changeLanguage(r.language)},t.save=function(){s.default.set("Configs","default",r)}},640:e=>{e.exports=require("@koa/router")},805:e=>{e.exports=require("i18next")},406:e=>{e.exports=require("koa")},4:e=>{e.exports=require("koa-body")},511:e=>{e.exports=require("koa-session")},94:e=>{e.exports=require("log4js")},828:e=>{e.exports=require("uuid")},147:e=>{e.exports=require("fs")},685:e=>{e.exports=require("http")},17:e=>{e.exports=require("path")},781:e=>{e.exports=require("stream")},438:e=>{e.exports=JSON.parse('{"app":{"initLang":"Internationalization system initialization complete, language: English (United States)","initLogger":"Logging system initialization finished","initOver":"Initialization completed","Started":"MSS3 Daemon Service is started!","StartedTip":"Press Ctrl + c to stop the Daemon","StartedHost":"Listening to http://localhost:{{port}}"}}')},867:e=>{e.exports=JSON.parse('{"app":{"initLang":"国际化系统初始化完成, 语言: 简体中文","initLogger":"日志系统初始化完成","initOver":"初始化完成","Started":"MSS 3 守护进程服务已启动!","StartedTip":"如果想退出 MSS 3 可以使用 ctrl + c 终止程序","StartedHost":"面板已经在 http://localhost:{{port}} 开始监听"}}')}},t={};!function n(o){var s=t[o];if(void 0!==s)return s.exports;var a=t[o]={exports:{}};return e[o].call(a.exports,a,a.exports,n),a.exports}(165)})();