index.html 12 KB

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