|
@@ -0,0 +1,96 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html>
|
|
|
+ <head>
|
|
|
+ <meta name="apple-mobile-web-app-capable" content="yes" />
|
|
|
+ <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="theme-color" content="#4b75ff">
|
|
|
+ <link rel="icon" type="image/png" href="./favicon.png" />
|
|
|
+ <title>Web SSH | Zoraxy</title>
|
|
|
+ <link rel="stylesheet" href="../script/semantic/semantic.min.css">
|
|
|
+ <script src="../script/jquery-3.6.0.min.js"></script>
|
|
|
+ <script src="../../script/ao_module.js"></script>
|
|
|
+ <script src="../script/semantic/semantic.min.js"></script>
|
|
|
+ <script src="../script/tablesort.js"></script>
|
|
|
+ <link rel="stylesheet" href="../main.css">
|
|
|
+ <style>
|
|
|
+ </style>
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <br>
|
|
|
+ <div class="ui container">
|
|
|
+ <div class="ui form">
|
|
|
+ <div class="two fields">
|
|
|
+ <div class="field">
|
|
|
+ <label>Server Name or IP Address</label>
|
|
|
+ <input type="text" name="server" placeholder="e.g. example.com or 192.168.1.1">
|
|
|
+ </div>
|
|
|
+ <div class="field">
|
|
|
+ <label>Port Number</label>
|
|
|
+ <input type="number" name="port" placeholder="e.g. 22 or 2022">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div style="float: right;">
|
|
|
+ <button class="ui basic button" onclick="connectSSH()"><i class="ui blue exchange icon"></i> Connect</button>
|
|
|
+ <button class="ui basic button" style="margin-right: 1em;" onclick="window.open('', '_self', ''); window.close();"><i class="ui red remove icon"></i> Close</button>
|
|
|
+ </div>
|
|
|
+ <br><br><br>
|
|
|
+ <script>
|
|
|
+
|
|
|
+ //Start the SSH connection process
|
|
|
+ function connectSSH() {
|
|
|
+ const serverValue = $('input[name="server"]').val().trim();
|
|
|
+ const portValue = parseInt($('input[name="port"]').val().trim(), 10);
|
|
|
+
|
|
|
+ // Validate server name or IP address
|
|
|
+ const validServer = isValidServerNameOrIPAddress(serverValue);
|
|
|
+
|
|
|
+ // Validate port number
|
|
|
+ const validPort = (portValue >= 1 && portValue <= 65535);
|
|
|
+
|
|
|
+ if (validServer && validPort) {
|
|
|
+ // Call doSomething function if both inputs are valid
|
|
|
+ createSSHProxy(serverValue, portValue);
|
|
|
+ } else {
|
|
|
+ // Display an error message if either input is invalid
|
|
|
+ const errorLabel = $('<div>').addClass('ui red basic label');
|
|
|
+ if (!validServer) {
|
|
|
+ errorLabel.text('Invalid server name or IP address');
|
|
|
+ $('input[name="server"]').addClass('error');
|
|
|
+ } else if (!validPort) {
|
|
|
+ errorLabel.text('Invalid port number');
|
|
|
+ $('input[name="port"]').addClass('error');
|
|
|
+ }
|
|
|
+ const field = $('input[name="server"]').closest('.field');
|
|
|
+ field.append(errorLabel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //Try to ask the server side to create a ssh proxy object
|
|
|
+ function createSSHProxy(){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function isValidServerNameOrIPAddress(str) {
|
|
|
+ // First, check if the string is a valid IP address
|
|
|
+ const ipAddressRegex = /^(\d{1,3}\.){3}\d{1,3}$/;
|
|
|
+ if (ipAddressRegex.test(str)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // If the string is not an IP address, check if it is a valid domain name or server name
|
|
|
+ const serverNameRegex = /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z]{2,})+$/;
|
|
|
+ if (serverNameRegex.test(str)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // If the string is neither an IP address nor a server name, return false
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+ </body>
|
|
|
+</html>
|