1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
"use strict";(()=>{var e={};e.id=3821,e.ids=[636,3821],e.modules={30671:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,t){return t in r?r[t]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,t)):"function"==typeof r&&"default"===t?r:void 0}}})},17021:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.r(r),t.d(r,{config:()=>y,default:()=>p,getServerSideProps:()=>h,getStaticPaths:()=>x,getStaticProps:()=>d,reportWebVitals:()=>m,routeModule:()=>q,unstable_getServerProps:()=>v,unstable_getServerSideProps:()=>A,unstable_getStaticParams:()=>S,unstable_getStaticPaths:()=>f,unstable_getStaticProps:()=>g});var i=t(63865),a=t(9455),n=t(30671),o=t(49407),u=t(68268),l=t(95376),c=e([l]);l=(c.then?(await c)():c)[0];let p=(0,n.M)(l,"default"),d=(0,n.M)(l,"getStaticProps"),x=(0,n.M)(l,"getStaticPaths"),h=(0,n.M)(l,"getServerSideProps"),y=(0,n.M)(l,"config"),m=(0,n.M)(l,"reportWebVitals"),g=(0,n.M)(l,"unstable_getStaticProps"),f=(0,n.M)(l,"unstable_getStaticPaths"),S=(0,n.M)(l,"unstable_getStaticParams"),v=(0,n.M)(l,"unstable_getServerProps"),A=(0,n.M)(l,"unstable_getServerSideProps"),q=new i.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/su/servers",pathname:"/su/servers",bundlePath:"",filename:""},components:{App:u.default,Document:o.default},userland:l});s()}catch(e){s(e)}})},94010:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>u});var i=t(8732);t(82015);var a=t(96089),n=t(75979),o=e([n]);function u({slugText:e,justIcon:r,noIcon:t,title:s,outlined:o,extraClasses:u}){return(0,i.jsxs)("div",{className:(0,n.twMerge)("button small-text",o?" outlined gray bg-white":" ghost light-gray",u),onClick:r=>{navigator.clipboard.writeText(e).then(()=>{alert(`Copied: "${e}"`)})},style:o?void 0:{padding:0},children:[!t&&(0,i.jsx)(a.A,{size:o?15:20}),!r&&(0,i.jsx)("span",{className:"text-slate-500 dark:text-slate-300",children:s||"Copy Slug"})]})}n=(o.then?(await o)():o)[0],s()}catch(e){s(e)}})},77306:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>l});var i=t(8732),a=t(94010),n=t(2459),o=t(75979),u=e([a,o]);function l({server:e,noLoadBalance:r}){return(0,i.jsxs)("div",{className:"stack w-full",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)(n.A,{size:15,opacity:.5}),(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{children:e.host}),r?(0,i.jsx)(i.Fragment,{}):e.loadBalanced?(0,i.jsx)("span",{className:"info green small",children:"Load Balanced"}):(0,i.jsx)("button",{children:"Add to Load Balancer"})]})]}),(0,i.jsx)("div",{className:(0,o.twMerge)("stack border-0 border-l border-solid border-s-slate-200 dark:border-white/20","pl-6 ml-2 -mt-4 pt-2 w-full gap-0"),children:(0,i.jsx)("ul",{className:"p-0 m-0 pl-4",children:e.users?.map((e,r)=>i.jsx(c,{user:e},r))})})]})}function c({user:e}){return(0,i.jsx)("li",{className:(0,o.twMerge)("w-full"),children:(0,i.jsxs)("div",{className:"stack gap-0",children:[(0,i.jsxs)("span",{children:["user: ",(0,i.jsx)("b",{children:e.name})]}),(0,i.jsxs)("span",{children:["pass:"," ",(0,i.jsx)("b",{children:(0,i.jsx)(a.A,{slugText:e.password,title:"********",extraClasses:"inline",noIcon:!0})})]})]})})}[a,o]=u.then?(await u)():u,s()}catch(e){s(e)}})},2419:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>c});var i=t(8732),a=t(68268),n=t(82015),o=t.n(n),u=t(77306),l=e([u]);function c(){let e=o().useContext(a.AppContext).pageProps;e.user;let r=e.servers;return(0,i.jsxs)(o().Fragment,{children:[(0,i.jsxs)("div",{className:"w-full justify-between",children:[(0,i.jsxs)("div",{className:"flex-col items-start gap-2",children:[(0,i.jsx)("h2",{className:"text-xl m-0",children:"Servers"}),(0,i.jsx)("span",{children:"All Servers"})]}),(0,i.jsx)("div",{children:(0,i.jsx)("button",{children:"Add Server"})})]}),(0,i.jsxs)("section",{className:"paper",children:[(0,i.jsx)("div",{className:"flex flex-col gap-2 w-full",children:r.map((e,r)=>(0,i.jsx)(u.A,{server:e,noLoadBalance:!0},r))}),(0,i.jsx)("button",{className:"w-full outlined dashed gray",children:"Add Server"})]})]})}u=(l.then?(await l)():l)[0],s()}catch(e){s(e)}})},92127:(e,r,t)=>{t(33873);let s=t(29021);t(56248);let i=t(70956);e.exports=function(){try{let e=i();if(!s.existsSync(e.path)){let r={host:String(process.env.DSQL_DB_TARGET_IP_ADDRESS),port:3306,primary:!0,loadBalanced:!0,users:[{host:String(process.env.DSQL_DB_HOST),name:"root",password:process.env.DSQL_MARIADB_ROOT_PASSWORD||"password"}]};s.writeFileSync(e.path,JSON.stringify([r]))}return!0}catch(e){return console.log(`Error checking servers ${e.message}`),!1}}},70956:(e,r,t)=>{let s=t(33873);e.exports=function(){let e=process.env.DSQL_SU_USER_ID||"1",r=s.resolve(process.cwd(),`./jsonData/dbSchemas/users/user-${e}`),t=`${r}/servers.json`;return{dir:r,path:t}}},31511:(e,r,t)=>{t(33873);let s=t(29021),i=t(56248),a=t(92127),n=t(70956);e.exports=function(){try{a();let e=n();return i.parse(s.readFileSync(e.path,"utf-8"))}catch(e){console.log(`Error getting servers ${e.message}`);return}}},67105:(e,r,t)=>{t.d(r,{A:()=>s});let s=(0,t(82544).A)("CloudUpload",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M12 12v9",key:"192myk"}],["path",{d:"m16 16-4-4-4 4",key:"119tzi"}]])},96089:(e,r,t)=>{t.d(r,{A:()=>s});let s=(0,t(82544).A)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},26628:(e,r,t)=>{t.d(r,{A:()=>s});let s=(0,t(82544).A)("DatabaseBackup",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 12a9 3 0 0 0 5 2.69",key:"1ui2ym"}],["path",{d:"M21 9.3V5",key:"6k6cib"}],["path",{d:"M3 5v14a9 3 0 0 0 6.47 2.88",key:"i62tjy"}],["path",{d:"M12 12v4h4",key:"1bxaet"}],["path",{d:"M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16",key:"1f4ei9"}]])},34479:(e,r,t)=>{t.d(r,{A:()=>s});let s=(0,t(82544).A)("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},20427:(e,r,t)=>{t.d(r,{A:()=>s});let s=(0,t(82544).A)("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]])},62011:(e,r,t)=>{t.d(r,{A:()=>s});let s=(0,t(82544).A)("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]])},2459:(e,r,t)=>{t.d(r,{A:()=>s});let s=(0,t(82544).A)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},80006:(e,r,t)=>{t.d(r,{A:()=>s});let s=(0,t(82544).A)("SquareChevronRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]])},25294:(e,r,t)=>{t.d(r,{A:()=>s});let s=(0,t(82544).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},67216:(e,r,t)=>{let s=t(9973),i=t(31976),a=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:i()}});async function n(...e){try{let r=await a.query(...e);return await a.end(),JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=n},31976:(e,r,t)=>{let s=t(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let r=`${e}/ca-cert.pem`;if(!s.existsSync(r)){console.log(`${r} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}},56248:e=>{e.exports={parse:function(e,r){if(e){if("object"==typeof e)return e;if("string"==typeof e)try{return JSON.parse(e,r)}catch(e){return}}},stringify:function(e,r,t){try{return JSON.stringify(e,r,t)}catch(e){return}}}},95376:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.r(r),t.d(r,{default:()=>v,getServerSideProps:()=>A});var i=t(8732);t(82015);var a=t(29021),n=t.n(a),o=t(93615),u=t.n(o),l=t(64987),c=t(31511),p=t.n(c),d=t(2419),x=t(67216),h=t.n(x),y=t(33873),m=t.n(y),g=t(56248),f=t.n(g),S=e([d]);function v({user:e,data:r}){let t=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("title",{children:"Load Balancing"}),(0,i.jsx)("meta",{name:"description",content:"Distribute db load accross servers"})]});return(0,i.jsx)(l.A,{head:t,user:e,children:(0,i.jsx)(d.A,{})})}async function A({req:e,res:r,query:t}){try{let r=await u()(e);if(!r?.logged_in_status)return{redirect:{destination:"/su/login",permanent:!1}};let t=p()();if(!t)throw Error("No servers found");t.find(e=>e.primary);let s=(await h()("SELECT user,host,password FROM mysql.user")).filter(e=>e.User.match(/^dsql_user|^root/i));return n().writeFileSync(m().resolve(process.cwd(),"./.tmp/wrt.json"),String(f().stringify(s,null,4)),"utf8"),{props:{user:r,servers:t}}}catch(e){return{redirect:{destination:"/su",permanent:!1}}}}d=(S.then?(await S)():S)[0],s()}catch(e){s(e)}})},9455:(e,r)=>{var t;Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(t||(t={}))},66099:e=>{e.exports=require("@mui/system")},37616:e=>{e.exports=require("@mui/system/DefaultPropsProvider")},24509:e=>{e.exports=require("@mui/system/InitColorSchemeScript")},84781:e=>{e.exports=require("@mui/system/colorManipulator")},18215:e=>{e.exports=require("@mui/system/createStyled")},59989:e=>{e.exports=require("@mui/system/createTheme")},16670:e=>{e.exports=require("@mui/system/styleFunctionSx")},88698:e=>{e.exports=require("@mui/system/useThemeProps")},76831:e=>{e.exports=require("@mui/utils")},28578:e=>{e.exports=require("@mui/utils/capitalize")},14036:e=>{e.exports=require("@mui/utils/composeClasses")},31112:e=>{e.exports=require("@mui/utils/createChainedFunction")},21763:e=>{e.exports=require("@mui/utils/debounce")},7546:e=>{e.exports=require("@mui/utils/deepmerge")},5928:e=>{e.exports=require("@mui/utils/deprecatedPropType")},20985:e=>{e.exports=require("@mui/utils/formatMuiErrorMessage")},61119:e=>{e.exports=require("@mui/utils/generateUtilityClass")},81699:e=>{e.exports=require("@mui/utils/generateUtilityClasses")},29823:e=>{e.exports=require("@mui/utils/isMuiElement")},55402:e=>{e.exports=require("@mui/utils/ownerDocument")},46875:e=>{e.exports=require("@mui/utils/ownerWindow")},48080:e=>{e.exports=require("@mui/utils/requirePropFactory")},39597:e=>{e.exports=require("@mui/utils/setRef")},88190:e=>{e.exports=require("@mui/utils/unsupportedProp")},83889:e=>{e.exports=require("@mui/utils/useControlled")},21956:e=>{e.exports=require("@mui/utils/useEnhancedEffect")},4926:e=>{e.exports=require("@mui/utils/useEventCallback")},7376:e=>{e.exports=require("@mui/utils/useForkRef")},63310:e=>{e.exports=require("@mui/utils/useId")},10977:e=>{e.exports=require("@mui/utils/useIsFocusVisible")},74956:e=>{e.exports=require("clsx")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},29825:e=>{e.exports=require("prop-types")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},8732:e=>{e.exports=require("react/jsx-runtime")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},75979:e=>{e.exports=import("tailwind-merge")}};var r=require("../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[9764,883,8268,615],()=>t(17021));module.exports=s})(); |