├── README.md ├── build ├── 404.html ├── _next │ └── static │ │ ├── chunks │ │ ├── 164.9f581f85aa0d571e.js │ │ ├── 317.e12a4000786aeafa.js │ │ ├── 512-2ce2dcb10789f835.js │ │ ├── 514-fd1c040060a89e7b.js │ │ ├── 544.18101b48c2d33992.js │ │ ├── 626-3a496b4da8241c7a.js │ │ ├── 8a28b14e.65ae4fcead3c2f33.js │ │ ├── framework-3b5a00d5d7e8d93b.js │ │ ├── main-f2e125da23ccdc4a.js │ │ ├── pages │ │ │ ├── _app-f7bee06c13a5bbb0.js │ │ │ ├── _error-8353112a01355ec2.js │ │ │ ├── convert-config-43d546974a8bb1d5.js │ │ │ ├── index-e686d512e6270582.js │ │ │ ├── monitor-22c7e7c5e5692db0.js │ │ │ ├── pki-view-aadb21af8bc87747.js │ │ │ ├── setup-c915f8a2afc97173.js │ │ │ └── upstream-161a5bae7183a18f.js │ │ ├── polyfills-c67a75d1b6f99dc8.js │ │ └── webpack-b48a405952ad4f00.js │ │ └── dzaxkwXeM3rrxfcqjdkGw │ │ ├── _buildManifest.js │ │ └── _ssgManifest.js ├── convert-config.html ├── favicon.ico ├── index.html ├── monitor.html ├── pki-view.html ├── setup.html └── upstream.html ├── caddy_admin_ui.go ├── go.mod ├── go.sum └── screenshots ├── load.jpg ├── metrics.png ├── pki.jpg ├── upstream.jpg └── view.jpg /README.md: -------------------------------------------------------------------------------- 1 | # caddy-admin-ui 2 | 3 | Add a caddy http directive to serve a web ui for admin api. 4 | 5 | ## How to use 6 | 7 | Build caddy with this package 8 | 9 | ```bash 10 | xcaddy build --with github.com/gsmlg-dev/caddy-admin-ui@main 11 | ``` 12 | 13 | Add a http config 14 | 15 | ``` 16 | { 17 | admin localhost:2021 18 | } 19 | 20 | :2022 { 21 | route { 22 | caddy_admin_ui 23 | reverse_proxy localhost:2021 { 24 | header_up Host localhost:2021 25 | } 26 | } 27 | } 28 | ``` 29 | 30 | ## Feature 31 | 32 | - Show Server Config 33 | - Show Upstream 34 | - Show PKI 35 | - Load Server Config and Save Config to Server 36 | - View Metrics from "/metrics" 37 | 38 | ## Screenshots 39 | 40 | ![](screenshots/view.jpg) 41 | ![](screenshots/upstream.jpg) 42 | ![](screenshots/pki.jpg) 43 | ![](screenshots/load.jpg) 44 | ![](screenshots/metrics.png) 45 | -------------------------------------------------------------------------------- /build/404.html: -------------------------------------------------------------------------------- 1 | 404: This page could not be found

404

This page could not be found.

