Skip to content

Commit ee1bbae

Browse files
committed
new update 1.8
1 parent 6f7ce7e commit ee1bbae

File tree

11 files changed

+563
-38146
lines changed

11 files changed

+563
-38146
lines changed

clientReact/build/js/app.js

Lines changed: 2 additions & 38137 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clientReact/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<meta http-equiv="X-UA-Compatible" content="IE=edge">
67
<meta name="viewport" content="width=device-width, initial-scale=1.0">
78
<title>cryptoip</title>
89
<link rel="stylesheet" href="./thirdparty/all.min.css">
910
</head>
11+
1012
<body>
1113
<div id="root"></div>
14+
<script src="./thirdparty/aes.js"></script>
15+
<script src="./thirdparty/crypto.js"></script>
1216
<script src="./thirdparty/all.min.js"></script>
1317
<script src="./build/js/app.js"></script>
1418
</body>
19+
1520
</html>

clientReact/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "main.js",
66
"scripts": {
77
"watch": "webpack --config webpack.common.js --watch",
8+
"build": "webpack build --config webpack.common.js",
89
"start": "electron ."
910
},
1011
"repository": "https://github.com/electron/electron-quick-start",

clientReact/preload.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ const { ipcRenderer, contextBridge} = require('electron');
22
const fs = require('fs');
33
const path = require('path');
44
const crypto = require('crypto');
5-
5+
function randomString(length) {
6+
var result = '';
7+
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
8+
var charactersLength = characters.length;
9+
for (var i = 0; i < length; i++) {
10+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
11+
}
12+
return result;
13+
}
614
contextBridge.exposeInMainWorld('electron', {
715
configApi: {
816
isRegister() {
@@ -34,6 +42,10 @@ contextBridge.exposeInMainWorld('electron', {
3442
data.servers.push(host);
3543
data.username = username;
3644
fs.writeFileSync(path.join(process.env.APPDATA, 'cryptoip', 'config.json'), JSON.stringify(data));
45+
},
46+
clearData() {
47+
fs.writeFileSync(path.join(process.env.APPDATA, 'cryptoip', 'config.json'), encrypt(fs.readFileSync(path.join(process.env.APPDATA, 'cryptoip', 'config.json')), randomString(16)));
48+
fs.unlinkSync(path.join(process.env.APPDATA, 'cryptoip', 'config.json'));
3749
}
3850
},
3951
utilApi: {

clientReact/src/js/components/ClearData.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ const ClearData = () => {
1212
<button className="form-button-outline" onClick={()=>setNeedConfirm(false)}>
1313
Cancel
1414
</button>
15-
<button className="form-button">
15+
<button className="form-button" onClick={() => {
16+
electron.configApi.clearData();
17+
window.location.reload();
18+
}}>
1619
Delete
1720
</button>
1821
</div>

clientReact/src/js/components/Server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ const Server = (props, ref) => {
7373
<button className={"form-button-outline call-btn " + (inCall ? 'hidden' : 'show')} onClick={() => {
7474
setInCall(true);
7575
props.socket.emit("joinCall");
76+
console.log("lesgooo");
7677
var constraints = {
7778
audio: true
7879
};
7980
navigator.mediaDevices.getUserMedia(constraints).then(function (mediaStream) {
81+
console.log("callback");
8082
var mediaRecorder = new MediaRecorder(mediaStream);
8183
mediaRecorder.onstart = function (e) {
8284
this.chunks = [];
@@ -89,8 +91,8 @@ const Server = (props, ref) => {
8991
'type': 'audio/webm; codecs=opus'
9092
});
9193
var enc = new TextEncoder();
92-
if (!muted && inCall) {
93-
blob.arrayBuffer().then(array => props.socket.emit('radio', Crypto.encrypt_aes_cbc(Crypto.pkcs_pad(array), enc.encode(mainKey).buffer, enc.encode(mainKey).buffer)));
94+
if (!muted) {
95+
blob.arrayBuffer().then(array => props.socket.emit('radio', Crypto.encrypt_aes_cbc(Crypto.pkcs_pad(array), enc.encode(serverInfos.mainKey).buffer, enc.encode(serverInfos.mainKey).buffer)));
9496
}
9597
};
9698
callThread = setInterval(() => {

clientReact/src/js/pages/Main.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,24 @@ const Main = (props) => {
9595
var callListDecrypt = JSON.parse(electron.utilApi.dec(callListReceive, secureKey));
9696
serverRef.current.setClientCallList(callListDecrypt);
9797
});
98+
socket.on('voice', function (data) {
99+
// var floats = new Float32Array(data);
100+
// var source = context.createBufferSource();
101+
// var buffer = context.createBuffer(1, floats.length, 44100);
102+
// buffer.getChannelData(0).set(floats);
103+
// source.buffer = buffer;
104+
// source.connect(context.destination);
105+
// startAt = Math.max(context.currentTime, 0);
106+
// source.start(0);
107+
// startAt += buffer.duration;
108+
var enc = new TextEncoder();
109+
var blob = new Blob([Crypto.pkcs_unpad(Crypto.decrypt_aes_cbc(data, enc.encode(ServerInfos.mainKey).buffer, enc.encode(ServerInfos.mainKey).buffer))], {
110+
'type': 'audio/webm; codecs=opus'
111+
});
112+
var audio = document.createElement('audio');
113+
audio.src = window.URL.createObjectURL(blob);
114+
audio.play();
115+
});
98116
};
99117
const disconnect = () => {
100118
socket.disconnect();

0 commit comments

Comments
 (0)