1 line
7.5 KiB
JavaScript
1 line
7.5 KiB
JavaScript
"use strict";(()=>{var e={};e.id=3821,e.ids=[3821],e.modules={17021:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.r(r),t.d(r,{config:()=>g,default:()=>u,getServerSideProps:()=>x,getStaticPaths:()=>h,getStaticProps:()=>p,reportWebVitals:()=>S,routeModule:()=>_,unstable_getServerProps:()=>y,unstable_getServerSideProps:()=>j,unstable_getStaticParams:()=>f,unstable_getStaticPaths:()=>v,unstable_getStaticProps:()=>m});var a=t(63865),n=t(9455),i=t(30671),c=t(49407),o=t(89600),l=t(95376),d=e([l]);l=(d.then?(await d)():d)[0];let u=(0,i.M)(l,"default"),p=(0,i.M)(l,"getStaticProps"),h=(0,i.M)(l,"getStaticPaths"),x=(0,i.M)(l,"getServerSideProps"),g=(0,i.M)(l,"config"),S=(0,i.M)(l,"reportWebVitals"),m=(0,i.M)(l,"unstable_getStaticProps"),v=(0,i.M)(l,"unstable_getStaticPaths"),f=(0,i.M)(l,"unstable_getStaticParams"),y=(0,i.M)(l,"unstable_getServerProps"),j=(0,i.M)(l,"unstable_getServerSideProps"),_=new a.PagesRouteModule({definition:{kind:n.A.PAGES,page:"/su/servers",pathname:"/su/servers",bundlePath:"",filename:""},components:{App:o.default,Document:c.default},userland:l});s()}catch(e){s(e)}})},94010:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>o});var a=t(8732);t(82015);var n=t(96089),i=t(75979),c=e([i]);function o({slugText:e,justIcon:r,noIcon:t,title:s,outlined:c,extraClasses:o}){return(0,a.jsxs)("div",{className:(0,i.twMerge)("button small-text hover:!bg-transparent",c?" outlined gray bg-white":" ghost light-gray",o),onClick:r=>{navigator.clipboard.writeText(e).then(()=>{alert(`Copied: "${e}"`)})},style:c?void 0:{padding:0},children:[!t&&(0,a.jsx)(n.A,{size:c?15:20}),!r&&(0,a.jsx)("span",{className:"text-slate-500 dark:text-slate-300",children:s||"Copy Slug"})]})}i=(c.then?(await c)():c)[0],s()}catch(e){s(e)}})},77306:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>l});var a=t(8732),n=t(94010),i=t(2459),c=t(75979),o=e([n,c]);function l({server:e,noLoadBalance:r}){return(0,a.jsxs)("div",{className:"stack w-full",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(i.A,{size:15,opacity:.5}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:e.host}),r?(0,a.jsx)(a.Fragment,{}):e.loadBalanced?(0,a.jsx)("span",{className:"info green small",children:"Load Balanced"}):(0,a.jsx)("button",{children:"Add to Load Balancer"})]})]}),(0,a.jsx)("div",{className:(0,c.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,a.jsx)("ul",{className:"p-0 m-0 pl-4",children:e.users?.map((e,r)=>a.jsx(d,{user:e},r))})})]})}function d({user:e}){return(0,a.jsx)("li",{className:(0,c.twMerge)("w-full"),children:(0,a.jsxs)("div",{className:"stack gap-0",children:[(0,a.jsxs)("span",{children:["user: ",(0,a.jsx)("b",{children:e.name})]}),(0,a.jsxs)("span",{children:["pass:"," ",(0,a.jsx)("b",{children:(0,a.jsx)(n.A,{slugText:e.password,title:"********",extraClasses:"inline",noIcon:!0})})]})]})})}[n,c]=o.then?(await o)():o,s()}catch(e){s(e)}})},2419:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>d});var a=t(8732),n=t(89600),i=t(82015),c=t.n(i),o=t(77306),l=e([o]);function d(){let e=c().useContext(n.AppContext).pageProps;e.user;let r=e.servers;return(0,a.jsxs)(c().Fragment,{children:[(0,a.jsxs)("div",{className:"w-full justify-between",children:[(0,a.jsxs)("div",{className:"flex-col items-start gap-2",children:[(0,a.jsx)("h2",{className:"text-xl m-0",children:"Servers"}),(0,a.jsx)("span",{children:"All Servers"})]}),(0,a.jsx)("div",{children:(0,a.jsx)("button",{children:"Add Server"})})]}),(0,a.jsxs)("section",{className:"paper",children:[(0,a.jsx)("div",{className:"flex flex-col gap-2 w-full",children:r.map((e,r)=>(0,a.jsx)(o.A,{server:e,noLoadBalance:!0},r))}),(0,a.jsx)("button",{className:"w-full outlined dashed gray",children:"Add Server"})]})]})}o=(l.then?(await l)():l)[0],s()}catch(e){s(e)}})},92127:(e,r,t)=>{t(33873);let s=t(29021);t(56248);let a=t(70956);e.exports=function(){try{let e=a();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),a=t(56248),n=t(92127),i=t(70956);e.exports=function(){try{n();let e=i();return a.parse(s.readFileSync(e.path,"utf-8"))}catch(e){console.log(`Error getting servers ${e.message}`);return}}},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"}]])},67216:(e,r,t)=>{let s=t(9973),a=t(31976),n=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:a()}});async function i(...e){try{let r=await n.query(...e);return await n.end(),JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=i},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:()=>y,getServerSideProps:()=>j});var a=t(8732);t(82015);var n=t(29021),i=t.n(n),c=t(93615),o=t.n(c),l=t(49888),d=t(31511),u=t.n(d),p=t(2419),h=t(67216),x=t.n(h),g=t(33873),S=t.n(g),m=t(56248),v=t.n(m),f=e([p]);function y({user:e,data:r}){let t=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("title",{children:"Load Balancing"}),(0,a.jsx)("meta",{name:"description",content:"Distribute db load accross servers"})]});return(0,a.jsx)(l.A,{head:t,user:e,children:(0,a.jsx)(p.A,{})})}async function j({req:e,res:r,query:t}){try{let r=await o()(e);if(!r?.logged_in_status)return{redirect:{destination:"/su/login",permanent:!1}};let t=u()();if(!t)throw Error("No servers found");t.find(e=>e.primary);let s=(await x()("SELECT user,host,password FROM mysql.user")).filter(e=>e.User.match(/^dsql_user|^root/i));return i().writeFileSync(S().resolve(process.cwd(),"./.tmp/wrt.json"),String(v().stringify(s,null,4)),"utf8"),{props:{user:r,servers:t}}}catch(e){return{redirect:{destination:"/su",permanent:!1}}}}p=(f.then?(await f)():f)[0],s()}catch(e){s(e)}})},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},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,[883,9821,9600,3932],()=>t(17021));module.exports=s})(); |