-------------------------------------------------------------------------------- /build/_next/static/chunks/164.9f581f85aa0d571e.js: -------------------------------------------------------------------------------- 1 | "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[164],{7164:function(e,l,t){t.r(l);var o=t(5893);t(7294);var n=t(4981),r=t(1526);t(252),t(7787),t(2679);let s=e=>(console.log(e),(0,o.jsx)(r.w,{children(l){let{width:t,height:r}=l;return(0,o.jsx)(n.Vl,{width:t,height:r,mode:"json",theme:"dracula",splits:2,orientation:"below",name:"UNIQUE_ID_OF_DIV",editorProps:{$blockScrolling:!0},...e})}}));l.default=s}}]); -------------------------------------------------------------------------------- /build/_next/static/chunks/544.18101b48c2d33992.js: -------------------------------------------------------------------------------- 1 | "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[544],{8544:function(e,n,l){l.r(n);var o=l(5893);l(7294);var t=l(4981),c=l(1526);function r(e){console.log("change",e)}l(252),l(7787),l(2679);let h=e=>(0,o.jsx)(c.w,{children(n){let{width:l,height:c}=n;return(0,o.jsx)(t.ZP,{width:l,height:c,mode:"json",theme:"dracula",onChange:r,editorProps:{$blockScrolling:!0},...e})}});n.default=h}}]); -------------------------------------------------------------------------------- /build/_next/static/chunks/626-3a496b4da8241c7a.js: -------------------------------------------------------------------------------- 1 | (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[626],{7645:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){let r=o.default,n=(null==t?void 0:t.suspense)?{}:{loading(e){let{error:t,isLoading:r,pastDelay:l}=e;return null}};if(e instanceof Promise?n.loader=()=>e:"function"==typeof e?n.loader=e:"object"==typeof e&&(n=l({},n,e)),(n=l({},n,t)).suspense&&(delete n.ssr,delete n.loading),n.loadableGenerated&&delete(n=l({},n,n.loadableGenerated)).loadableGenerated,"boolean"==typeof n.ssr&&!n.suspense){if(!n.ssr)return delete n.ssr,a(r,n);delete n.ssr}return r(n)},t.noSSR=a;var l=r(6495).Z,n=r(2648).Z,o=(n(r(7294)),n(r(4588)));function a(e,t){return delete t.webpack,delete t.modules,e(t)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3644:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LoadableContext=void 0;var l=(0,r(2648).Z)(r(7294));let n=l.default.createContext(null);t.LoadableContext=n},4588:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=r(6495).Z,n=(0,r(1598).Z)(r(7294)),o=r(3644);let a=[],s=[],i=!1;function u(e){let t=e(),r={loading:!0,loaded:null,error:null};return r.promise=t.then(e=>(r.loading=!1,r.loaded=e,e)).catch(e=>{throw r.loading=!1,r.error=e,e}),r}class d{promise(){return this._res.promise}retry(){this._clearTimeouts(),this._res=this._loadFn(this._opts.loader),this._state={pastDelay:!1,timedOut:!1};let{_res:e,_opts:t}=this;e.loading&&("number"==typeof t.delay&&(0===t.delay?this._state.pastDelay=!0:this._delay=setTimeout(()=>{this._update({pastDelay:!0})},t.delay)),"number"==typeof t.timeout&&(this._timeout=setTimeout(()=>{this._update({timedOut:!0})},t.timeout))),this._res.promise.then(()=>{this._update({}),this._clearTimeouts()}).catch(e=>{this._update({}),this._clearTimeouts()}),this._update({})}_update(e){this._state=l({},this._state,{error:this._res.error,loaded:this._res.loaded,loading:this._res.loading},e),this._callbacks.forEach(e=>e())}_clearTimeouts(){clearTimeout(this._delay),clearTimeout(this._timeout)}getCurrentValue(){return this._state}subscribe(e){return this._callbacks.add(e),()=>{this._callbacks.delete(e)}}constructor(e,t){this._loadFn=e,this._opts=t,this._callbacks=new Set,this._delay=null,this._timeout=null,this.retry()}}function c(e){return function(e,t){let r=Object.assign({loader:null,loading:null,delay:200,timeout:null,webpack:null,modules:null,suspense:!1},t);r.suspense&&(r.lazy=n.default.lazy(r.loader));let a=null;function u(){if(!a){let t=new d(e,r);a={getCurrentValue:t.getCurrentValue.bind(t),subscribe:t.subscribe.bind(t),retry:t.retry.bind(t),promise:t.promise.bind(t)}}return a.promise()}if(!i){let c=r.webpack?r.webpack():r.modules;c&&s.push(e=>{for(let t of c)if(-1!==e.indexOf(t))return u()})}function f(){u();let e=n.default.useContext(o.LoadableContext);e&&Array.isArray(r.modules)&&r.modules.forEach(t=>{e(t)})}let p=r.suspense?function(e,t){return f(),n.default.createElement(r.lazy,l({},e,{ref:t}))}:function(e,t){f();let l=n.useSyncExternalStore(a.subscribe,a.getCurrentValue,a.getCurrentValue);return n.default.useImperativeHandle(t,()=>({retry:a.retry}),[]),n.default.useMemo(()=>{var t;return l.loading||l.error?n.default.createElement(r.loading,{isLoading:l.loading,pastDelay:l.pastDelay,timedOut:l.timedOut,error:l.error,retry:a.retry}):l.loaded?n.default.createElement((t=l.loaded)&&t.__esModule?t.default:t,e):null},[e,l])};return p.preload=()=>u(),p.displayName="LoadableComponent",n.default.forwardRef(p)}(u,e)}function f(e,t){let r=[];for(;e.length;){let l=e.pop();r.push(l(t))}return Promise.all(r).then(()=>{if(e.length)return f(e,t)})}c.preloadAll=()=>new Promise((e,t)=>{f(a).then(e,t)}),c.preloadReady=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return new Promise(t=>{let r=()=>(i=!0,t());f(s,e).then(r,r)})},window.__NEXT_PRELOADREADY=c.preloadReady,t.default=c},9465:function(e,t,r){"use strict";r.d(t,{Z:function(){return M}});var l=r(7297),n=r(5944),o=r(917),a=r(7294),s=r(5050),i=r(1953),u=r(784),d=r(562),c=r(9630),f=r(9934),p=r(326),h=r(6336),m=r(5084),y=r(7056),b=r(3960),_=r(5893),g=r(5697),x=r.n(g),Z=r(6010),v=r(1163),w=r(1664),k=r.n(w),C=r(8346),j=r(1719);let O=(0,j.ZP)("a")({}),T=a.forwardRef(function(e,t){let{to:r,linkAs:l,replace:n,scroll:o,shallow:a,prefetch:s,locale:i,...u}=e;return(0,_.jsx)(k(),{href:r,prefetch:s,as:l,replace:n,scroll:o,shallow:a,passHref:!0,locale:i,children:(0,_.jsx)(O,{ref:t,...u})})});T.propTypes={href:x().any,linkAs:x().oneOfType([x().object,x().string]),locale:x().string,passHref:x().bool,prefetch:x().bool,replace:x().bool,scroll:x().bool,shallow:x().bool,to:x().oneOfType([x().object,x().string]).isRequired};let E=a.forwardRef(function(e,t){let{activeClassName:r="active",as:l,className:n,href:o,linkAs:a,locale:s,noLinkStyle:i,prefetch:u,replace:d,role:c,scroll:f,shallow:p,...h}=e,m=(0,v.useRouter)(),y="string"==typeof o?o:o.pathname,b=(0,Z.Z)(n,{[r]:m.pathname===y&&r}),g="string"==typeof o&&(0===o.indexOf("http")||0===o.indexOf("mailto:"));if(g)return i?(0,_.jsx)(O,{className:b,href:o,ref:t,...h}):(0,_.jsx)(C.Z,{className:b,href:o,ref:t,...h});let x={to:o,linkAs:a||l,replace:d,scroll:f,shallow:p,prefetch:u,locale:s};return i?(0,_.jsx)(T,{className:b,ref:t,...x,...h}):(0,_.jsx)(C.Z,{component:T,className:b,ref:t,...x,...h})});function A(){let e=(0,l.Z)(["\n color: white;\n "]);return A=function(){return e},e}function D(){let e=(0,l.Z)(["\n color: white;\n "]);return D=function(){return e},e}E.propTypes={activeClassName:x().string,as:x().oneOfType([x().object,x().string]),className:x().string,href:x().any,linkAs:x().oneOfType([x().object,x().string]),locale:x().string,noLinkStyle:x().bool,prefetch:x().bool,replace:x().bool,role:x().string,scroll:x().bool,shallow:x().bool};let N=[{name:"Upstream",href:"/upstream"},{name:"PKI",href:"/pki-view"},{name:"Load",href:"/setup"},{name:"Adapt",href:"/convert-config"},{name:"Metrics",href:"/monitor"}],P=()=>{let[e,t]=a.useState(null),r=e=>{t(e.currentTarget)},l=()=>{t(null)};return(0,n.tZ)(s.Z,{position:"static",children:(0,n.tZ)(h.Z,{maxWidth:"lg",children:(0,n.BX)(u.Z,{disableGutters:!0,children:[(0,n.tZ)(b.Z,{sx:{display:{xs:"none",md:"flex"},mr:1}}),(0,n.tZ)(c.Z,{variant:"h6",noWrap:!0,component:"a",href:"/",sx:{mr:2,display:{xs:"none",md:"flex"},fontFamily:"monospace",fontWeight:700,letterSpacing:".3rem",color:"inherit",textDecoration:"none"},children:"Caddy Config"}),(0,n.BX)(i.Z,{sx:{flexGrow:1,display:{xs:"flex",md:"none"}},children:[(0,n.tZ)(d.Z,{size:"large","aria-label":"account of current user","aria-controls":"menu-appbar","aria-haspopup":"true",onClick:r,color:"inherit",children:(0,n.tZ)(p.Z,{})}),(0,n.tZ)(f.Z,{id:"menu-appbar",anchorEl:e,anchorOrigin:{vertical:"bottom",horizontal:"left"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"left"},open:Boolean(e),onClose:l,sx:{display:{xs:"block",md:"none"}},children:N.map(e=>(0,n.tZ)(y.Z,{onClick:l,children:(0,n.tZ)(E,{href:e.href,css:(0,o.iv)(A()),children:(0,n.tZ)(c.Z,{textAlign:"center",children:e.name})})},e.name))})]}),(0,n.tZ)(b.Z,{sx:{display:{xs:"flex",md:"none"},mr:1}}),(0,n.tZ)(c.Z,{variant:"h5",noWrap:!0,component:"a",href:"",sx:{mr:2,display:{xs:"flex",md:"none"},flexGrow:1,fontFamily:"monospace",fontWeight:700,letterSpacing:".3rem",color:"inherit",textDecoration:"none"},children:"Caddy Config"}),(0,n.tZ)(i.Z,{sx:{flexGrow:1,display:{xs:"none",md:"flex"}},children:N.map(e=>(0,n.tZ)(m.Z,{onClick:l,sx:{my:2,color:"white",display:"block"},children:(0,n.tZ)(E,{href:e.href,css:(0,o.iv)(D()),children:e.name})},e.name))})]})})})};var M=P},1906:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});var l=r(5893);r(7294);var n=r(9630),o=r(8346);function a(){return(0,l.jsxs)(n.Z,{variant:"body2",color:"text.secondary",align:"center",children:["Copyright \xa9 ",(0,l.jsx)(o.Z,{color:"inherit",href:"https://github.com/gsmlg-dev/",children:"GSMLG-DEV"})," ",new Date().getFullYear(),"."]})}},5152:function(e,t,r){e.exports=r(7645)}}]); -------------------------------------------------------------------------------- /build/_next/static/chunks/pages/_error-8353112a01355ec2.js: -------------------------------------------------------------------------------- 1 | (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[820],{1981:function(n,_,u){(window.__NEXT_P=window.__NEXT_P||[]).push(["/_error",function(){return u(67)}])}},function(n){n.O(0,[774,888,179],function(){return n(n.s=1981)}),_N_E=n.O()}]); -------------------------------------------------------------------------------- /build/_next/static/chunks/pages/convert-config-43d546974a8bb1d5.js: -------------------------------------------------------------------------------- 1 | (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[199],{4050:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/convert-config",function(){return t(3595)}])},3595:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return p}});var a=t(5893),o=t(7294),i=t(5152),r=t.n(i),s=t(6336),c=t(9630),d=t(1953),l=t(5084),u=t(9465),h=t(1906);let f=r()(()=>Promise.all([t.e(281),t.e(317),t.e(164)]).then(t.bind(t,7164)),{loadableGenerated:{webpack:()=>[7164]},ssr:!1});function p(){let[e,n]=o.useState(["caddy.json","Caddyfile"]),t=o.useCallback(async t=>{let a=new Request("/adapt",{method:"POST",headers:{"Content-Type":"text/caddyfile"},body:e[0]}),o=await fetch(a),i=await o.json();n([e[0],JSON.stringify(i,null,2)])},[e]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u.Z,{}),(0,a.jsx)(s.Z,{maxWidth:"lg",children:(0,a.jsxs)(d.Z,{sx:{my:4},children:[(0,a.jsx)(c.Z,{variant:"h4",component:"h1",gutterBottom:!0,children:"Caddy Server Load"}),(0,a.jsx)(c.Z,{variant:"p",component:"p",gutterBottom:!0,children:(0,a.jsx)(l.Z,{variant:"contained",onClick:t,children:"Convert"})}),(0,a.jsx)(c.Z,{variant:"p",component:"p",gutterBottom:!0,children:(0,a.jsx)(f,{onChange:console.log,value:e,height:600,splits:2})}),(0,a.jsx)(h.Z,{})]})})]})}}},function(e){e.O(0,[514,626,774,888,179],function(){return e(e.s=4050)}),_N_E=e.O()}]); -------------------------------------------------------------------------------- /build/_next/static/chunks/pages/index-e686d512e6270582.js: -------------------------------------------------------------------------------- 1 | (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{3508:function(e,t,n){"use strict";var r=n(4836);t.Z=void 0;var o=r(n(4938)),i=n(5893),a=(0,o.default)((0,i.jsx)("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");t.Z=a},5557:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return n(5882)}])},5882:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return ee}});var r=n(5893),o=n(7294),i=n(6336),a=n(9630),s=n(1953),l=n(3366),d=n(7462);n(9864);var c=n(6010),u=n(4780),p=n(1719),h=n(8884),f=n(8662),m=n(3204),x=n(3566),Z=n(2097),g=n(4771),b=n(1588),y=n(4867);function v(e){return(0,y.Z)("MuiCollapse",e)}(0,b.Z)("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);let w=["addEndListener","children","className","collapsedSize","component","easing","in","onEnter","onEntered","onEntering","onExit","onExited","onExiting","orientation","style","timeout","TransitionComponent"],j=e=>{let{orientation:t,classes:n}=e,r={root:["root",`${t}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${t}`],wrapperInner:["wrapperInner",`${t}`]};return(0,u.Z)(r,v,n)},R=(0,p.ZP)("div",{name:"MuiCollapse",slot:"Root",overridesResolver(e,t){let{ownerState:n}=e;return[t.root,t[n.orientation],"entered"===n.state&&t.entered,"exited"===n.state&&!n.in&&"0px"===n.collapsedSize&&t.hidden]}})(({theme:e,ownerState:t})=>(0,d.Z)({height:0,overflow:"hidden",transition:e.transitions.create("height")},"horizontal"===t.orientation&&{height:"auto",width:0,transition:e.transitions.create("width")},"entered"===t.state&&(0,d.Z)({height:"auto",overflow:"visible"},"horizontal"===t.orientation&&{width:"auto"}),"exited"===t.state&&!t.in&&"0px"===t.collapsedSize&&{visibility:"hidden"})),C=(0,p.ZP)("div",{name:"MuiCollapse",slot:"Wrapper",overridesResolver:(e,t)=>t.wrapper})(({ownerState:e})=>(0,d.Z)({display:"flex",width:"100%"},"horizontal"===e.orientation&&{width:"auto",height:"100%"})),S=(0,p.ZP)("div",{name:"MuiCollapse",slot:"WrapperInner",overridesResolver:(e,t)=>t.wrapperInner})(({ownerState:e})=>(0,d.Z)({width:"100%"},"horizontal"===e.orientation&&{width:"auto",height:"100%"})),k=o.forwardRef(function(e,t){let n=(0,h.Z)({props:e,name:"MuiCollapse"}),{addEndListener:i,children:a,className:s,collapsedSize:u="0px",component:p,easing:b,in:y,onEnter:v,onEntered:k,onEntering:N,onExit:A,onExited:E,onExiting:M,orientation:$="vertical",style:T,timeout:I=m.x9.standard,TransitionComponent:W=f.ZP}=n,z=(0,l.Z)(n,w),O=(0,d.Z)({},n,{orientation:$,collapsedSize:u}),P=j(O),D=(0,Z.Z)(),G=o.useRef(),_=o.useRef(null),B=o.useRef(),H="number"==typeof u?`${u}px`:u,L="horizontal"===$,V=L?"width":"height";o.useEffect(()=>()=>{clearTimeout(G.current)},[]);let F=o.useRef(null),q=(0,g.Z)(t,F),X=e=>t=>{if(e){let n=F.current;void 0===t?e(n):e(n,t)}},J=()=>_.current?_.current[L?"clientWidth":"clientHeight"]:0,K=X((e,t)=>{_.current&&L&&(_.current.style.position="absolute"),e.style[V]=H,v&&v(e,t)}),U=X((e,t)=>{let n=J();_.current&&L&&(_.current.style.position="");let{duration:r,easing:o}=(0,x.C)({style:T,timeout:I,easing:b},{mode:"enter"});if("auto"===I){let i=D.transitions.getAutoHeightDuration(n);e.style.transitionDuration=`${i}ms`,B.current=i}else e.style.transitionDuration="string"==typeof r?r:`${r}ms`;e.style[V]=`${n}px`,e.style.transitionTimingFunction=o,N&&N(e,t)}),Y=X((e,t)=>{e.style[V]="auto",k&&k(e,t)}),Q=X(e=>{e.style[V]=`${J()}px`,A&&A(e)}),ee=X(E),et=X(e=>{let t=J(),{duration:n,easing:r}=(0,x.C)({style:T,timeout:I,easing:b},{mode:"exit"});if("auto"===I){let o=D.transitions.getAutoHeightDuration(t);e.style.transitionDuration=`${o}ms`,B.current=o}else e.style.transitionDuration="string"==typeof n?n:`${n}ms`;e.style[V]=H,e.style.transitionTimingFunction=r,M&&M(e)}),en=e=>{"auto"===I&&(G.current=setTimeout(e,B.current||0)),i&&i(F.current,e)};return(0,r.jsx)(W,(0,d.Z)({in:y,onEnter:K,onEntered:Y,onEntering:U,onExit:Q,onExited:ee,onExiting:et,addEndListener:en,nodeRef:F,timeout:"auto"===I?null:I},z,{children:(e,t)=>(0,r.jsx)(R,(0,d.Z)({as:p,className:(0,c.Z)(P.root,s,{entered:P.entered,exited:!y&&"0px"===H&&P.hidden}[e]),style:(0,d.Z)({[L?"minWidth":"minHeight"]:H},T),ownerState:(0,d.Z)({},O,{state:e}),ref:q},t,{children:(0,r.jsx)(C,{ownerState:(0,d.Z)({},O,{state:e}),className:P.wrapper,ref:_,children:(0,r.jsx)(S,{ownerState:(0,d.Z)({},O,{state:e}),className:P.wrapperInner,children:a})})}))}))});k.muiSupportAuto=!0;var N=n(1401);let A=o.createContext({});var E=n(4591);function M(e){return(0,y.Z)("MuiAccordion",e)}let $=(0,b.Z)("MuiAccordion",["root","rounded","expanded","disabled","gutters","region"]),T=["children","className","defaultExpanded","disabled","disableGutters","expanded","onChange","square","TransitionComponent","TransitionProps"],I=e=>{let{classes:t,square:n,expanded:r,disabled:o,disableGutters:i}=e;return(0,u.Z)({root:["root",!n&&"rounded",r&&"expanded",o&&"disabled",!i&&"gutters"],region:["region"]},M,t)},W=(0,p.ZP)(N.Z,{name:"MuiAccordion",slot:"Root",overridesResolver(e,t){let{ownerState:n}=e;return[{[`& .${$.region}`]:t.region},t.root,!n.square&&t.rounded,!n.disableGutters&&t.gutters]}})(({theme:e})=>{let t={duration:e.transitions.duration.shortest};return{position:"relative",transition:e.transitions.create(["margin"],t),overflowAnchor:"none","&:before":{position:"absolute",left:0,top:-1,right:0,height:1,content:'""',opacity:1,backgroundColor:(e.vars||e).palette.divider,transition:e.transitions.create(["opacity","background-color"],t)},"&:first-of-type":{"&:before":{display:"none"}},[`&.${$.expanded}`]:{"&:before":{opacity:0},"&:first-of-type":{marginTop:0},"&:last-of-type":{marginBottom:0},"& + &":{"&:before":{display:"none"}}},[`&.${$.disabled}`]:{backgroundColor:(e.vars||e).palette.action.disabledBackground}}},({theme:e,ownerState:t})=>(0,d.Z)({},!t.square&&{borderRadius:0,"&:first-of-type":{borderTopLeftRadius:(e.vars||e).shape.borderRadius,borderTopRightRadius:(e.vars||e).shape.borderRadius},"&:last-of-type":{borderBottomLeftRadius:(e.vars||e).shape.borderRadius,borderBottomRightRadius:(e.vars||e).shape.borderRadius,"@supports (-ms-ime-align: auto)":{borderBottomLeftRadius:0,borderBottomRightRadius:0}}},!t.disableGutters&&{[`&.${$.expanded}`]:{margin:"16px 0"}})),z=o.forwardRef(function(e,t){let n=(0,h.Z)({props:e,name:"MuiAccordion"}),{children:i,className:a,defaultExpanded:s=!1,disabled:u=!1,disableGutters:p=!1,expanded:f,onChange:m,square:x=!1,TransitionComponent:Z=k,TransitionProps:g}=n,b=(0,l.Z)(n,T),[y,v]=(0,E.Z)({controlled:f,default:s,name:"Accordion",state:"expanded"}),w=o.useCallback(e=>{v(!y),m&&m(e,!y)},[y,m,v]),[j,...R]=o.Children.toArray(i),C=o.useMemo(()=>({expanded:y,disabled:u,disableGutters:p,toggle:w}),[y,u,p,w]),S=(0,d.Z)({},n,{square:x,disabled:u,disableGutters:p,expanded:y}),N=I(S);return(0,r.jsxs)(W,(0,d.Z)({className:(0,c.Z)(N.root,a),ref:t,ownerState:S,square:x},b,{children:[(0,r.jsx)(A.Provider,{value:C,children:j}),(0,r.jsx)(Z,(0,d.Z)({in:y,timeout:"auto"},g,{children:(0,r.jsx)("div",{"aria-labelledby":j.props.id,id:j.props["aria-controls"],role:"region",className:N.region,children:R})}))]}))});function O(e){return(0,y.Z)("MuiAccordionDetails",e)}(0,b.Z)("MuiAccordionDetails",["root"]);let P=["className"],D=e=>{let{classes:t}=e;return(0,u.Z)({root:["root"]},O,t)},G=(0,p.ZP)("div",{name:"MuiAccordionDetails",slot:"Root",overridesResolver:(e,t)=>t.root})(({theme:e})=>({padding:e.spacing(1,2,2)})),_=o.forwardRef(function(e,t){let n=(0,h.Z)({props:e,name:"MuiAccordionDetails"}),{className:o}=n,i=(0,l.Z)(n,P),a=D(n);return(0,r.jsx)(G,(0,d.Z)({className:(0,c.Z)(a.root,o),ref:t,ownerState:n},i))});var B=n(9828);function H(e){return(0,y.Z)("MuiAccordionSummary",e)}let L=(0,b.Z)("MuiAccordionSummary",["root","expanded","focusVisible","disabled","gutters","contentGutters","content","expandIconWrapper"]),V=["children","className","expandIcon","focusVisibleClassName","onClick"],F=e=>{let{classes:t,expanded:n,disabled:r,disableGutters:o}=e;return(0,u.Z)({root:["root",n&&"expanded",r&&"disabled",!o&&"gutters"],focusVisible:["focusVisible"],content:["content",n&&"expanded",!o&&"contentGutters"],expandIconWrapper:["expandIconWrapper",n&&"expanded"]},H,t)},q=(0,p.ZP)(B.Z,{name:"MuiAccordionSummary",slot:"Root",overridesResolver:(e,t)=>t.root})(({theme:e,ownerState:t})=>{let n={duration:e.transitions.duration.shortest};return(0,d.Z)({display:"flex",minHeight:48,padding:e.spacing(0,2),transition:e.transitions.create(["min-height","background-color"],n),[`&.${L.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${L.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`&:hover:not(.${L.disabled})`]:{cursor:"pointer"}},!t.disableGutters&&{[`&.${L.expanded}`]:{minHeight:64}})}),X=(0,p.ZP)("div",{name:"MuiAccordionSummary",slot:"Content",overridesResolver:(e,t)=>t.content})(({theme:e,ownerState:t})=>(0,d.Z)({display:"flex",flexGrow:1,margin:"12px 0"},!t.disableGutters&&{transition:e.transitions.create(["margin"],{duration:e.transitions.duration.shortest}),[`&.${L.expanded}`]:{margin:"20px 0"}})),J=(0,p.ZP)("div",{name:"MuiAccordionSummary",slot:"ExpandIconWrapper",overridesResolver:(e,t)=>t.expandIconWrapper})(({theme:e})=>({display:"flex",color:(e.vars||e).palette.action.active,transform:"rotate(0deg)",transition:e.transitions.create("transform",{duration:e.transitions.duration.shortest}),[`&.${L.expanded}`]:{transform:"rotate(180deg)"}})),K=o.forwardRef(function(e,t){let n=(0,h.Z)({props:e,name:"MuiAccordionSummary"}),{children:i,className:a,expandIcon:s,focusVisibleClassName:u,onClick:p}=n,f=(0,l.Z)(n,V),{disabled:m=!1,disableGutters:x,expanded:Z,toggle:g}=o.useContext(A),b=e=>{g&&g(e),p&&p(e)},y=(0,d.Z)({},n,{expanded:Z,disabled:m,disableGutters:x}),v=F(y);return(0,r.jsxs)(q,(0,d.Z)({focusRipple:!1,disableRipple:!0,disabled:m,component:"div","aria-expanded":Z,className:(0,c.Z)(v.root,a),focusVisibleClassName:(0,c.Z)(v.focusVisible,u),onClick:b,ref:t,ownerState:y},f,{children:[(0,r.jsx)(X,{className:v.content,ownerState:y,children:i}),s&&(0,r.jsx)(J,{className:v.expandIconWrapper,ownerState:y,children:s})]}))});var U=n(3508),Y=n(9465),Q=n(1906);function ee(){let[e,t]=o.useState({});o.useEffect(()=>{let e=async()=>{let e=await fetch("/config/"),n=await e.json();t(n)};e()},[]);let[n,l]=o.useState({}),d=e=>(t,r)=>{l({...n,[e]:r})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Y.Z,{}),(0,r.jsx)(i.Z,{maxWidth:"lg",children:(0,r.jsxs)(s.Z,{sx:{my:4},children:[(0,r.jsx)(a.Z,{variant:"h4",component:"h1",gutterBottom:!0,children:"Caddy Server Config"}),(0,r.jsx)(a.Z,{variant:"p",component:"pre",gutterBottom:!0,children:Object.keys(e).map(t=>{let o=e[t];return(0,r.jsxs)(z,{expanded:n[t],onChange:d(t),children:[(0,r.jsx)(K,{expandIcon:(0,r.jsx)(U.Z,{}),"aria-controls":"".concat(t,"-content"),id:"as-".concat(t,"-header"),children:(0,r.jsx)(a.Z,{sx:{width:"33%",flexShrink:0},children:t})}),(0,r.jsx)(_,{children:"apps"===t?Object.keys(o).map(e=>{let i=o[e];return(0,r.jsxs)(z,{expanded:n["".concat(t,"-").concat(e)],onChange:d("".concat(t,"-").concat(e)),children:[(0,r.jsx)(K,{expandIcon:(0,r.jsx)(U.Z,{}),"aria-controls":"".concat(e,"-content"),id:"as-".concat(e,"-header"),children:(0,r.jsx)(a.Z,{sx:{width:"33%",flexShrink:0},children:e})}),(0,r.jsx)(_,{children:(0,r.jsx)(a.Z,{component:"pre",children:JSON.stringify(i,null,4)})})]})}):(0,r.jsx)(a.Z,{component:"pre",children:JSON.stringify(o,null,4)})})]},t)})}),(0,r.jsx)(Q.Z,{})]})})]})}},9465:function(e,t,n){"use strict";n.d(t,{Z:function(){return I}});var r=n(7297),o=n(5944),i=n(917),a=n(7294),s=n(5050),l=n(1953),d=n(784),c=n(562),u=n(9630),p=n(9934),h=n(326),f=n(6336),m=n(5084),x=n(7056),Z=n(3960),g=n(5893),b=n(5697),y=n.n(b),v=n(6010),w=n(1163),j=n(1664),R=n.n(j),C=n(8346),S=n(1719);let k=(0,S.ZP)("a")({}),N=a.forwardRef(function(e,t){let{to:n,linkAs:r,replace:o,scroll:i,shallow:a,prefetch:s,locale:l,...d}=e;return(0,g.jsx)(R(),{href:n,prefetch:s,as:r,replace:o,scroll:i,shallow:a,passHref:!0,locale:l,children:(0,g.jsx)(k,{ref:t,...d})})});N.propTypes={href:y().any,linkAs:y().oneOfType([y().object,y().string]),locale:y().string,passHref:y().bool,prefetch:y().bool,replace:y().bool,scroll:y().bool,shallow:y().bool,to:y().oneOfType([y().object,y().string]).isRequired};let A=a.forwardRef(function(e,t){let{activeClassName:n="active",as:r,className:o,href:i,linkAs:a,locale:s,noLinkStyle:l,prefetch:d,replace:c,role:u,scroll:p,shallow:h,...f}=e,m=(0,w.useRouter)(),x="string"==typeof i?i:i.pathname,Z=(0,v.Z)(o,{[n]:m.pathname===x&&n}),b="string"==typeof i&&(0===i.indexOf("http")||0===i.indexOf("mailto:"));if(b)return l?(0,g.jsx)(k,{className:Z,href:i,ref:t,...f}):(0,g.jsx)(C.Z,{className:Z,href:i,ref:t,...f});let y={to:i,linkAs:a||r,replace:c,scroll:p,shallow:h,prefetch:d,locale:s};return l?(0,g.jsx)(N,{className:Z,ref:t,...y,...f}):(0,g.jsx)(C.Z,{component:N,className:Z,ref:t,...y,...f})});function E(){let e=(0,r.Z)(["\n color: white;\n "]);return E=function(){return e},e}function M(){let e=(0,r.Z)(["\n color: white;\n "]);return M=function(){return e},e}A.propTypes={activeClassName:y().string,as:y().oneOfType([y().object,y().string]),className:y().string,href:y().any,linkAs:y().oneOfType([y().object,y().string]),locale:y().string,noLinkStyle:y().bool,prefetch:y().bool,replace:y().bool,role:y().string,scroll:y().bool,shallow:y().bool};let $=[{name:"Upstream",href:"/upstream"},{name:"PKI",href:"/pki-view"},{name:"Load",href:"/setup"},{name:"Adapt",href:"/convert-config"},{name:"Metrics",href:"/monitor"}],T=()=>{let[e,t]=a.useState(null),n=e=>{t(e.currentTarget)},r=()=>{t(null)};return(0,o.tZ)(s.Z,{position:"static",children:(0,o.tZ)(f.Z,{maxWidth:"lg",children:(0,o.BX)(d.Z,{disableGutters:!0,children:[(0,o.tZ)(Z.Z,{sx:{display:{xs:"none",md:"flex"},mr:1}}),(0,o.tZ)(u.Z,{variant:"h6",noWrap:!0,component:"a",href:"/",sx:{mr:2,display:{xs:"none",md:"flex"},fontFamily:"monospace",fontWeight:700,letterSpacing:".3rem",color:"inherit",textDecoration:"none"},children:"Caddy Config"}),(0,o.BX)(l.Z,{sx:{flexGrow:1,display:{xs:"flex",md:"none"}},children:[(0,o.tZ)(c.Z,{size:"large","aria-label":"account of current user","aria-controls":"menu-appbar","aria-haspopup":"true",onClick:n,color:"inherit",children:(0,o.tZ)(h.Z,{})}),(0,o.tZ)(p.Z,{id:"menu-appbar",anchorEl:e,anchorOrigin:{vertical:"bottom",horizontal:"left"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"left"},open:Boolean(e),onClose:r,sx:{display:{xs:"block",md:"none"}},children:$.map(e=>(0,o.tZ)(x.Z,{onClick:r,children:(0,o.tZ)(A,{href:e.href,css:(0,i.iv)(E()),children:(0,o.tZ)(u.Z,{textAlign:"center",children:e.name})})},e.name))})]}),(0,o.tZ)(Z.Z,{sx:{display:{xs:"flex",md:"none"},mr:1}}),(0,o.tZ)(u.Z,{variant:"h5",noWrap:!0,component:"a",href:"",sx:{mr:2,display:{xs:"flex",md:"none"},flexGrow:1,fontFamily:"monospace",fontWeight:700,letterSpacing:".3rem",color:"inherit",textDecoration:"none"},children:"Caddy Config"}),(0,o.tZ)(l.Z,{sx:{flexGrow:1,display:{xs:"none",md:"flex"}},children:$.map(e=>(0,o.tZ)(m.Z,{onClick:r,sx:{my:2,color:"white",display:"block"},children:(0,o.tZ)(A,{href:e.href,css:(0,i.iv)(M()),children:e.name})},e.name))})]})})})};var I=T},1906:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(5893);n(7294);var o=n(9630),i=n(8346);function a(){return(0,r.jsxs)(o.Z,{variant:"body2",color:"text.secondary",align:"center",children:["Copyright \xa9 ",(0,r.jsx)(i.Z,{color:"inherit",href:"https://github.com/gsmlg-dev/",children:"GSMLG-DEV"})," ",new Date().getFullYear(),"."]})}}},function(e){e.O(0,[514,774,888,179],function(){return e(e.s=5557)}),_N_E=e.O()}]); -------------------------------------------------------------------------------- /build/_next/static/chunks/pages/monitor-22c7e7c5e5692db0.js: -------------------------------------------------------------------------------- 1 | (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[69],{809:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/monitor",function(){return n(8118)}])},8118:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return N}});var r=n(5893),l=n(7294),i=n(6336),a=n(9630),o=n(1953),s=n(2722),c=n(8661),d=n(9465),h=n(4246),p=n(8316),f=n(7056),x=n(5343),u=n(2012),m=n(1448),Z=n(244),b=n(9807),j=n(5605),g=n(3978),v=n(9417);let y=e=>{let t=e.split(/\n|\r\n/),n={};return t.forEach(e=>{if(/(^\s+)?#/.test(e))return;let[t,r]=e.split(/\s+/);t&&(n[t]=Number(r))}),n};function w(e){let{children:t,value:n,index:l,...i}=e;return(0,r.jsx)("div",{role:"tabpanel",hidden:n!==l,id:"vertical-tabpanel-".concat(l),"aria-labelledby":"vertical-tab-".concat(l),...i,children:n===l&&(0,r.jsx)(o.Z,{sx:{p:3},children:(0,r.jsx)(a.Z,{children:t})})})}function k(e){return{id:"vertical-tab-".concat(e),"aria-controls":"vertical-tabpanel-".concat(e)}}let C={PaperProps:{style:{maxHeight:224,width:1e3}}};function N(){var e;let[t,n]=l.useState(""),[N,O]=l.useState([]),[S,_]=l.useState(0),W=(e,t)=>{_(t)},T=l.useCallback(async()=>{let e=await fetch("/metrics"),t=await e.text();n(t);let r=y(t),l=[{time:Date.now(),data:r}].concat(N).slice(0,240);O(l)},[N]);l.useEffect(()=>{T();let e=setInterval(()=>{T()},3e4);return()=>clearInterval(e)},[]);let[E,P]=l.useState([]),A=e=>{let{target:{value:t}}=e;P("string"==typeof t?t.split(","):t)},M=N[0],R=Object.keys(null!==(e=null==M?void 0:M.data)&&void 0!==e?e:{});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.Z,{}),(0,r.jsx)(i.Z,{maxWidth:"lg",children:(0,r.jsxs)(o.Z,{sx:{my:4},children:[(0,r.jsx)(a.Z,{variant:"h4",component:"h1",gutterBottom:!0,children:"Caddy Server Metrics"}),(0,r.jsxs)(o.Z,{sx:{flexGrow:1,bgcolor:"background.paper",display:"flex",height:224},children:[(0,r.jsxs)(s.Z,{orientation:"vertical",variant:"scrollable",value:S,onChange:W,"aria-label":"Vertical tabs example",sx:{borderRight:1,borderColor:"divider",minWidth:100},children:[(0,r.jsx)(c.Z,{label:"Raw",...k(0)}),(0,r.jsx)(c.Z,{label:"Parsed",...k(1)}),(0,r.jsx)(c.Z,{label:"Metric",...k(2)})]}),(0,r.jsx)(w,{value:S,index:0,children:(0,r.jsx)("pre",{children:t})}),(0,r.jsx)(w,{value:S,index:1,children:(0,r.jsx)("pre",{children:JSON.stringify(N[0],null,4)})}),(0,r.jsxs)(w,{value:S,index:2,children:[(0,r.jsx)("div",{children:(0,r.jsxs)(x.Z,{sx:{m:1,width:800},children:[(0,r.jsx)(p.Z,{id:"demo-multiple-chip-label",children:"Select Metric"}),(0,r.jsx)(u.Z,{labelId:"demo-multiple-chip-label",id:"demo-multiple-chip",multiple:!0,value:E,onChange:A,input:(0,r.jsx)(h.Z,{id:"select-multiple-chip",label:"Chip"}),renderValue:e=>(0,r.jsx)(o.Z,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:e.map(e=>(0,r.jsx)(m.Z,{label:e},e))}),MenuProps:C,children:R.map(e=>(0,r.jsx)(f.Z,{value:e,style:{fontWeight:-1===E.indexOf(e)?"normal":"500"},children:e},e))})]})}),(0,r.jsxs)(Z.Z,{sx:{minWidth:800},"aria-label":"simple table",children:[(0,r.jsx)(g.Z,{children:(0,r.jsxs)(v.Z,{children:[(0,r.jsx)(j.Z,{children:"time"}),E.map(e=>(0,r.jsx)(j.Z,{children:e},"m-".concat(e)))]})}),(0,r.jsx)(b.Z,{children:N.map(e=>(0,r.jsxs)(v.Z,{children:[(0,r.jsx)(j.Z,{children:new Date(e.time).toISOString()}),E.map(t=>(0,r.jsx)(j.Z,{children:e.data[t]},"t-".concat(e.time,"-").concat(t)))]},"t-".concat(e.time)))})]})]})]})]})})]})}},9465:function(e,t,n){"use strict";n.d(t,{Z:function(){return A}});var r=n(7297),l=n(5944),i=n(917),a=n(7294),o=n(5050),s=n(1953),c=n(784),d=n(562),h=n(9630),p=n(9934),f=n(326),x=n(6336),u=n(5084),m=n(7056),Z=n(3960),b=n(5893),j=n(5697),g=n.n(j),v=n(6010),y=n(1163),w=n(1664),k=n.n(w),C=n(8346),N=n(1719);let O=(0,N.ZP)("a")({}),S=a.forwardRef(function(e,t){let{to:n,linkAs:r,replace:l,scroll:i,shallow:a,prefetch:o,locale:s,...c}=e;return(0,b.jsx)(k(),{href:n,prefetch:o,as:r,replace:l,scroll:i,shallow:a,passHref:!0,locale:s,children:(0,b.jsx)(O,{ref:t,...c})})});S.propTypes={href:g().any,linkAs:g().oneOfType([g().object,g().string]),locale:g().string,passHref:g().bool,prefetch:g().bool,replace:g().bool,scroll:g().bool,shallow:g().bool,to:g().oneOfType([g().object,g().string]).isRequired};let _=a.forwardRef(function(e,t){let{activeClassName:n="active",as:r,className:l,href:i,linkAs:a,locale:o,noLinkStyle:s,prefetch:c,replace:d,role:h,scroll:p,shallow:f,...x}=e,u=(0,y.useRouter)(),m="string"==typeof i?i:i.pathname,Z=(0,v.Z)(l,{[n]:u.pathname===m&&n}),j="string"==typeof i&&(0===i.indexOf("http")||0===i.indexOf("mailto:"));if(j)return s?(0,b.jsx)(O,{className:Z,href:i,ref:t,...x}):(0,b.jsx)(C.Z,{className:Z,href:i,ref:t,...x});let g={to:i,linkAs:a||r,replace:d,scroll:p,shallow:f,prefetch:c,locale:o};return s?(0,b.jsx)(S,{className:Z,ref:t,...g,...x}):(0,b.jsx)(C.Z,{component:S,className:Z,ref:t,...g,...x})});function W(){let e=(0,r.Z)(["\n color: white;\n "]);return W=function(){return e},e}function T(){let e=(0,r.Z)(["\n color: white;\n "]);return T=function(){return e},e}_.propTypes={activeClassName:g().string,as:g().oneOfType([g().object,g().string]),className:g().string,href:g().any,linkAs:g().oneOfType([g().object,g().string]),locale:g().string,noLinkStyle:g().bool,prefetch:g().bool,replace:g().bool,role:g().string,scroll:g().bool,shallow:g().bool};let E=[{name:"Upstream",href:"/upstream"},{name:"PKI",href:"/pki-view"},{name:"Load",href:"/setup"},{name:"Adapt",href:"/convert-config"},{name:"Metrics",href:"/monitor"}],P=()=>{let[e,t]=a.useState(null),n=e=>{t(e.currentTarget)},r=()=>{t(null)};return(0,l.tZ)(o.Z,{position:"static",children:(0,l.tZ)(x.Z,{maxWidth:"lg",children:(0,l.BX)(c.Z,{disableGutters:!0,children:[(0,l.tZ)(Z.Z,{sx:{display:{xs:"none",md:"flex"},mr:1}}),(0,l.tZ)(h.Z,{variant:"h6",noWrap:!0,component:"a",href:"/",sx:{mr:2,display:{xs:"none",md:"flex"},fontFamily:"monospace",fontWeight:700,letterSpacing:".3rem",color:"inherit",textDecoration:"none"},children:"Caddy Config"}),(0,l.BX)(s.Z,{sx:{flexGrow:1,display:{xs:"flex",md:"none"}},children:[(0,l.tZ)(d.Z,{size:"large","aria-label":"account of current user","aria-controls":"menu-appbar","aria-haspopup":"true",onClick:n,color:"inherit",children:(0,l.tZ)(f.Z,{})}),(0,l.tZ)(p.Z,{id:"menu-appbar",anchorEl:e,anchorOrigin:{vertical:"bottom",horizontal:"left"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"left"},open:Boolean(e),onClose:r,sx:{display:{xs:"block",md:"none"}},children:E.map(e=>(0,l.tZ)(m.Z,{onClick:r,children:(0,l.tZ)(_,{href:e.href,css:(0,i.iv)(W()),children:(0,l.tZ)(h.Z,{textAlign:"center",children:e.name})})},e.name))})]}),(0,l.tZ)(Z.Z,{sx:{display:{xs:"flex",md:"none"},mr:1}}),(0,l.tZ)(h.Z,{variant:"h5",noWrap:!0,component:"a",href:"",sx:{mr:2,display:{xs:"flex",md:"none"},flexGrow:1,fontFamily:"monospace",fontWeight:700,letterSpacing:".3rem",color:"inherit",textDecoration:"none"},children:"Caddy Config"}),(0,l.tZ)(s.Z,{sx:{flexGrow:1,display:{xs:"none",md:"flex"}},children:E.map(e=>(0,l.tZ)(u.Z,{onClick:r,sx:{my:2,color:"white",display:"block"},children:(0,l.tZ)(_,{href:e.href,css:(0,i.iv)(T()),children:e.name})},e.name))})]})})})};var A=P}},function(e){e.O(0,[514,512,774,888,179],function(){return e(e.s=809)}),_N_E=e.O()}]); -------------------------------------------------------------------------------- /build/_next/static/chunks/pages/pki-view-aadb21af8bc87747.js: -------------------------------------------------------------------------------- 1 | (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[971],{9837:function(e,t,n){"use strict";n.d(t,{Z:function(){return v}});var r=n(7462),o=n(3366),i=n(7294),a=n(6010),s=n(4780),l=n(1719),c=n(8884),d=n(1401),f=n(1588),u=n(4867);function p(e){return(0,u.Z)("MuiCard",e)}(0,f.Z)("MuiCard",["root"]);var h=n(5893);let m=["className","raised"],Z=e=>{let{classes:t}=e;return(0,s.Z)({root:["root"]},p,t)},x=(0,l.ZP)(d.Z,{name:"MuiCard",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({overflow:"hidden"})),g=i.forwardRef(function(e,t){let n=(0,c.Z)({props:e,name:"MuiCard"}),{className:i,raised:s=!1}=n,l=(0,o.Z)(n,m),d=(0,r.Z)({},n,{raised:s}),f=Z(d);return(0,h.jsx)(x,(0,r.Z)({className:(0,a.Z)(f.root,i),elevation:s?8:void 0,ref:t,ownerState:d},l))});var v=g},1359:function(e,t,n){"use strict";n.d(t,{Z:function(){return g}});var r=n(7462),o=n(3366),i=n(7294),a=n(6010),s=n(4780),l=n(1719),c=n(8884),d=n(1588),f=n(4867);function u(e){return(0,f.Z)("MuiCardContent",e)}(0,d.Z)("MuiCardContent",["root"]);var p=n(5893);let h=["className","component"],m=e=>{let{classes:t}=e;return(0,s.Z)({root:["root"]},u,t)},Z=(0,l.ZP)("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),x=i.forwardRef(function(e,t){let n=(0,c.Z)({props:e,name:"MuiCardContent"}),{className:i,component:s="div"}=n,l=(0,o.Z)(n,h),d=(0,r.Z)({},n,{component:s}),f=m(d);return(0,p.jsx)(Z,(0,r.Z)({as:s,className:(0,a.Z)(f.root,i),ownerState:d,ref:t},l))});var g=x},7296:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/pki-view",function(){return n(3493)}])},3493:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return M}});var r=n(5893),o=n(7294),i=n(6336),a=n(9630),s=n(1953),l=n(9465),c=n(1906),d=n(9837),f=n(3366),u=n(7462),p=n(6010),h=n(4780),m=n(1719),Z=n(8884),x=n(1588),g=n(4867);function v(e){return(0,g.Z)("MuiCardActions",e)}(0,x.Z)("MuiCardActions",["root","spacing"]);let b=["disableSpacing","className"],j=e=>{let{classes:t,disableSpacing:n}=e;return(0,h.Z)({root:["root",!n&&"spacing"]},v,t)},y=(0,m.ZP)("div",{name:"MuiCardActions",slot:"Root",overridesResolver(e,t){let{ownerState:n}=e;return[t.root,!n.disableSpacing&&t.spacing]}})(({ownerState:e})=>(0,u.Z)({display:"flex",alignItems:"center",padding:8},!e.disableSpacing&&{"& > :not(:first-of-type)":{marginLeft:8}})),w=o.forwardRef(function(e,t){let n=(0,Z.Z)({props:e,name:"MuiCardActions"}),{disableSpacing:o=!1,className:i}=n,a=(0,f.Z)(n,b),s=(0,u.Z)({},n,{disableSpacing:o}),l=j(s);return(0,r.jsx)(y,(0,u.Z)({className:(0,p.Z)(l.root,i),ownerState:s,ref:t},a))});var C=n(1359),k=n(5084),N=n(8389);function S(e){let{id:t,name:n,root_common_name:i,intermediate_common_name:l,root_certificate:c,intermediate_certificate:f}=e,[u,p]=o.useState(!1),h=e=>()=>p(e),m=()=>p(!1);return(0,r.jsxs)(d.Z,{sx:{minWidth:275},children:[(0,r.jsxs)(C.Z,{children:[(0,r.jsxs)(a.Z,{sx:{fontSize:14},color:"text.secondary",gutterBottom:!0,children:["ID: ",t]}),(0,r.jsxs)(a.Z,{variant:"h5",component:"div",children:["Name: ",n]}),(0,r.jsxs)(a.Z,{variant:"body2",children:["Root CommonName:",(0,r.jsx)("br",{}),i]}),(0,r.jsxs)(a.Z,{variant:"body2",children:["Intermediate CommonName:",(0,r.jsx)("br",{}),l]})]}),(0,r.jsxs)(w,{children:[(0,r.jsx)(k.Z,{size:"small",onClick:h("root"),children:"Show Root"}),(0,r.jsx)(k.Z,{size:"small",onClick:h("intermediate"),children:"Show Intermediate"})]}),(0,r.jsx)(N.Z,{open:!1!==u,onClose:m,"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",children:(0,r.jsxs)(s.Z,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:720,bgcolor:"background.paper",border:"2px solid #000",boxShadow:24,p:4},children:[(0,r.jsx)(a.Z,{id:"modal-modal-title",variant:"h6",component:"h2",children:u}),(0,r.jsx)(a.Z,{id:"modal-modal-description",sx:{mt:2},component:"pre",children:"root"===u?c:f})]})})]})}function M(){let[e,t]=o.useState([]);return o.useEffect(()=>{let e=async()=>{let e=await fetch("/config/apps/pki/certificate_authorities"),n=await e.json(),r=Object.keys(n),o=[];for(let i=0;i(0,r.jsx)(S,{...e},"n-".concat(t)))}),(0,r.jsx)(c.Z,{})]})})]})}},9465:function(e,t,n){"use strict";n.d(t,{Z:function(){return E}});var r=n(7297),o=n(5944),i=n(917),a=n(7294),s=n(5050),l=n(1953),c=n(784),d=n(562),f=n(9630),u=n(9934),p=n(326),h=n(6336),m=n(5084),Z=n(7056),x=n(3960),g=n(5893),v=n(5697),b=n.n(v),j=n(6010),y=n(1163),w=n(1664),C=n.n(w),k=n(8346),N=n(1719);let S=(0,N.ZP)("a")({}),M=a.forwardRef(function(e,t){let{to:n,linkAs:r,replace:o,scroll:i,shallow:a,prefetch:s,locale:l,...c}=e;return(0,g.jsx)(C(),{href:n,prefetch:s,as:r,replace:o,scroll:i,shallow:a,passHref:!0,locale:l,children:(0,g.jsx)(S,{ref:t,...c})})});M.propTypes={href:b().any,linkAs:b().oneOfType([b().object,b().string]),locale:b().string,passHref:b().bool,prefetch:b().bool,replace:b().bool,scroll:b().bool,shallow:b().bool,to:b().oneOfType([b().object,b().string]).isRequired};let R=a.forwardRef(function(e,t){let{activeClassName:n="active",as:r,className:o,href:i,linkAs:a,locale:s,noLinkStyle:l,prefetch:c,replace:d,role:f,scroll:u,shallow:p,...h}=e,m=(0,y.useRouter)(),Z="string"==typeof i?i:i.pathname,x=(0,j.Z)(o,{[n]:m.pathname===Z&&n}),v="string"==typeof i&&(0===i.indexOf("http")||0===i.indexOf("mailto:"));if(v)return l?(0,g.jsx)(S,{className:x,href:i,ref:t,...h}):(0,g.jsx)(k.Z,{className:x,href:i,ref:t,...h});let b={to:i,linkAs:a||r,replace:d,scroll:u,shallow:p,prefetch:c,locale:s};return l?(0,g.jsx)(M,{className:x,ref:t,...b,...h}):(0,g.jsx)(k.Z,{component:M,className:x,ref:t,...b,...h})});function _(){let e=(0,r.Z)(["\n color: white;\n "]);return _=function(){return e},e}function O(){let e=(0,r.Z)(["\n color: white;\n "]);return O=function(){return e},e}R.propTypes={activeClassName:b().string,as:b().oneOfType([b().object,b().string]),className:b().string,href:b().any,linkAs:b().oneOfType([b().object,b().string]),locale:b().string,noLinkStyle:b().bool,prefetch:b().bool,replace:b().bool,role:b().string,scroll:b().bool,shallow:b().bool};let A=[{name:"Upstream",href:"/upstream"},{name:"PKI",href:"/pki-view"},{name:"Load",href:"/setup"},{name:"Adapt",href:"/convert-config"},{name:"Metrics",href:"/monitor"}],T=()=>{let[e,t]=a.useState(null),n=e=>{t(e.currentTarget)},r=()=>{t(null)};return(0,o.tZ)(s.Z,{position:"static",children:(0,o.tZ)(h.Z,{maxWidth:"lg",children:(0,o.BX)(c.Z,{disableGutters:!0,children:[(0,o.tZ)(x.Z,{sx:{display:{xs:"none",md:"flex"},mr:1}}),(0,o.tZ)(f.Z,{variant:"h6",noWrap:!0,component:"a",href:"/",sx:{mr:2,display:{xs:"none",md:"flex"},fontFamily:"monospace",fontWeight:700,letterSpacing:".3rem",color:"inherit",textDecoration:"none"},children:"Caddy Config"}),(0,o.BX)(l.Z,{sx:{flexGrow:1,display:{xs:"flex",md:"none"}},children:[(0,o.tZ)(d.Z,{size:"large","aria-label":"account of current user","aria-controls":"menu-appbar","aria-haspopup":"true",onClick:n,color:"inherit",children:(0,o.tZ)(p.Z,{})}),(0,o.tZ)(u.Z,{id:"menu-appbar",anchorEl:e,anchorOrigin:{vertical:"bottom",horizontal:"left"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"left"},open:Boolean(e),onClose:r,sx:{display:{xs:"block",md:"none"}},children:A.map(e=>(0,o.tZ)(Z.Z,{onClick:r,children:(0,o.tZ)(R,{href:e.href,css:(0,i.iv)(_()),children:(0,o.tZ)(f.Z,{textAlign:"center",children:e.name})})},e.name))})]}),(0,o.tZ)(x.Z,{sx:{display:{xs:"flex",md:"none"},mr:1}}),(0,o.tZ)(f.Z,{variant:"h5",noWrap:!0,component:"a",href:"",sx:{mr:2,display:{xs:"flex",md:"none"},flexGrow:1,fontFamily:"monospace",fontWeight:700,letterSpacing:".3rem",color:"inherit",textDecoration:"none"},children:"Caddy Config"}),(0,o.tZ)(l.Z,{sx:{flexGrow:1,display:{xs:"none",md:"flex"}},children:A.map(e=>(0,o.tZ)(m.Z,{onClick:r,sx:{my:2,color:"white",display:"block"},children:(0,o.tZ)(R,{href:e.href,css:(0,i.iv)(O()),children:e.name})},e.name))})]})})})};var E=T},1906:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(5893);n(7294);var o=n(9630),i=n(8346);function a(){return(0,r.jsxs)(o.Z,{variant:"body2",color:"text.secondary",align:"center",children:["Copyright \xa9 ",(0,r.jsx)(i.Z,{color:"inherit",href:"https://github.com/gsmlg-dev/",children:"GSMLG-DEV"})," ",new Date().getFullYear(),"."]})}}},function(e){e.O(0,[514,774,888,179],function(){return e(e.s=7296)}),_N_E=e.O()}]); -------------------------------------------------------------------------------- /build/_next/static/chunks/pages/setup-c915f8a2afc97173.js: -------------------------------------------------------------------------------- 1 | (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[463],{4488:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/setup",function(){return n(107)}])},107:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return f}});var a=n(5893),s=n(7294),i=n(5152),o=n.n(i),c=n(6336),r=n(9630),l=n(1953),u=n(5084),d=n(9465),h=n(1906);let p=o()(()=>Promise.all([n.e(281),n.e(317),n.e(544)]).then(n.bind(n,8544)),{loadableGenerated:{webpack:()=>[8544]},ssr:!1});function f(){let[e,t]=s.useState(""),[n,i]=s.useState(""),o=s.useCallback(async()=>{let e=await fetch("/config/"),n=await e.json();t(JSON.stringify(n,null,2)),i("")},[]);s.useEffect(()=>{o()},[]);let f=s.useCallback(e=>{t(e)},[]),x=s.useCallback(async t=>{let n=new Request("/load",{method:"POST",headers:{"Content-Type":"application/json"},body:e}),a=await fetch(n);await a.text(),i("Save success!")},[e]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.Z,{}),(0,a.jsx)(c.Z,{maxWidth:"lg",children:(0,a.jsxs)(l.Z,{sx:{my:4},children:[(0,a.jsx)(r.Z,{variant:"h4",component:"h1",gutterBottom:!0,children:"Caddy Server Load"}),(0,a.jsxs)(r.Z,{variant:"p",component:"p",gutterBottom:!0,children:[(0,a.jsx)(u.Z,{variant:"outlined",onClick:o,children:"Reset"})," ",(0,a.jsx)(u.Z,{variant:"contained",onClick:x,children:"Save"})]}),(0,a.jsx)(r.Z,{variant:"p",component:"p",gutterBottom:!0,style:{minHeight:600},children:(0,a.jsx)(p,{onChange:f,value:e,height:600})}),(0,a.jsx)(r.Z,{variant:"p",component:"p",gutterBottom:!0,children:n}),(0,a.jsx)(h.Z,{})]})})]})}}},function(e){e.O(0,[514,626,774,888,179],function(){return e(e.s=4488)}),_N_E=e.O()}]); -------------------------------------------------------------------------------- /build/_next/static/chunks/pages/upstream-161a5bae7183a18f.js: -------------------------------------------------------------------------------- 1 | (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[83],{9837:function(e,t,n){"use strict";n.d(t,{Z:function(){return g}});var r=n(7462),o=n(3366),a=n(7294),i=n(6010),s=n(4780),l=n(1719),c=n(8884),f=n(1401),u=n(1588),d=n(4867);function h(e){return(0,d.Z)("MuiCard",e)}(0,u.Z)("MuiCard",["root"]);var p=n(5893);let m=["className","raised"],Z=e=>{let{classes:t}=e;return(0,s.Z)({root:["root"]},h,t)},x=(0,l.ZP)(f.Z,{name:"MuiCard",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({overflow:"hidden"})),v=a.forwardRef(function(e,t){let n=(0,c.Z)({props:e,name:"MuiCard"}),{className:a,raised:s=!1}=n,l=(0,o.Z)(n,m),f=(0,r.Z)({},n,{raised:s}),u=Z(f);return(0,p.jsx)(x,(0,r.Z)({className:(0,i.Z)(u.root,a),elevation:s?8:void 0,ref:t,ownerState:f},l))});var g=v},1359:function(e,t,n){"use strict";n.d(t,{Z:function(){return v}});var r=n(7462),o=n(3366),a=n(7294),i=n(6010),s=n(4780),l=n(1719),c=n(8884),f=n(1588),u=n(4867);function d(e){return(0,u.Z)("MuiCardContent",e)}(0,f.Z)("MuiCardContent",["root"]);var h=n(5893);let p=["className","component"],m=e=>{let{classes:t}=e;return(0,s.Z)({root:["root"]},d,t)},Z=(0,l.ZP)("div",{name:"MuiCardContent",slot:"Root",overridesResolver:(e,t)=>t.root})(()=>({padding:16,"&:last-child":{paddingBottom:24}})),x=a.forwardRef(function(e,t){let n=(0,c.Z)({props:e,name:"MuiCardContent"}),{className:a,component:s="div"}=n,l=(0,o.Z)(n,p),f=(0,r.Z)({},n,{component:s}),u=m(f);return(0,h.jsx)(Z,(0,r.Z)({as:s,className:(0,i.Z)(u.root,a),ownerState:f,ref:t},l))});var v=x},5048:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/upstream",function(){return n(4264)}])},4264:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var r=n(5893),o=n(7294),a=n(6336),i=n(9630),s=n(1953),l=n(9465),c=n(1906),f=n(9837),u=n(1359);function d(e){let{address:t,healthy:n,num_requests:o,fails:a}=e;return(0,r.jsx)(f.Z,{sx:{minWidth:275},children:(0,r.jsxs)(u.Z,{children:[(0,r.jsxs)(i.Z,{sx:{fontSize:14},color:"text.secondary",gutterBottom:!0,children:["Healthy: ",n?"\uD83D\uDC4D":"\uD83D\uDC4E"]}),(0,r.jsxs)(i.Z,{variant:"h5",component:"div",children:["Address: ",t]}),(0,r.jsxs)(i.Z,{variant:"body2",children:["Requests: ".concat(o),(0,r.jsx)("br",{}),"Fails: ".concat(a)]})]})})}function h(){let[e,t]=o.useState([]);return o.useEffect(()=>{let e=async()=>{let e=await fetch("/reverse_proxy/upstreams"),n=await e.json();t(n)};e()},[]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.Z,{}),(0,r.jsx)(a.Z,{maxWidth:"lg",children:(0,r.jsxs)(s.Z,{sx:{my:4},children:[(0,r.jsx)(i.Z,{variant:"h4",component:"h1",gutterBottom:!0,children:"Caddy Server Upstream"}),(0,r.jsx)(i.Z,{variant:"p",component:"p",gutterBottom:!0,children:e.map(e=>(0,r.jsx)(d,{...e}))}),(0,r.jsx)(c.Z,{})]})})]})}},9465:function(e,t,n){"use strict";n.d(t,{Z:function(){return T}});var r=n(7297),o=n(5944),a=n(917),i=n(7294),s=n(5050),l=n(1953),c=n(784),f=n(562),u=n(9630),d=n(9934),h=n(326),p=n(6336),m=n(5084),Z=n(7056),x=n(3960),v=n(5893),g=n(5697),y=n.n(g),j=n(6010),b=n(1163),C=n(1664),w=n.n(C),k=n(8346),N=n(1719);let _=(0,N.ZP)("a")({}),D=i.forwardRef(function(e,t){let{to:n,linkAs:r,replace:o,scroll:a,shallow:i,prefetch:s,locale:l,...c}=e;return(0,v.jsx)(w(),{href:n,prefetch:s,as:r,replace:o,scroll:a,shallow:i,passHref:!0,locale:l,children:(0,v.jsx)(_,{ref:t,...c})})});D.propTypes={href:y().any,linkAs:y().oneOfType([y().object,y().string]),locale:y().string,passHref:y().bool,prefetch:y().bool,replace:y().bool,scroll:y().bool,shallow:y().bool,to:y().oneOfType([y().object,y().string]).isRequired};let M=i.forwardRef(function(e,t){let{activeClassName:n="active",as:r,className:o,href:a,linkAs:i,locale:s,noLinkStyle:l,prefetch:c,replace:f,role:u,scroll:d,shallow:h,...p}=e,m=(0,b.useRouter)(),Z="string"==typeof a?a:a.pathname,x=(0,j.Z)(o,{[n]:m.pathname===Z&&n}),g="string"==typeof a&&(0===a.indexOf("http")||0===a.indexOf("mailto:"));if(g)return l?(0,v.jsx)(_,{className:x,href:a,ref:t,...p}):(0,v.jsx)(k.Z,{className:x,href:a,ref:t,...p});let y={to:a,linkAs:i||r,replace:f,scroll:d,shallow:h,prefetch:c,locale:s};return l?(0,v.jsx)(D,{className:x,ref:t,...y,...p}):(0,v.jsx)(k.Z,{component:D,className:x,ref:t,...y,...p})});function R(){let e=(0,r.Z)(["\n color: white;\n "]);return R=function(){return e},e}function O(){let e=(0,r.Z)(["\n color: white;\n "]);return O=function(){return e},e}M.propTypes={activeClassName:y().string,as:y().oneOfType([y().object,y().string]),className:y().string,href:y().any,linkAs:y().oneOfType([y().object,y().string]),locale:y().string,noLinkStyle:y().bool,prefetch:y().bool,replace:y().bool,role:y().string,scroll:y().bool,shallow:y().bool};let S=[{name:"Upstream",href:"/upstream"},{name:"PKI",href:"/pki-view"},{name:"Load",href:"/setup"},{name:"Adapt",href:"/convert-config"},{name:"Metrics",href:"/monitor"}],E=()=>{let[e,t]=i.useState(null),n=e=>{t(e.currentTarget)},r=()=>{t(null)};return(0,o.tZ)(s.Z,{position:"static",children:(0,o.tZ)(p.Z,{maxWidth:"lg",children:(0,o.BX)(c.Z,{disableGutters:!0,children:[(0,o.tZ)(x.Z,{sx:{display:{xs:"none",md:"flex"},mr:1}}),(0,o.tZ)(u.Z,{variant:"h6",noWrap:!0,component:"a",href:"/",sx:{mr:2,display:{xs:"none",md:"flex"},fontFamily:"monospace",fontWeight:700,letterSpacing:".3rem",color:"inherit",textDecoration:"none"},children:"Caddy Config"}),(0,o.BX)(l.Z,{sx:{flexGrow:1,display:{xs:"flex",md:"none"}},children:[(0,o.tZ)(f.Z,{size:"large","aria-label":"account of current user","aria-controls":"menu-appbar","aria-haspopup":"true",onClick:n,color:"inherit",children:(0,o.tZ)(h.Z,{})}),(0,o.tZ)(d.Z,{id:"menu-appbar",anchorEl:e,anchorOrigin:{vertical:"bottom",horizontal:"left"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"left"},open:Boolean(e),onClose:r,sx:{display:{xs:"block",md:"none"}},children:S.map(e=>(0,o.tZ)(Z.Z,{onClick:r,children:(0,o.tZ)(M,{href:e.href,css:(0,a.iv)(R()),children:(0,o.tZ)(u.Z,{textAlign:"center",children:e.name})})},e.name))})]}),(0,o.tZ)(x.Z,{sx:{display:{xs:"flex",md:"none"},mr:1}}),(0,o.tZ)(u.Z,{variant:"h5",noWrap:!0,component:"a",href:"",sx:{mr:2,display:{xs:"flex",md:"none"},flexGrow:1,fontFamily:"monospace",fontWeight:700,letterSpacing:".3rem",color:"inherit",textDecoration:"none"},children:"Caddy Config"}),(0,o.tZ)(l.Z,{sx:{flexGrow:1,display:{xs:"none",md:"flex"}},children:S.map(e=>(0,o.tZ)(m.Z,{onClick:r,sx:{my:2,color:"white",display:"block"},children:(0,o.tZ)(M,{href:e.href,css:(0,a.iv)(O()),children:e.name})},e.name))})]})})})};var T=E},1906:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=n(5893);n(7294);var o=n(9630),a=n(8346);function i(){return(0,r.jsxs)(o.Z,{variant:"body2",color:"text.secondary",align:"center",children:["Copyright \xa9 ",(0,r.jsx)(a.Z,{color:"inherit",href:"https://github.com/gsmlg-dev/",children:"GSMLG-DEV"})," ",new Date().getFullYear(),"."]})}}},function(e){e.O(0,[514,774,888,179],function(){return e(e.s=5048)}),_N_E=e.O()}]); -------------------------------------------------------------------------------- /build/_next/static/chunks/webpack-b48a405952ad4f00.js: -------------------------------------------------------------------------------- 1 | !function(){"use strict";var e,t,n,r,o,u,i,c,f,a={},d={};function l(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={id:e,loaded:!1,exports:{}},r=!0;try{a[e].call(n.exports,n,n.exports,l),r=!1}finally{r&&delete d[e]}return n.loaded=!0,n.exports}l.m=a,l.amdD=function(){throw Error("define cannot be used indirect")},e=[],l.O=function(t,n,r,o){if(n){o=o||0;for(var u=e.length;u>0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u=o&&Object.keys(l.O).every(function(e){return l.O[e](n[f])})?n.splice(f--,1):(c=!1,o

Caddy Server Load

Copyright © GSMLG-DEV 2022.

-------------------------------------------------------------------------------- /build/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsmlg-dev/caddy-admin-ui/216284ec390740f0faf41af5682d8c42c54d15da/build/favicon.ico -------------------------------------------------------------------------------- /build/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /build/monitor.html: -------------------------------------------------------------------------------- 1 |

Caddy Server Metrics

-------------------------------------------------------------------------------- /build/pki-view.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /build/setup.html: -------------------------------------------------------------------------------- 1 |

Caddy Server Load

Copyright © GSMLG-DEV 2022.

-------------------------------------------------------------------------------- /build/upstream.html: -------------------------------------------------------------------------------- 1 |

Caddy Server Upstream

Copyright © GSMLG-DEV 2022.

-------------------------------------------------------------------------------- /caddy_admin_ui.go: -------------------------------------------------------------------------------- 1 | package caddy_admin_ui 2 | 3 | import ( 4 | "bytes" 5 | "embed" 6 | "fmt" 7 | "io/fs" 8 | "mime" 9 | "net/http" 10 | "net/url" 11 | "os" 12 | "path" 13 | "path/filepath" 14 | "strconv" 15 | "strings" 16 | "time" 17 | 18 | "github.com/caddyserver/caddy/v2" 19 | "github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" 20 | "github.com/caddyserver/caddy/v2/modules/caddyhttp" 21 | 22 | "go.uber.org/zap" 23 | ) 24 | 25 | const DirectiveName = "caddy_admin_ui" 26 | 27 | // Replace this at compile time 28 | var compileUnixTime = "1657605601" 29 | 30 | func init() { 31 | httpcaddyfile.RegisterHandlerDirective(DirectiveName, parseCaddyfile) 32 | 33 | caddy.RegisterModule(CaddyAdminUI{}) 34 | } 35 | 36 | // CaddyAdminUI implements a static file server responder for Caddy. 37 | type CaddyAdminUI struct { 38 | // The names of files to try as index files if a folder is requested. 39 | IndexNames []string `json:"index_names,omitempty"` 40 | 41 | // Append suffix to request filename if origin name is not exists. 42 | SuffixNames []string `json:"suffix_names,omitempty"` 43 | 44 | logger *zap.Logger 45 | } 46 | 47 | // CaddyModule returns the Caddy module information. 48 | func (CaddyAdminUI) CaddyModule() caddy.ModuleInfo { 49 | return caddy.ModuleInfo{ 50 | ID: "http.handlers." + DirectiveName, 51 | New: func() caddy.Module { return new(CaddyAdminUI) }, 52 | } 53 | } 54 | 55 | // Provision sets up the static files responder. 56 | func (adminUI *CaddyAdminUI) Provision(ctx caddy.Context) error { 57 | adminUI.logger = ctx.Logger(adminUI) 58 | 59 | adminUI.IndexNames = []string{"index.html", "index.htm", "index.txt"} 60 | 61 | adminUI.SuffixNames = []string{"html", "htm", "txt"} 62 | 63 | files, err := getAllFilenames(&buildFs, "build") 64 | adminUI.logger.Debug("list files of caddy_admin_ui", 65 | zap.Strings("files", files), 66 | zap.Error(err)) 67 | 68 | return nil 69 | } 70 | 71 | func (adminUI *CaddyAdminUI) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error { 72 | repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer) 73 | 74 | // PathUnescape returns an error if the escapes aren't well-formed, 75 | // meaning the count % matches the RFC. Return early if the escape is 76 | // improper. 77 | if _, err := url.PathUnescape(r.URL.Path); err != nil { 78 | adminUI.logger.Debug("improper path escape", 79 | zap.String("request_path", r.URL.Path), 80 | zap.Error(err)) 81 | return err 82 | } 83 | filename := "build" + r.URL.Path 84 | 85 | adminUI.logger.Debug("sanitized path join", 86 | zap.String("request_path", r.URL.Path), 87 | zap.String("result", filename)) 88 | 89 | // get information about the file 90 | opF, err := buildFs.Open(filename) 91 | var info fs.FileInfo 92 | if err != nil { 93 | adminUI.logger.Debug("filename is not exists, try to find with index and suffix", 94 | zap.String("error", err.Error()), 95 | zap.String("filename", filename), 96 | zap.String("File", fmt.Sprintf("%v", opF)), 97 | zap.String("FileSystem", fmt.Sprintf("%v", buildFs))) 98 | err = mapDirOpenError(err, filename) 99 | if os.IsNotExist(err) { 100 | if len(adminUI.IndexNames) > 0 { 101 | for _, indexPage := range adminUI.IndexNames { 102 | indexPage := repl.ReplaceAll(indexPage, "") 103 | indexPath := caddyhttp.SanitizedPathJoin(filename, indexPage) 104 | 105 | opF, err = buildFs.Open(indexPath) 106 | if err != nil { 107 | continue 108 | } 109 | info, err = opF.Stat() 110 | filename = indexPath 111 | // implicitIndexFile = true 112 | adminUI.logger.Debug("located file with index filename", zap.String("filename", filename), zap.String("indexPage", indexPage)) 113 | break 114 | } 115 | } 116 | if info == nil && !strings.HasSuffix(filename, "/") { 117 | suffixList := []string{"html", "htm", "txt", "md"} 118 | for _, suffix := range suffixList { 119 | suffix := repl.ReplaceAll(suffix, "") 120 | filePath := fmt.Sprintf("%s.%s", filename, suffix) 121 | 122 | opF, err = buildFs.Open(filePath) 123 | if err != nil { 124 | continue 125 | } 126 | info, err = opF.Stat() 127 | filename = filePath 128 | adminUI.logger.Debug("located file with suffix filename", zap.String("filename", filename), zap.String("suffix", suffix)) 129 | break 130 | } 131 | } 132 | if info == nil { 133 | adminUI.logger.Debug("open file error", 134 | zap.String("error", err.Error()), 135 | zap.String("File", fmt.Sprintf("%v", opF)), 136 | zap.String("FileSystem", fmt.Sprintf("%v", buildFs))) 137 | return adminUI.notFound(w, r, next) 138 | } 139 | } 140 | } else { 141 | info, err = opF.Stat() 142 | if err != nil { 143 | return caddyhttp.Error(http.StatusInternalServerError, err) 144 | } 145 | } 146 | 147 | var file []byte 148 | 149 | // no precompressed file found, use the actual file 150 | if file == nil { 151 | adminUI.logger.Debug("opening file", zap.String("filename", filename)) 152 | 153 | // open the file 154 | file, err = adminUI.openFile(filename, w) 155 | if err != nil { 156 | if herr, ok := err.(caddyhttp.HandlerError); ok && 157 | herr.StatusCode == http.StatusNotFound { 158 | return adminUI.notFound(w, r, next) 159 | } 160 | return err // error is already structured 161 | } 162 | } 163 | 164 | // set the ETag - note that a conditional If-None-Match request is handled 165 | // by http.ServeContent below, which checks against this ETag value 166 | w.Header().Set("ETag", calculateEtag(info)) 167 | 168 | // set last modify since 169 | ti, _ := strconv.ParseInt(compileUnixTime, 10, 64) 170 | tu := time.Unix(ti, 0) 171 | w.Header().Set("Last-Modified-Since", tu.Format("Mon, 02 Jan 2006 15:04:05 GMT")) 172 | 173 | if w.Header().Get("Content-Type") == "" { 174 | mtyp := mime.TypeByExtension(filepath.Ext(filename)) 175 | if mtyp == "" { 176 | // do not allow Go to sniff the content-type; see 177 | // https://www.youtube.com/watch?v=8t8JYpt0egE 178 | // TODO: If we want a Content-Type, consider writing a default of application/octet-stream - this is secure but violates spec 179 | w.Header()["Content-Type"] = nil 180 | } else { 181 | w.Header().Set("Content-Type", mtyp) 182 | } 183 | } 184 | 185 | // let the standard library do what it does best; note, however, 186 | // that errors generated by ServeContent are written immediately 187 | // to the response, so we cannot handle them (but errors there 188 | // are rare) 189 | http.ServeContent(w, r, info.Name(), info.ModTime(), bytes.NewReader(file)) 190 | 191 | return nil 192 | } 193 | 194 | // openFile opens the file at the given filename. If there was an error, 195 | // the response is configured to inform the client how to best handle it 196 | // and a well-described handler error is returned (do not wrap the 197 | // returned error value). 198 | func (adminUI *CaddyAdminUI) openFile(filename string, w http.ResponseWriter) ([]byte, error) { 199 | file, err := buildFs.ReadFile(filename) 200 | if err != nil { 201 | err = mapDirOpenError(err, filename) 202 | if os.IsNotExist(err) { 203 | adminUI.logger.Debug("file not found", zap.String("filename", filename), zap.Error(err)) 204 | return nil, caddyhttp.Error(http.StatusNotFound, err) 205 | } 206 | return nil, caddyhttp.Error(http.StatusServiceUnavailable, err) 207 | } 208 | return file, nil 209 | } 210 | 211 | // mapDirOpenError maps the provided non-nil error from opening name 212 | // to a possibly better non-nil error. In particular, it turns OS-specific errors 213 | // about opening files in non-directories into os.ErrNotExist. See golang/go#18984. 214 | // Adapted from the Go standard library; originally written by Nathaniel Caza. 215 | // https://go-review.googlesource.com/c/go/+/36635/ 216 | // https://go-review.googlesource.com/c/go/+/36804/ 217 | func mapDirOpenError(originalErr error, name string) error { 218 | if os.IsNotExist(originalErr) { 219 | return originalErr 220 | } 221 | 222 | parts := strings.Split(name, separator) 223 | for i := range parts { 224 | if parts[i] == "" { 225 | continue 226 | } 227 | fi, err := os.Stat(strings.Join(parts[:i+1], separator)) 228 | if err != nil { 229 | return originalErr 230 | } 231 | if !fi.IsDir() { 232 | return os.ErrNotExist 233 | } 234 | } 235 | 236 | return originalErr 237 | } 238 | 239 | // it calls the next handler in the chain. 240 | func (fsrv *CaddyAdminUI) notFound(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error { 241 | return next.ServeHTTP(w, r) 242 | } 243 | 244 | // parseCaddyfile parses the caddy_admin_ui directive. It enables the static file 245 | // server and configures it with this syntax: 246 | // 247 | // caddy_admin_ui 248 | // 249 | func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) { 250 | var adminUI CaddyAdminUI 251 | 252 | for h.Next() { 253 | for h.NextBlock(0) { 254 | switch h.Val() { 255 | 256 | default: 257 | return nil, h.Errf("unknown subdirective '%s'", h.Val()) 258 | } 259 | } 260 | } 261 | 262 | return &adminUI, nil 263 | } 264 | 265 | // calculateEtag produces a strong etag by default, although, for 266 | // efficiency reasons, it does not actually consume the contents 267 | // of the file to make a hash of all the bytes. ¯\_(ツ)_/¯ 268 | // Prefix the etag with "W/" to convert it into a weak etag. 269 | // See: https://tools.ietf.org/html/rfc7232#section-2.3 270 | func calculateEtag(d os.FileInfo) string { 271 | ti, _ := strconv.ParseInt(compileUnixTime, 10, 64) 272 | t := strconv.FormatInt(ti, 36) 273 | s := strconv.FormatInt(d.Size(), 36) 274 | return `"` + t + "_" + s + `"` 275 | } 276 | 277 | func getAllFilenames(fs *embed.FS, dir string) (out []string, err error) { 278 | if len(dir) == 0 { 279 | dir = "." 280 | } 281 | 282 | entries, err := fs.ReadDir(dir) 283 | if err != nil { 284 | return nil, err 285 | } 286 | 287 | for _, entry := range entries { 288 | fp := path.Join(dir, entry.Name()) 289 | if entry.IsDir() { 290 | res, err := getAllFilenames(fs, fp) 291 | if err != nil { 292 | return nil, err 293 | } 294 | 295 | out = append(out, res...) 296 | 297 | continue 298 | } 299 | 300 | out = append(out, fp) 301 | } 302 | 303 | return 304 | } 305 | 306 | const ( 307 | separator = string(filepath.Separator) 308 | ) 309 | 310 | //go:embed all:build/* 311 | var buildFs embed.FS 312 | 313 | // Interface guards 314 | var ( 315 | _ caddy.Provisioner = (*CaddyAdminUI)(nil) 316 | _ caddyhttp.MiddlewareHandler = (*CaddyAdminUI)(nil) 317 | ) 318 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gsmlg-dev/caddy-admin-ui 2 | 3 | go 1.18 4 | 5 | require ( 6 | github.com/caddyserver/caddy/v2 v2.5.1 7 | go.uber.org/zap v1.21.0 8 | ) 9 | 10 | require ( 11 | filippo.io/edwards25519 v1.0.0-rc.1 // indirect 12 | github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect 13 | github.com/Masterminds/goutils v1.1.1 // indirect 14 | github.com/Masterminds/semver/v3 v3.1.1 // indirect 15 | github.com/Masterminds/sprig/v3 v3.2.2 // indirect 16 | github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f // indirect 17 | github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b // indirect 18 | github.com/beorn7/perks v1.0.1 // indirect 19 | github.com/caddyserver/certmagic v0.16.1 // indirect 20 | github.com/cespare/xxhash v1.1.0 // indirect 21 | github.com/cespare/xxhash/v2 v2.1.2 // indirect 22 | github.com/cheekybits/genny v1.0.0 // indirect 23 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect 24 | github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect 25 | github.com/dgraph-io/badger v1.6.2 // indirect 26 | github.com/dgraph-io/badger/v2 v2.2007.4 // indirect 27 | github.com/dgraph-io/ristretto v0.0.4-0.20200906165740-41ebdbffecfd // indirect 28 | github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect 29 | github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect 30 | github.com/fsnotify/fsnotify v1.5.1 // indirect 31 | github.com/go-kit/kit v0.10.0 // indirect 32 | github.com/go-logfmt/logfmt v0.5.0 // indirect 33 | github.com/go-sql-driver/mysql v1.6.0 // indirect 34 | github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect 35 | github.com/golang/protobuf v1.5.2 // indirect 36 | github.com/golang/snappy v0.0.4 // indirect 37 | github.com/google/cel-go v0.7.3 // indirect 38 | github.com/google/uuid v1.3.0 // indirect 39 | github.com/huandu/xstrings v1.3.2 // indirect 40 | github.com/imdario/mergo v0.3.12 // indirect 41 | github.com/jackc/chunkreader/v2 v2.0.1 // indirect 42 | github.com/jackc/pgconn v1.10.1 // indirect 43 | github.com/jackc/pgio v1.0.0 // indirect 44 | github.com/jackc/pgpassfile v1.0.0 // indirect 45 | github.com/jackc/pgproto3/v2 v2.2.0 // indirect 46 | github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect 47 | github.com/jackc/pgtype v1.9.0 // indirect 48 | github.com/jackc/pgx/v4 v4.14.0 // indirect 49 | github.com/klauspost/compress v1.15.0 // indirect 50 | github.com/klauspost/cpuid/v2 v2.0.11 // indirect 51 | github.com/libdns/libdns v0.2.1 // indirect 52 | github.com/lucas-clemente/quic-go v0.26.0 // indirect 53 | github.com/manifoldco/promptui v0.9.0 // indirect 54 | github.com/marten-seemann/qpack v0.2.1 // indirect 55 | github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect 56 | github.com/marten-seemann/qtls-go1-17 v0.1.1 // indirect 57 | github.com/marten-seemann/qtls-go1-18 v0.1.1 // indirect 58 | github.com/mattn/go-colorable v0.1.8 // indirect 59 | github.com/mattn/go-isatty v0.0.13 // indirect 60 | github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect 61 | github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect 62 | github.com/mholt/acmez v1.0.2 // indirect 63 | github.com/micromdm/scep/v2 v2.1.0 // indirect 64 | github.com/miekg/dns v1.1.46 // indirect 65 | github.com/mitchellh/copystructure v1.2.0 // indirect 66 | github.com/mitchellh/go-ps v1.0.0 // indirect 67 | github.com/mitchellh/reflectwalk v1.0.2 // indirect 68 | github.com/nxadm/tail v1.4.8 // indirect 69 | github.com/onsi/ginkgo v1.16.4 // indirect 70 | github.com/pkg/errors v0.9.1 // indirect 71 | github.com/prometheus/client_golang v1.12.1 // indirect 72 | github.com/prometheus/client_model v0.2.0 // indirect 73 | github.com/prometheus/common v0.32.1 // indirect 74 | github.com/prometheus/procfs v0.7.3 // indirect 75 | github.com/rs/xid v1.2.1 // indirect 76 | github.com/russross/blackfriday/v2 v2.0.1 // indirect 77 | github.com/shopspring/decimal v1.2.0 // indirect 78 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect 79 | github.com/sirupsen/logrus v1.8.1 // indirect 80 | github.com/slackhq/nebula v1.5.2 // indirect 81 | github.com/smallstep/certificates v0.19.0 // indirect 82 | github.com/smallstep/cli v0.18.0 // indirect 83 | github.com/smallstep/nosql v0.4.0 // indirect 84 | github.com/smallstep/truststore v0.11.0 // indirect 85 | github.com/spf13/cast v1.4.1 // indirect 86 | github.com/stoewer/go-strcase v1.2.0 // indirect 87 | github.com/tailscale/tscert v0.0.0-20220125204807-4509a5fbaf74 // indirect 88 | github.com/urfave/cli v1.22.5 // indirect 89 | go.etcd.io/bbolt v1.3.6 // indirect 90 | go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect 91 | go.step.sm/cli-utils v0.7.0 // indirect 92 | go.step.sm/crypto v0.16.1 // indirect 93 | go.step.sm/linkedca v0.15.0 // indirect 94 | go.uber.org/atomic v1.9.0 // indirect 95 | go.uber.org/multierr v1.6.0 // indirect 96 | golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2 // indirect 97 | golang.org/x/mod v0.4.2 // indirect 98 | golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect 99 | golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect 100 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect 101 | golang.org/x/text v0.3.8-0.20211004125949-5bd84dd9b33b // indirect 102 | golang.org/x/tools v0.1.7 // indirect 103 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect 104 | google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf // indirect 105 | google.golang.org/grpc v1.44.0 // indirect 106 | google.golang.org/protobuf v1.27.1 // indirect 107 | gopkg.in/square/go-jose.v2 v2.6.0 // indirect 108 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect 109 | howett.net/plist v1.0.0 // indirect 110 | ) 111 | -------------------------------------------------------------------------------- /screenshots/load.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsmlg-dev/caddy-admin-ui/216284ec390740f0faf41af5682d8c42c54d15da/screenshots/load.jpg -------------------------------------------------------------------------------- /screenshots/metrics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsmlg-dev/caddy-admin-ui/216284ec390740f0faf41af5682d8c42c54d15da/screenshots/metrics.png -------------------------------------------------------------------------------- /screenshots/pki.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsmlg-dev/caddy-admin-ui/216284ec390740f0faf41af5682d8c42c54d15da/screenshots/pki.jpg -------------------------------------------------------------------------------- /screenshots/upstream.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsmlg-dev/caddy-admin-ui/216284ec390740f0faf41af5682d8c42c54d15da/screenshots/upstream.jpg -------------------------------------------------------------------------------- /screenshots/view.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsmlg-dev/caddy-admin-ui/216284ec390740f0faf41af5682d8c42c54d15da/screenshots/view.jpg --------------------------------------------------------------------------------