-
Notifications
You must be signed in to change notification settings - Fork 6
/
renderer.js
105 lines (86 loc) · 3 KB
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const electron = require('electron')
const ipc = electron.ipcRenderer
const startServerBtn = document.getElementById('start-server-btn')
const stopServerBtn = document.getElementById('stop-server-btn')
const startClientBtn = document.getElementById('start-client-btn')
const stopClientBtn = document.getElementById('stop-client-btn')
const connectInput = document.getElementById('connect')
const keyInput = document.getElementById('key')
const passphraseInput = document.getElementById('passphrase')
startServerBtn.disabled = false
stopServerBtn.disabled = true
startClientBtn.disabled = false
stopClientBtn.disabled = true
ipc.on('starting-server', function (event, message) {
startServerBtn.disabled = true
document.getElementById('server-info').innerHTML = message
})
ipc.on('started-server', function (event, message) {
document.getElementById('server-info').innerHTML = message
if (message.toLowerCase().startsWith('proxy tunnel')) {
stopServerBtn.disabled = false
} else {
startServerBtn.disabled = false
stopServerBtn.disabled = true
}
})
ipc.on('stopping-server', function (event, message) {
stopServerBtn.disabled = true
document.getElementById('server-info').innerHTML = message
})
ipc.on('stopped-server', function (event, message) {
document.getElementById('server-info').innerHTML = message
startServerBtn.disabled = false
})
ipc.on('starting-client', function (event, message) {
startClientBtn.disabled = true
document.getElementById('client-info').innerHTML = message
})
ipc.on('started-client', function (event, message) {
document.getElementById('client-info').innerHTML = message
if (! message.toLowerCase().startsWith('error')) {
stopClientBtn.disabled = false
} else {
startClientBtn.disabled = false
stopClientBtn.disabled = true
}
})
ipc.on('stopping-client', function (event, message) {
stopClientBtn.disabled = true
document.getElementById('client-info').innerHTML = message
})
ipc.on('stopped-client', function (event, message) {
document.getElementById('client-info').innerHTML = message
startClientBtn.disabled = false
})
ipc.on('connect-set', function (event, message) {
connectInput.value = message
ipc.send('connect-input', connectInput.value)
})
ipc.on('key-set', function (event, message) {
keyInput.value = message
ipc.send('key-input', keyInput.value)
ipc.send('start-client')
})
startServerBtn.addEventListener('click', function () {
ipc.send('start-server')
})
stopServerBtn.addEventListener('click', function () {
ipc.send('stop-server')
})
startClientBtn.addEventListener('click', function () {
ipc.send('start-client')
})
stopClientBtn.addEventListener('click', function () {
ipc.send('stop-client')
})
connectInput.addEventListener('change', function() {
ipc.send('connect-input', connectInput.value)
})
keyInput.addEventListener('change', function() {
ipc.send('key-input', keyInput.value)
})
passphraseInput.addEventListener('change', function() {
ipc.send('passphrase-input', passphraseInput.value)
})
ipc.send('start-server')