1
0

index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. <a class="item" tag="upnp">
  108. <i class="blue exchange icon"></i> Port Forward
  109. </a>
  110. <div class="ui divider menudivider">Bridging</div>
  111. <a class="item" tag="">
  112. <i class="remove icon"></i> TCP Proxy
  113. </a>
  114. <a class="item" tag="">
  115. <i class="remove icon"></i> HTTP over Websocket
  116. </a>
  117. <a class="item" tag="">
  118. <i class="remove icon"></i> UDP Hole Punching
  119. </a>
  120. <div class="ui divider menudivider">Others</div>
  121. <a class="item" tag="">
  122. <i class="remove icon"></i> Uptime Monitor
  123. </a>
  124. <a class="item" tag="">
  125. <i class="remove icon"></i> Network Tools
  126. </a>
  127. <a class="item" tag="utils">
  128. <i class="grey paperclip icon"></i> Utilities
  129. </a>
  130. <!-- Add more components here -->
  131. </div>
  132. </div>
  133. <div class="contentWindow">
  134. <!-- Status Tab -->
  135. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  136. <br><br><div class="ui active centered inline loader"></div>
  137. </div>
  138. <!-- Virtual Directory Tab -->
  139. <div id="vdir" class="functiontab" target="vdir.html"></div>
  140. <!-- Subdomain Proxy -->
  141. <div id="subd" class="functiontab" target="subd.html"></div>
  142. <!-- Create Rules -->
  143. <div id="rules" class="functiontab" target="rules.html"></div>
  144. <!-- Set proxy root -->
  145. <div id="setroot" class="functiontab" target="rproot.html"></div>
  146. <!-- Set TLS cert -->
  147. <div id="cert" class="functiontab" target="cert.html"></div>
  148. <!-- Redirections -->
  149. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  150. <!-- Blacklist -->
  151. <div id="blacklist" class="functiontab" target="blacklist.html"></div>
  152. <!-- UPnP based port fowarding -->
  153. <div id="upnp" class="functiontab" target="upnp.html"></div>
  154. <!-- Utilities -->
  155. <div id="utils" class="functiontab" target="utils.html"></div>
  156. </div>
  157. </div>
  158. </div>
  159. <br><br>
  160. <div class="ui divider"></div>
  161. <div class="ui container" style="color: grey; font-size: 90%">
  162. <p>CopyRight Zoraxy project and its author, 2022 - <span class="year"></span></p>
  163. </div>
  164. <br><br>
  165. <script>
  166. $(".year").text(new Date().getFullYear());
  167. /*
  168. Loader function
  169. Load all the components view from the
  170. components/ directory into their corrisponding divs
  171. */
  172. let loadingComponents = 0;
  173. function initTabs(callback=undefined){
  174. $('.functiontab').each(function(){
  175. let loadTarget = $(this).attr("target");
  176. if (loadTarget != undefined){
  177. $(this).load("./components/" + loadTarget, function(){
  178. loadingComponents--;
  179. });
  180. loadingComponents++;
  181. }else{
  182. $(this).html(`<p>Unable to load components for this tab</p>`);
  183. }
  184. })
  185. if (callback != undefined){
  186. waitInit(callback);
  187. }
  188. }
  189. function waitInit(callback = undefined, retryCount = 0){
  190. if (loadingComponents > 0 && retryCount < 5){
  191. setTimeout(function(){
  192. waitInit(callback, retryCount++);
  193. }, 300);
  194. }else if (loadingComponents == 0){
  195. callback();
  196. }else{
  197. alert("Missing component. Please check if your installation is complete.")
  198. }
  199. }
  200. initTabs(function(){
  201. initRPStaste();
  202. if (window.location.hash.length > 1){
  203. let tabID = window.location.hash.substr(1);
  204. openTabById(tabID);
  205. }else{
  206. openTabById("status");
  207. }
  208. $(".ui.dropdown").dropdown();
  209. $(".ui.checkbox").checkbox();
  210. //Click on the current tab
  211. $("#mainmenu").find(".item").each(function(){
  212. $(this).on("click", function(event){
  213. let tabid = $(this).attr("tag");
  214. openTabById(tabid);
  215. });
  216. });
  217. //Initialize all table that is sortable
  218. $('table').tablesort();
  219. });
  220. function logout() {
  221. $.get("/api/auth/logout", function(response) {
  222. if (response === "OK") {
  223. window.location.href = "/";
  224. }
  225. });
  226. }
  227. function getTabButtonById(targetTabId){
  228. let targetTabBtn = undefined;
  229. $("#mainmenu").find(".item").each(function(){
  230. let tabid = $(this).attr("tag");
  231. if (tabid == targetTabId){
  232. targetTabBtn = $(this);
  233. }
  234. });
  235. return targetTabBtn;
  236. }
  237. //Select and open a tab by its tag id
  238. function openTabById(tabID){
  239. let targetBtn = getTabButtonById(tabID);
  240. if (targetBtn == undefined){
  241. alert("Invalid tabid given");
  242. return;
  243. }
  244. $("#mainmenu").find(".item").removeClass("active");
  245. $(targetBtn).addClass("active");
  246. $(".functiontab").hide();
  247. $("#" + tabID).fadeIn('fast');
  248. $('html,body').animate({scrollTop: 0}, 'fast');
  249. window.location.hash = tabID;
  250. }
  251. //Generic functions
  252. function deleteEndpoint(ptype, epoint){
  253. if (confirm("Confirm remove proxy for :" + epoint + " (type: " + ptype + ")?")){
  254. $.ajax({
  255. url: "./del",
  256. data: {ep: epoint, ptype: ptype},
  257. success: function(){
  258. listVdirs();
  259. listSubd();
  260. }
  261. })
  262. }
  263. }
  264. function setProxyRoot(){
  265. var newpr = $("#proxyRoot").val();
  266. if (newpr.trim() == ""){
  267. $("#proxyRoot").parent().addClass('error');
  268. return
  269. }else{
  270. $("#proxyRoot").parent().removeClass('error');
  271. }
  272. var rootReqTls = $("#rootReqTLS")[0].checked;
  273. //Create the endpoint by calling add
  274. $.ajax({
  275. url: "./add",
  276. data: {"type": "root", tls: rootReqTls, ep: newpr},
  277. success: function(data){
  278. if (data.error != undefined){
  279. alert(data.error);
  280. }else{
  281. //OK
  282. initRootInfo();
  283. $("#ProxyRootUpdate").stop().slideDown('fast').delay(3000).slideUp('fast');
  284. }
  285. }
  286. });
  287. }
  288. //Show error message
  289. function errmsg(message){
  290. $("#errmsg").html(`<i class="red remove icon"></i> ${message}`);
  291. $("#errmsg").slideDown('fast').delay(5000).slideUp('fast');
  292. }
  293. </script>
  294. </body>
  295. </html>