mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
sodium verify works
This commit is contained in:
@@ -2,6 +2,7 @@ import Websock from "./websock";
|
||||
import * as message from "./message.js";
|
||||
import * as rendezvous from "./rendezvous.js";
|
||||
import { loadVp9, loadOpus } from "./codec";
|
||||
import * as globals from "./globals";
|
||||
|
||||
const PORT = 21116;
|
||||
const HOST = "rs-sg.rustdesk.com";
|
||||
@@ -16,7 +17,7 @@ export default class Connection {
|
||||
|
||||
constructor() {
|
||||
this._msgs = [];
|
||||
this._id = "";
|
||||
this._id = '';
|
||||
this._interval = setInterval(() => {
|
||||
while (this._msgs.length) {
|
||||
this._ws?.sendMessage(this._msgs[0]);
|
||||
@@ -82,7 +83,10 @@ export default class Connection {
|
||||
}
|
||||
|
||||
async secure(pk: Uint8Array | undefined) {
|
||||
//
|
||||
if (pk) {
|
||||
const RS_PK = 'OeVuKk5nlHiXp+APNn0Y3pC1Iwpwn44JGqrQCsWqmBw=';
|
||||
let pk_id = await globals.verify(pk, RS_PK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,5 +109,5 @@ function getrUriFromRs(uri: string): string {
|
||||
} else {
|
||||
uri += ":" + (PORT + 3);
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
return SCHEMA + uri;
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import Connection from "./connection";
|
||||
import _sodium from "libsodium-wrappers";
|
||||
|
||||
window.currentConnection = undefined;
|
||||
|
||||
export function setConn(conn) {
|
||||
@@ -6,4 +9,22 @@ export function setConn(conn) {
|
||||
|
||||
export function getConn() {
|
||||
return windows.currentConnection;
|
||||
}
|
||||
}
|
||||
|
||||
export async function startConn(id) {
|
||||
const conn = new Connection();
|
||||
setConn(conn);
|
||||
await conn.start('124931507');
|
||||
}
|
||||
|
||||
let sodium;
|
||||
export async function verify(signed, pk) {
|
||||
if (!sodium) {
|
||||
await _sodium.ready;
|
||||
sodium = _sodium;
|
||||
}
|
||||
pk = sodium.from_base64(pk, sodium.base64_variants.ORIGINAL);
|
||||
return sodium.crypto_sign_open(signed, pk);
|
||||
}
|
||||
|
||||
window.startConn = startConn;
|
||||
@@ -1,7 +1,8 @@
|
||||
import "./style.css";
|
||||
import "./connection";
|
||||
import { startConn } from "./globals";
|
||||
|
||||
const app = document.querySelector("#app");
|
||||
const app = document.querySelector('#app');
|
||||
|
||||
if (app) {
|
||||
app.innerHTML = `
|
||||
@@ -36,6 +37,7 @@ if (app) {
|
||||
localStorage.setItem('key', key.value);
|
||||
document.querySelector('div#connect').style.display = 'none';
|
||||
document.querySelector('div#password').style.display = 'block';
|
||||
startConn(id);
|
||||
}
|
||||
|
||||
window.cancel = () => {
|
||||
|
||||
Reference in New Issue
Block a user