index.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="apple-mobile-web-app-capable" content="yes" />
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  6. <meta charset="UTF-8">
  7. <meta name="theme-color" content="#4b75ff">
  8. <meta name="zoraxy.csrf.Token" content="{{.csrfToken}}">
  9. <link rel="icon" type="image/png" href="./favicon.png" />
  10. <title>Control Panel | Zoraxy</title>
  11. <link rel="stylesheet" href="script/semantic/semantic.min.css">
  12. <script src="script/jquery-3.6.0.min.js"></script>
  13. <script src="script/semantic/semantic.min.js"></script>
  14. <script src="script/tablesort.js"></script>
  15. <script src="script/countryCode.js"></script>
  16. <script src="script/chart.js"></script>
  17. <script src="script/utils.js"></script>
  18. <link rel="stylesheet" href="main.css">
  19. <link rel="stylesheet" href="darktheme.css">
  20. </head>
  21. <body>
  22. <script src="script/darktheme.js"></script>
  23. <div class="menubar">
  24. <div class="item">
  25. <img class="logo" src="img/logo.svg">
  26. </div>
  27. <div class="ui right floated buttons menutoggle" style="padding-top: 2px;">
  28. <button id="sidemenuBtn" class="ui basic icon button" onclick="$('.toolbar').fadeToggle('fast');"><i class="content icon"></i></button>
  29. </div>
  30. <div class="ui right floated buttons" style="padding-top: 2px; padding-right: 0.4em;">
  31. <button class="ui basic white icon button" onclick="logout();"><i class="sign-out icon"></i></button>
  32. </div>
  33. <div class="ui right floated buttons" style="padding-top: 2px; margin-right: 0.4em;">
  34. <button id="themeColorButton" class="ui icon button" onclick="toggleTheme();"><i class="sun icon"></i></button>
  35. </div>
  36. </div>
  37. <div class="wrapper">
  38. <div class="toolbar">
  39. <div id="mainmenu" class="ui secondary vertical menu">
  40. <a class="item" tag="qstart">
  41. <i class="simplistic magic icon"></i>Quick Start
  42. </a>
  43. <a class="item active" tag="status">
  44. <i class="simplistic info circle icon"></i>Status
  45. </a>
  46. <a class="item" tag="setroot">
  47. <i class="simplistic home icon"></i> Default Site
  48. </a>
  49. <div class="ui divider menudivider">Reverse Proxy</div>
  50. <a class="item" tag="httprp">
  51. <i class="simplistic sitemap icon"></i> HTTP Proxy
  52. </a>
  53. <a class="item" tag="vdir">
  54. <i class="simplistic folder icon"></i> Virtual Directory
  55. </a>
  56. <a class="item" tag="rules">
  57. <i class="simplistic plus square icon"></i> Create Proxy Rules
  58. </a>
  59. <a class="item" tag="streamproxy">
  60. <i class="simplistic exchange icon"></i> Stream Proxy
  61. </a>
  62. <div class="ui divider menudivider">Access & Connections</div>
  63. <a class="item" tag="redirectset">
  64. <i class="simplistic level up alternate icon"></i> Redirection
  65. </a>
  66. <a class="item" tag="access">
  67. <i class="simplistic ban icon"></i> Access Control
  68. </a>
  69. <a class="item" tag="gan">
  70. <i class="simplistic globe icon"></i> Global Area Network
  71. </a>
  72. <div class="ui divider menudivider">Security</div>
  73. <a class="item" tag="cert">
  74. <i class="simplistic lock icon"></i> TLS / SSL certificates
  75. </a>
  76. <a class="item" tag="sso">
  77. <i class="simplistic user circle icon"></i> SSO / Oauth
  78. </a>
  79. <div class="ui divider menudivider">Others</div>
  80. <a class="item" tag="webserv">
  81. <i class="simplistic globe icon"></i> Static Web Server
  82. </a>
  83. <a class="item" tag="utm">
  84. <i class="simplistic time icon"></i> Uptime Monitor
  85. </a>
  86. <a class="item" tag="networktool">
  87. <i class="simplistic terminal icon"></i> Network Tools
  88. </a>
  89. <a class="item" tag="stats">
  90. <i class="simplistic database icon"></i> Statistical Analysis
  91. </a>
  92. <a class="item" tag="utils">
  93. <i class="simplistic paperclip icon"></i> Utilities
  94. </a>
  95. <!-- Add more components here -->
  96. </div>
  97. </div>
  98. <div class="contentWindow">
  99. <!-- Quick Start -->
  100. <div id="qstart" class="functiontab" target="quickstart.html"></div>
  101. <!-- Status Tab -->
  102. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  103. <br><br><div class="ui active centered inline loader"></div>
  104. </div>
  105. <!-- Virtual Directory Tab -->
  106. <div id="vdir" class="functiontab" target="vdir.html"></div>
  107. <!-- Subdomain Proxy -->
  108. <div id="httprp" class="functiontab" target="httprp.html"></div>
  109. <!-- Create Rules -->
  110. <div id="rules" class="functiontab" target="rules.html"></div>
  111. <!-- Set proxy root -->
  112. <div id="setroot" class="functiontab" target="rproot.html"></div>
  113. <!-- Set TLS cert -->
  114. <div id="cert" class="functiontab" target="cert.html"></div>
  115. <!-- Redirections -->
  116. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  117. <!-- Blacklist -->
  118. <div id="access" class="functiontab" target="access.html"></div>
  119. <!-- Global Area Networking -->
  120. <div id="gan" class="functiontab" target="gan.html"></div>
  121. <!-- SSO / Oauth services -->
  122. <div id="sso" class="functiontab" target="sso.html"></div>
  123. <!-- TCP Proxy -->
  124. <div id="streamproxy" class="functiontab" target="streamprox.html"></div>
  125. <!-- Web Server -->
  126. <div id="webserv" class="functiontab" target="webserv.html"></div>
  127. <!-- Up Time Monitor -->
  128. <div id="utm" class="functiontab" target="uptime.html"></div>
  129. <!-- Network Tools -->
  130. <div id="networktool" class="functiontab" target="networktools.html"></div>
  131. <!-- Statistic Tools -->
  132. <div id="stats" class="functiontab" target="stats.html"></div>
  133. <!-- Utilities -->
  134. <div id="utils" class="functiontab" target="utils.html"></div>
  135. </div>
  136. </div>
  137. </div>
  138. <div class="sideWrapper" style="display:none;">
  139. <div class="fadingBackground" onclick="hideSideWrapper();"></div>
  140. <div class="content">
  141. <div class="sideWrapperMenu"></div>
  142. <iframe src="snippet/placeholder.html"></iframe>
  143. </div>
  144. </div>
  145. <br><br>
  146. <div class="ui divider"></div>
  147. <div class="ui container" style="color: grey; font-size: 90%">
  148. <p><a href="https://zoraxy.aroz.org" target="_blank">Zoraxy</a> <span class="zrversion"></span> © 2021 - <span class="year"></span> tobychui. Licensed under AGPL</p>
  149. </div>
  150. <div id="messageBox" class="ui green floating big compact message">
  151. <p><i class="green check circle icon"></i> There are no messages</p>
  152. </div>
  153. <div id="confirmBox" style="display:none;">
  154. <div class="ui top attached progress">
  155. <div class="bar" style="width: 100%; min-width: 0px;"></div>
  156. </div>
  157. <div class="confirmBoxBody">
  158. <button class="ui red basic mini circular icon right floated button" style="margin-left: 0.4em;"><i class="ui times icon"></i></button>
  159. <button class="ui green basic mini circular icon right floated button"><i class="ui check icon"></i></button>
  160. <div class="questionToConfirm">Confirm Exit?</div>
  161. </div>
  162. </div>
  163. <div id="tourModal" class="nofocus" position="center">
  164. <h4 class="tourStepTitle">Welcome to Zoraxy Tour</h4>
  165. <p class="tourStepContent">This is a simplified tour to show some of what it can do.
  166. Use your keyboard or click the next button to get going.</p>
  167. <div class="ui divider"></div>
  168. <div class="ui equal width grid" align="center">
  169. <div class="column"><button onclick="previousTourStep();" class="ui basic small disabled button tourStepButtonBack">Back</button></div>
  170. <div class="column"><p style="margin-top: 0.4em">Steps <span class="tourStepCounter">1 / 9</span></p></div>
  171. <div class="column nextStepAvaible"><button onclick="nextTourStep();" class="ui basic right floated small button tourStepButtonNext">Next</button></div>
  172. <div class="column nextStepFinish"><button onclick="endTourFocus();" class="ui right floated small button tourStepButtonFinish">Finish</button></div>
  173. </div>
  174. <button onclick="endTourFocus();" class="ui circular small icon button tourCloseButton"><i class="ui times icon"></i></button>
  175. </div>
  176. <div id="tourModalOverlay" style="display:none;"></div>
  177. <br><br>
  178. <script>
  179. $(".year").text(new Date().getFullYear());
  180. /*
  181. Loader function
  182. Load all the components view from the
  183. components/ directory into their corrisponding divs
  184. */
  185. let loadingComponents = 0;
  186. function initTabs(callback=undefined){
  187. $('.functiontab').each(function(){
  188. let loadTarget = $(this).attr("target");
  189. if (loadTarget != undefined){
  190. $(this).load("./components/" + loadTarget, function(){
  191. loadingComponents--;
  192. });
  193. loadingComponents++;
  194. }else{
  195. $(this).html(`<p>Unable to load components for this tab</p>`);
  196. }
  197. })
  198. if (callback != undefined){
  199. waitInit(callback);
  200. }
  201. }
  202. function waitInit(callback = undefined, retryCount = 0){
  203. if (loadingComponents > 0 && retryCount < 5){
  204. setTimeout(function(){
  205. waitInit(callback, retryCount++);
  206. }, 300);
  207. }else if (loadingComponents == 0){
  208. callback();
  209. }else{
  210. alert("Missing component. Please check if your installation is complete.")
  211. }
  212. }
  213. initTabs(function(){
  214. initRPStaste();
  215. if (window.location.hash.length > 1){
  216. let tabID = window.location.hash.substr(1);
  217. openTabById(tabID);
  218. }else{
  219. openTabById("status");
  220. }
  221. $(".ui.dropdown").dropdown();
  222. $(".ui.checkbox").checkbox();
  223. //Click on the current tab
  224. $("#mainmenu").find(".item").each(function(){
  225. $(this).on("click", function(event){
  226. let tabid = $(this).attr("tag");
  227. openTabById(tabid);
  228. });
  229. });
  230. //Initialize all table that is sortable
  231. $('table').tablesort();
  232. });
  233. function logout() {
  234. $.get("/api/auth/logout", function(response) {
  235. if (response === "OK") {
  236. setTimeout(function(){
  237. window.location.href = "/login.html";
  238. }, 300);
  239. }
  240. });
  241. }
  242. function toggleTheme(){
  243. if ($("body").hasClass("darkTheme")){
  244. setDarkTheme(false);
  245. //Check if the snippet iframe is opened. If yes, set the dark theme to the iframe
  246. if ($(".sideWrapper").is(":visible")){
  247. $(".sideWrapper iframe")[0].contentWindow.setDarkTheme(false);
  248. }
  249. }else{
  250. setDarkTheme(true);
  251. //Check if the snippet iframe is opened. If yes, set the dark theme to the iframe
  252. if ($(".sideWrapper").is(":visible")){
  253. $(".sideWrapper iframe")[0].contentWindow.setDarkTheme(true);
  254. }
  255. }
  256. }
  257. function getTabButtonById(targetTabId){
  258. let targetTabBtn = undefined;
  259. $("#mainmenu").find(".item").each(function(){
  260. let tabid = $(this).attr("tag");
  261. if (tabid == targetTabId){
  262. targetTabBtn = $(this);
  263. }
  264. });
  265. return targetTabBtn;
  266. }
  267. //Select and open a tab by its tag id
  268. let tabSwitchEventBind = {}; //Bind event to tab switch by tabid
  269. function openTabById(tabID){
  270. let targetBtn = getTabButtonById(tabID);
  271. if (targetBtn == undefined){
  272. alert("Invalid tabid given");
  273. return;
  274. }
  275. if (window.innerWidth < 750){
  276. //RWD mode, hide toolbar
  277. $(".toolbar").fadeOut('fast');
  278. }
  279. $("#mainmenu").find(".item").removeClass("active");
  280. $(targetBtn).addClass("active");
  281. $(".functiontab").hide();
  282. $("#" + tabID).fadeIn('fast', function(){
  283. setTimeout(function(){
  284. if (tabSwitchEventBind[tabID]){
  285. tabSwitchEventBind[tabID]();
  286. }
  287. },100)
  288. });
  289. $('html,body').animate({scrollTop: 0}, 'fast');
  290. window.location.hash = tabID;
  291. }
  292. $(window).on("resize", function(){
  293. if (window.innerWidth >= 750 && $(".toolbar").is(":visible") == false){
  294. $(".toolbar").show();
  295. }
  296. });
  297. function msgbox(message, succ=true, delayDuration=3000){
  298. let icon = `<i class="ui info circle icon"></i>`;
  299. if (succ){
  300. $("#messageBox").attr("class", "ui green floating compact message")
  301. icon = `<i class="ui green circle check icon"></i>`;
  302. }else{
  303. message = message.capitalize();
  304. $("#messageBox").attr("class", "ui red floating compact message")
  305. icon = `<i class="ui red circle times icon"></i>`;
  306. }
  307. $("#messageBox").html(`${icon} ${message}`);
  308. $("#messageBox").stop().finish().fadeIn("fast").delay(delayDuration).fadeOut("fast");
  309. }
  310. function confirmBox(question_to_confirm, callback, delaytime=15) {
  311. var progressBar = $("#confirmBox .bar");
  312. var questionElement = $("#confirmBox .questionToConfirm");
  313. //Just to make sure there are no animation runnings
  314. progressBar.stop();
  315. // Update the question to confirm
  316. questionElement.text(question_to_confirm);
  317. // Start the progress bar animation
  318. progressBar.css("width", "100%");
  319. progressBar.animate({ width: "0%", easing: "linear" }, delaytime * 1000, function() {
  320. // Animation complete, invoke the callback with undefined
  321. callback(undefined);
  322. //Unset the event listener
  323. $("#confirmBox .ui.green.button").off("click");
  324. // Hide the confirm box
  325. $("#confirmBox").hide();
  326. });
  327. // Bind click event to "Yes" button
  328. $("#confirmBox .ui.green.button").on("click", function() {
  329. // Stop the progress bar animation
  330. progressBar.stop();
  331. // Invoke the callback with true
  332. callback(true);
  333. // Hide the confirm box
  334. $("#confirmBox").hide();
  335. //Unset the event listener
  336. $("#confirmBox .ui.green.button").off("click");
  337. });
  338. // Bind click event to "No" button
  339. $("#confirmBox .ui.red.button").on("click", function() {
  340. // Stop the progress bar animation
  341. progressBar.stop();
  342. // Invoke the callback with false
  343. callback(false);
  344. // Hide the confirm box
  345. $("#confirmBox").hide();
  346. //Unset the event listener
  347. $("#confirmBox .ui.red.button").off("click");
  348. });
  349. // Show the confirm box
  350. $("#confirmBox").show().transition('jiggle');
  351. }
  352. /*
  353. Toggles for side wrapper
  354. */
  355. function showSideWrapper(scriptpath=""){
  356. if (scriptpath != ""){
  357. $(".sideWrapper iframe").attr("src", scriptpath);
  358. }
  359. if ($(".sideWrapper .content").transition("is animating") || $(".sideWrapper .content").transition("is visible")){
  360. return
  361. }
  362. $(".sideWrapper").show();
  363. $(".sideWrapper .fadingBackground").fadeIn("fast");
  364. $(".sideWrapper .content").transition('slide left in', 300);
  365. $("body").css("overflow", "hidden");
  366. }
  367. function hideSideWrapper(discardFrameContent = false){
  368. if (discardFrameContent){
  369. $(".sideWrapper iframe").attr("src", "snippet/placeholder.html");
  370. }
  371. if ($(".sideWrapper .content").transition("is animating") || !$(".sideWrapper .content").transition("is visible")){
  372. return
  373. }
  374. $(".sideWrapper .content").transition('slide left out', 300, function(){
  375. $(".sideWrapper .fadingBackground").fadeOut("fast", function(){
  376. $(".sideWrapper").hide();
  377. });
  378. });
  379. $("body").css("overflow", "auto");
  380. }
  381. </script>
  382. </body>
  383. </html>