index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. <link rel="icon" type="image/png" href="./favicon.png" />
  9. <title>Control Panel | Zoraxy</title>
  10. <link rel="stylesheet" href="script/semantic/semantic.min.css">
  11. <script src="script/jquery-3.6.0.min.js"></script>
  12. <script src="../script/ao_module.js"></script>
  13. <script src="script/semantic/semantic.min.js"></script>
  14. <script src="script/tablesort.js"></script>
  15. <style>
  16. body{
  17. background-color:white;
  18. }
  19. .functiontab{
  20. display:none;
  21. }
  22. .menubar{
  23. width: 100%;
  24. padding: 0.4em;
  25. padding-left: 1.2em;
  26. padding-right: 1.2em;
  27. background-color: #f5f5f5;
  28. margin-bottom: 1em;
  29. }
  30. .menubar .logo{
  31. height: 36px;
  32. }
  33. .menubar .item{
  34. display: inline-block;
  35. vertical-align: middle;
  36. }
  37. .wrapper{
  38. display: flex;
  39. flex-wrap: wrap;
  40. }
  41. .toolbar{
  42. width: 240px;
  43. }
  44. .contentWindow{
  45. padding: 1em;
  46. flex: 1;
  47. }
  48. @media screen and (max-width: 750px) {
  49. .toolbar {
  50. display: inline-block;
  51. width: 100%;
  52. margin-bottom: 1em;
  53. }
  54. #mainmenu{
  55. width: calc(100% - 1em);
  56. }
  57. .contentWindow{
  58. display: inline-block;
  59. width: 100%;
  60. }
  61. }
  62. .menudivider{
  63. font-size: 0.8em !important;
  64. color: #9c9c9c !important;
  65. padding-left: 0.6em;
  66. }
  67. </style>
  68. </head>
  69. <body>
  70. <div class="menubar">
  71. <div class="item">
  72. <img class="logo" src="img/logo.svg">
  73. </div>
  74. <div class="ui right floated buttons" style="padding-top: 2px;">
  75. <button class="ui basic icon button" onclick="logout();"><i class="sign-out icon"></i></button>
  76. </div>
  77. </div>
  78. <div id="errmsg" class="ui red message" style="display: none;"></div>
  79. <div class="wrapper">
  80. <div class="toolbar">
  81. <div id="mainmenu" class="ui secondary vertical pointing menu">
  82. <a class="item active" tag="status">
  83. <i class="blue info circle icon"></i>Status
  84. </a>
  85. <a class="item" tag="vdir">
  86. <i class="yellow folder icon"></i> Virtual Directory
  87. </a>
  88. <a class="item" tag="subd">
  89. <i class="teal sitemap icon"></i> Subdomain Proxy
  90. </a>
  91. <a class="item" tag="rules">
  92. <i class="brown plus square icon"></i> Create Proxy Rules
  93. </a>
  94. <a class="item" tag="setroot">
  95. <i class="home icon"></i> Set Proxy Root
  96. </a>
  97. <div class="ui divider menudivider">Access & Connections</div>
  98. <a class="item" tag="cert">
  99. <i class="orange lock icon"></i> TLS / SSL certificate
  100. </a>
  101. <a class="item" tag="redirectset">
  102. <i class="violet level up alternate icon"></i> Redirection
  103. </a>
  104. <a class="item" tag="blacklist">
  105. <i class="red ban icon"></i> Blacklist
  106. </a>
  107. <div class="ui divider menudivider">Bridging</div>
  108. <a class="item" tag="">
  109. <i class="remove icon"></i> TCP Proxy
  110. </a>
  111. <a class="item" tag="">
  112. <i class="remove icon"></i> HTTP over Websocket
  113. </a>
  114. <a class="item" tag="">
  115. <i class="remove icon"></i> UDP Hole Punching
  116. </a>
  117. <div class="ui divider menudivider">Others</div>
  118. <a class="item" tag="">
  119. <i class="remove icon"></i> Uptime Monitor
  120. </a>
  121. <a class="item" tag="">
  122. <i class="remove icon"></i> Network Tools
  123. </a>
  124. <a class="item" tag="utils">
  125. <i class="grey paperclip icon"></i> Utilities
  126. </a>
  127. <!-- Add more components here -->
  128. </div>
  129. </div>
  130. <div class="contentWindow">
  131. <!-- Status Tab -->
  132. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  133. <br><br><div class="ui active centered inline loader"></div>
  134. </div>
  135. <!-- Virtual Directory Tab -->
  136. <div id="vdir" class="functiontab" target="vdir.html"></div>
  137. <!-- Subdomain Proxy -->
  138. <div id="subd" class="functiontab" target="subd.html"></div>
  139. <!-- Create Rules -->
  140. <div id="rules" class="functiontab" target="rules.html"></div>
  141. <!-- Set proxy root -->
  142. <div id="setroot" class="functiontab" target="rproot.html"></div>
  143. <!-- Set TLS cert -->
  144. <div id="cert" class="functiontab" target="cert.html"></div>
  145. <!-- Redirections -->
  146. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  147. <!-- Blacklist -->
  148. <div id="blacklist" class="functiontab" target="blacklist.html"></div>
  149. <!-- Utilities -->
  150. <div id="utils" class="functiontab" target="utils.html"></div>
  151. </div>
  152. </div>
  153. </div>
  154. <br><br>
  155. <div class="ui divider"></div>
  156. <div class="ui container" style="color: grey; font-size: 90%">
  157. <p>CopyRight Zoraxy project and its author, 2022 - <span class="year"></span></p>
  158. </div>
  159. <br><br>
  160. <script>
  161. $(".year").text(new Date().getFullYear());
  162. /*
  163. Loader function
  164. Load all the components view from the
  165. components/ directory into their corrisponding divs
  166. */
  167. let loadingComponents = 0;
  168. function initTabs(callback=undefined){
  169. $('.functiontab').each(function(){
  170. let loadTarget = $(this).attr("target");
  171. if (loadTarget != undefined){
  172. $(this).load("./components/" + loadTarget, function(){
  173. loadingComponents--;
  174. });
  175. loadingComponents++;
  176. }else{
  177. $(this).html(`<p>Unable to load components for this tab</p>`);
  178. }
  179. })
  180. if (callback != undefined){
  181. waitInit(callback);
  182. }
  183. }
  184. function waitInit(callback = undefined, retryCount = 0){
  185. if (loadingComponents > 0 && retryCount < 5){
  186. setTimeout(function(){
  187. waitInit(callback, retryCount++);
  188. }, 300);
  189. }else if (loadingComponents == 0){
  190. callback();
  191. }else{
  192. alert("Missing component. Please check if your installation is complete.")
  193. }
  194. }
  195. initTabs(function(){
  196. initRPStaste();
  197. if (window.location.hash.length > 1){
  198. let tabID = window.location.hash.substr(1);
  199. openTabById(tabID);
  200. }else{
  201. openTabById("status");
  202. }
  203. $(".ui.dropdown").dropdown();
  204. $(".ui.checkbox").checkbox();
  205. //Click on the current tab
  206. $("#mainmenu").find(".item").each(function(){
  207. $(this).on("click", function(event){
  208. let tabid = $(this).attr("tag");
  209. openTabById(tabid);
  210. });
  211. });
  212. //Initialize all table that is sortable
  213. $('table').tablesort();
  214. });
  215. function logout() {
  216. $.get("/api/auth/logout", function(response) {
  217. if (response === "OK") {
  218. window.location.href = "/";
  219. }
  220. });
  221. }
  222. function getTabButtonById(targetTabId){
  223. let targetTabBtn = undefined;
  224. $("#mainmenu").find(".item").each(function(){
  225. let tabid = $(this).attr("tag");
  226. if (tabid == targetTabId){
  227. targetTabBtn = $(this);
  228. }
  229. });
  230. return targetTabBtn;
  231. }
  232. //Select and open a tab by its tag id
  233. function openTabById(tabID){
  234. let targetBtn = getTabButtonById(tabID);
  235. if (targetBtn == undefined){
  236. alert("Invalid tabid given");
  237. return;
  238. }
  239. $("#mainmenu").find(".item").removeClass("active");
  240. $(targetBtn).addClass("active");
  241. $(".functiontab").hide();
  242. $("#" + tabID).fadeIn('fast');
  243. $('html,body').animate({scrollTop: 0}, 'fast');
  244. window.location.hash = tabID;
  245. }
  246. //Generic functions
  247. function deleteEndpoint(ptype, epoint){
  248. if (confirm("Confirm remove proxy for :" + epoint + " (type: " + ptype + ")?")){
  249. $.ajax({
  250. url: "./del",
  251. data: {ep: epoint, ptype: ptype},
  252. success: function(){
  253. listVdirs();
  254. listSubd();
  255. }
  256. })
  257. }
  258. }
  259. function setProxyRoot(){
  260. var newpr = $("#proxyRoot").val();
  261. if (newpr.trim() == ""){
  262. $("#proxyRoot").parent().addClass('error');
  263. return
  264. }else{
  265. $("#proxyRoot").parent().removeClass('error');
  266. }
  267. var rootReqTls = $("#rootReqTLS")[0].checked;
  268. //Create the endpoint by calling add
  269. $.ajax({
  270. url: "./add",
  271. data: {"type": "root", tls: rootReqTls, ep: newpr},
  272. success: function(data){
  273. if (data.error != undefined){
  274. alert(data.error);
  275. }else{
  276. //OK
  277. initRootInfo();
  278. $("#ProxyRootUpdate").stop().slideDown('fast').delay(3000).slideUp('fast');
  279. }
  280. }
  281. });
  282. }
  283. //Show error message
  284. function errmsg(message){
  285. $("#errmsg").html(`<i class="red remove icon"></i> ${message}`);
  286. $("#errmsg").slideDown('fast').delay(5000).slideUp('fast');
  287. }
  288. </script>
  289. </body>
  290. </html>