Sorted the scripts, made profiles
This commit is contained in:
parent
2a326d477f
commit
cde5914101
29
index.html
29
index.html
|
@ -3,15 +3,28 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Connect</title>
|
<title>Connect</title>
|
||||||
<script src="index.js"></script>
|
<script src="scripts/include.js"></script>
|
||||||
<script src="scripts.js"></script>
|
<script src="scripts/profiles.js"></script>
|
||||||
|
<script src="scripts/communications.js"></script>
|
||||||
|
<script src="scripts/scripts.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>Direct Connect:</p>
|
<div class="chat-menu">
|
||||||
<p>
|
<ul id="chat-menu">
|
||||||
<input type="text" id="hostname"><br/>
|
|
||||||
<input type="text" id="port" value="22068"></br>
|
</ul>
|
||||||
<button onclick="connect_direct()">
|
</div>
|
||||||
</p>
|
<div class="new-profile">
|
||||||
|
<p>New Profile:</p>
|
||||||
|
<p>
|
||||||
|
<table>
|
||||||
|
<tr><td>Hostname</td><td><input type="text" id="edit_profile_hostname"></td></tr>
|
||||||
|
<tr><td>Port</td><td><input type="text" id="edit_profile_port" value="22068"></td></tr>
|
||||||
|
<tr><td>Username</td><td><input type="text", id="edit_profile_username"></td></tr>
|
||||||
|
<tr><td>Password</td><td><input type="password" id="edit_profile_password"></td></tr>
|
||||||
|
</table>
|
||||||
|
<button onclick="profile_save()">Save Profile</button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
51
key
51
key
|
@ -1,51 +0,0 @@
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIJJwIBAAKCAgEAjj0aDW3uJI8tivbJEk2q0EAWnkwmR3k91P61WFhFtA5j6rl+
|
|
||||||
DqF5Fr1AhjutkZT+xeno0n3Mm+/XqTTABKfcYpMmmGCHMvIc3AkFb0deXXHBqLeS
|
|
||||||
Soid+MsmMp/68/jvtvWGQzJK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LbuZSbwtVpSQeWQjCpBOeC8FORj
|
|
||||||
STwlMf9CfQ6bGp+0UkN8Tj4y/UoqrwO5T+uXHB7OmEivpfMFEimA95F4kyxykEzv
|
|
||||||
NM1DLa++EDIeuiP0MF+yphjW8qJ0F9KuZaS0MYnsTPvV08/IvPrtGt2U2g==
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
14
key.pub
14
key.pub
|
@ -1,14 +0,0 @@
|
||||||
-----BEGIN PUBLIC KEY-----
|
|
||||||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjj0aDW3uJI8tivbJEk2q
|
|
||||||
0EAWnkwmR3k91P61WFhFtA5j6rl+DqF5Fr1AhjutkZT+xeno0n3Mm+/XqTTABKfc
|
|
||||||
YpMmmGCHMvIc3AkFb0deXXHBqLeSSoid+MsmMp/68/jvtvWGQzJKEPURHndcupTX
|
|
||||||
FJmclYpHrHOLjndX01ofLaUg2fT+3Pu81gVJBE53xT97KQQvHN+xpGJYPTts0A3b
|
|
||||||
lrWyJ44WQha/jWQN84hRJuDe1SA2bTPx4UIyAmfY7RG3j2nLJgzZUTI2Z35mKhfg
|
|
||||||
vdYazTpYld9bm9CfLljCr4lKR50AZo4qZuIgD5+qYq1PUpsqQX04KcTOUiDHRFlD
|
|
||||||
06Wn9l7eeFZNwbDp7e397vueDdVBwe0sujuefwDyVon43DaO8ljEz+H0iq9L+0Mw
|
|
||||||
x8UshuQtWUAvgFqctJoITWNUEe78ib/3KXO4CurXcuOqfW+KA1TQQi3KKnP9cuTg
|
|
||||||
ajoxv4LPrBR6CtFzN/1TjzEjwdSXsecZ5Kz9SJVf1ZDDKl4CnGMFug1V9UGpbV4g
|
|
||||||
APGcZBvhVM1lWFC25T6YfviO/e1nPKTaLgFNsyzAFbX508Ta/9K5V8xw9JDfpoEb
|
|
||||||
HuFPFqsKTVV9pva8A1djfhMRTFCujQVpYTDp8tdmKoE0crAeJU+1EwlCZSSlz1Kh
|
|
||||||
CqBh5wLmGQNLbxSInu8oPYcCAwEAAQ==
|
|
||||||
-----END PUBLIC KEY-----
|
|
|
@ -1,12 +1,4 @@
|
||||||
|
|
||||||
// Get some libraries
|
|
||||||
const fs = require("fs");
|
|
||||||
const net = require("net");
|
|
||||||
const path = require("path");
|
|
||||||
const node_rsa = require("node-rsa");
|
|
||||||
const bsplit = require("buffer-split");
|
|
||||||
const child_process = require('child_process');
|
|
||||||
|
|
||||||
// Load the settings
|
// Load the settings
|
||||||
var settings = require("./settings.json");
|
var settings = require("./settings.json");
|
||||||
|
|
||||||
|
@ -225,8 +217,12 @@ function socket_write(socket, encryption, data)
|
||||||
socket.write(data);
|
socket.write(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect(hostname, port=22068)
|
function connect(profile, connection_id)
|
||||||
{
|
{
|
||||||
|
// Setup the port and hostname varibles
|
||||||
|
var port = profile.port;
|
||||||
|
var hostname = profile.hostname;
|
||||||
|
|
||||||
// Make an accessible global object
|
// Make an accessible global object
|
||||||
var g = new Object();
|
var g = new Object();
|
||||||
|
|
||||||
|
@ -239,8 +235,6 @@ function connect(hostname, port=22068)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
g.rsa_task.unref();
|
|
||||||
|
|
||||||
g.rsa_task.stdout.on('data', function(data)
|
g.rsa_task.stdout.on('data', function(data)
|
||||||
{
|
{
|
||||||
//console.log("child stdout:", data.toString());
|
//console.log("child stdout:", data.toString());
|
||||||
|
@ -339,8 +333,8 @@ function connect(hostname, port=22068)
|
||||||
|
|
||||||
client.on('close', function(data)
|
client.on('close', function(data)
|
||||||
{
|
{
|
||||||
// Close the window
|
// Close the connection
|
||||||
//window.close();
|
delete connections[connection_id];
|
||||||
});
|
});
|
||||||
|
|
||||||
g.rsa_task.on('message', function(message)
|
g.rsa_task.on('message', function(message)
|
||||||
|
@ -380,22 +374,14 @@ function connect(hostname, port=22068)
|
||||||
// Send status
|
// Send status
|
||||||
socket_write(client, g.encryption, 1);
|
socket_write(client, g.encryption, 1);
|
||||||
|
|
||||||
socket_write(client, g.encryption, {
|
console.log("Trying to get login data");
|
||||||
mode: "Hello",
|
|
||||||
text: "This is from the client!",
|
|
||||||
array: [
|
|
||||||
[1, 2, 3],
|
|
||||||
{4: 5, 6: "7"},
|
|
||||||
"8",
|
|
||||||
9,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log("Done.");
|
// Create a variable
|
||||||
|
var userdata_filename = "servers/"+hostname+":"+port.toString()+".json";
|
||||||
|
console.log(userdata_filename);
|
||||||
|
|
||||||
// Perform initialise operations here
|
// Try and get the users login data
|
||||||
|
//var userdata = readFile()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
// Get some libraries
|
||||||
|
const fs = require("fs");
|
||||||
|
const net = require("net");
|
||||||
|
const path = require("path");
|
||||||
|
const node_rsa = require("node-rsa");
|
||||||
|
const bsplit = require("buffer-split");
|
||||||
|
const child_process = require('child_process');
|
||||||
|
|
||||||
|
const PORT_DEFAULT = 22068;
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,108 @@
|
||||||
|
|
||||||
|
// Create a profiles varible
|
||||||
|
var profiles;
|
||||||
|
|
||||||
|
// Create a connections varible
|
||||||
|
var connections = [];
|
||||||
|
|
||||||
|
// Load the profiles
|
||||||
|
fs.readFile("profiles.json", "utf-8", function(err, data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Throw an error if there is one
|
||||||
|
if(err) throw err;
|
||||||
|
|
||||||
|
// Try to load it from the data
|
||||||
|
profiles = JSON.parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
// Set the profiles varible to its default value
|
||||||
|
profiles = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reload the profiles
|
||||||
|
profiles_reload();
|
||||||
|
|
||||||
|
// Connect to all the profiles
|
||||||
|
for(var i=0;i<profiles.length;i++)
|
||||||
|
{
|
||||||
|
// Connect to the server
|
||||||
|
profile_connect(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function profile_save()
|
||||||
|
{
|
||||||
|
// Get the values from the form
|
||||||
|
var hostname = document.getElementById("edit_profile_hostname").value;
|
||||||
|
var port = document.getElementById("edit_profile_port").value;
|
||||||
|
var username = document.getElementById("edit_profile_username").value;
|
||||||
|
var password = document.getElementById("edit_profile_password").value;
|
||||||
|
|
||||||
|
// Push the profiles data
|
||||||
|
profiles.push({
|
||||||
|
hostname: hostname,
|
||||||
|
port: port,
|
||||||
|
username: username,
|
||||||
|
password: password
|
||||||
|
});
|
||||||
|
|
||||||
|
// Write the data to the profiles file
|
||||||
|
fs.writeFileSync("profiles.json", JSON.stringify(profiles));
|
||||||
|
|
||||||
|
// Reload the profiles
|
||||||
|
profiles_reload();
|
||||||
|
|
||||||
|
// Start a connection
|
||||||
|
profile_connect(profiles.length-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function profile_connect(id)
|
||||||
|
{
|
||||||
|
// Connect to the server
|
||||||
|
var server = connect(profiles[id], connections.length);
|
||||||
|
|
||||||
|
// Add the server to the active connections
|
||||||
|
connections.push(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
function profile_switch_to(id)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function profiles_reload()
|
||||||
|
{
|
||||||
|
// Get the chat menu id
|
||||||
|
var chat_menu = document.getElementById("chat-menu");
|
||||||
|
|
||||||
|
// Reset it
|
||||||
|
chat_menu.innerHTML = "";
|
||||||
|
|
||||||
|
// Loop over the profiles
|
||||||
|
for(var i=0;i<profiles.length;i++)
|
||||||
|
{
|
||||||
|
// Create a list item
|
||||||
|
var profile = document.createElement("li");
|
||||||
|
|
||||||
|
// Should the port be displayed
|
||||||
|
var port_display = "";
|
||||||
|
|
||||||
|
// Is the port not the default port
|
||||||
|
if(profiles[i].port != PORT_DEFAULT)
|
||||||
|
{
|
||||||
|
// Set the port display varible
|
||||||
|
port_display = ":"+profiles[i].port.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the html for the list item
|
||||||
|
profile.innerHTML = "<a href='javascript:void(0)' onclick='profile_connect("+
|
||||||
|
i+")'>"+profiles[i].username+"@"+profiles[i].hostname+port_display+"</a>";
|
||||||
|
|
||||||
|
// Add the profile to the menu
|
||||||
|
chat_menu.appendChild(profile);
|
||||||
|
}
|
||||||
|
}
|
47
tasks.js
47
tasks.js
|
@ -1,47 +0,0 @@
|
||||||
|
|
||||||
// Include some libraries
|
|
||||||
const node_rsa = require("node-rsa");
|
|
||||||
|
|
||||||
module.exports = function(args, callback)
|
|
||||||
{
|
|
||||||
// Does the main task want an rsa key
|
|
||||||
if(args["mode"] == "make_rsa_key")
|
|
||||||
{
|
|
||||||
// Make an rsa key with the specified size
|
|
||||||
var key = new node_rsa({b:args['size']});
|
|
||||||
|
|
||||||
// Get the public and private keys
|
|
||||||
var data = {
|
|
||||||
public: key.exportKey("public"),
|
|
||||||
private: key.exportKey("private")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send it back to the main task
|
|
||||||
callback(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Does the main task want to decode something
|
|
||||||
else if(args["mode"] == "decrypt_rsa")
|
|
||||||
{
|
|
||||||
// Load the key
|
|
||||||
var key = new node_rsa();
|
|
||||||
key.importKey(args["public"], "public");
|
|
||||||
key.importKey(args["private"], "private");
|
|
||||||
|
|
||||||
// Decode the data
|
|
||||||
var data = key.decrypt(args["string"]);
|
|
||||||
|
|
||||||
// Send it back to the main task
|
|
||||||
callback({
|
|
||||||
out: data.toString(),
|
|
||||||
public: key.exportKey("public"),
|
|
||||||
private: key.exportKey("private")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Call back nothing
|
|
||||||
callback(undefined);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue