telnet tcp->udp, https->http

This commit is contained in:
2023-01-04 22:46:11 +02:00
parent b01b552834
commit 8f39f4e907
9 changed files with 74 additions and 93 deletions

View File

@@ -36,10 +36,10 @@ class Dial {
* decrypt socket traffic
*
*/
constructor(address, timeout, privateKey) {
constructor(address, timeout) {
this.address = address;
this.timeout = timeout;
this.privateKey = privateKey;
// this.privateKey = privateKey;
this.keepAliveTicker = null;
}
@@ -205,17 +205,17 @@ class Dial {
10 // max 10 buffered requests
);
let senderNonce = crypt.generateNonce();
sd.send(senderNonce);
// let senderNonce = crypt.generateNonce();
// sd.send(senderNonce);
let receiverNonce = await reader.readN(rd, crypt.GCMNonceSize);
// let receiverNonce = await reader.readN(rd, crypt.GCMNonceSize);
let key = await this.buildKey();
// let key = await this.buildKey();
sdDataConvert = async (rawData) => {
let encoded = await crypt.encryptGCM(key, senderNonce, rawData);
let encoded = rawData; // await crypt.encryptGCM(key, senderNonce, rawData);
crypt.increaseNonce(senderNonce);
// crypt.increaseNonce(senderNonce);
let dataToSend = new Uint8Array(encoded.byteLength + 2);
@@ -236,13 +236,13 @@ class Dial {
dSize <<= 8;
dSize |= dSizeBytes[1];
let decoded = await crypt.decryptGCM(
key,
receiverNonce,
await reader.readN(rd, dSize)
);
// let decoded = await crypt.decryptGCM(
// key,
// receiverNonce,
let decoded = await reader.readN(rd, dSize);
// );
crypt.increaseNonce(receiverNonce);
// crypt.increaseNonce(receiverNonce);
r.feed(
new reader.Buffer(new Uint8Array(decoded), () => {}),
@@ -276,7 +276,7 @@ export class Socket {
* @param {number} echoInterval Echo interval
*/
constructor(address, privateKey, timeout, echoInterval) {
this.dial = new Dial(address, timeout, privateKey);
this.dial = new Dial(address, timeout);
this.echoInterval = echoInterval;
this.streamHandler = null;
}