ssh_tunnel_proxy 1.1.2 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ the tunnel. A list of port forwards is provided to the connect_api function and
|
|
|
7
7
|
|
|
8
8
|
Example code for electron_js:
|
|
9
9
|
```js
|
|
10
|
+
|
|
11
|
+
// electronjs main.js
|
|
10
12
|
async function init_sshTunnelProxy(win) {
|
|
11
13
|
|
|
12
14
|
const SSHTunnelProxy = require('ssh_tunnel_proxy');
|
|
@@ -38,4 +40,46 @@ async function init_sshTunnelProxy(win) {
|
|
|
38
40
|
sshTunnelProxy.on('error',(...args) => win.webContents.send('error',...args));
|
|
39
41
|
|
|
40
42
|
};
|
|
43
|
+
|
|
44
|
+
// electronjs preload.js
|
|
45
|
+
const { contextBridge, ipcRenderer } = require('electron')
|
|
46
|
+
|
|
47
|
+
contextBridge.exposeInMainWorld('sshModule', {
|
|
48
|
+
connect_ssh_sync: opts => ipcRenderer.sendSync('connect_ssh_sync', opts),
|
|
49
|
+
generate_keypair: (...args) => ipcRenderer.sendSync("generate_keypair", ...args),
|
|
50
|
+
get_public_key: (...args) => ipcRenderer.sendSync("get_public_key", ...args),
|
|
51
|
+
network_online: (...args) => ipcRenderer.send("network_online", ...args),
|
|
52
|
+
network_offline: (...args) => ipcRenderer.send("network_offline", ...args),
|
|
53
|
+
ready: (callback) => ipcRenderer.on('ready', callback),
|
|
54
|
+
debug: (callback) => ipcRenderer.on('debug', callback),
|
|
55
|
+
error: (callback) => ipcRenderer.on('error', callback)
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// electronjs render process, setup listeners and initiate ssh tunnel
|
|
59
|
+
// initialize ssh message handlers
|
|
60
|
+
sshModule.ready((event, data) => {
|
|
61
|
+
});
|
|
62
|
+
sshModule.debug((event,msg)=>{
|
|
63
|
+
})
|
|
64
|
+
sshModule.error((event,err)=>{
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// options for connect_ssh_sync
|
|
68
|
+
var sshParams = {
|
|
69
|
+
"username": "<username>",
|
|
70
|
+
"password": "",
|
|
71
|
+
"host": "",
|
|
72
|
+
"port": "",
|
|
73
|
+
"proxy_ports": [
|
|
74
|
+
"8280:127.0.0.1:80",
|
|
75
|
+
"9000:127.0.0.1:9000",
|
|
76
|
+
"8122:192.168.2.1:22"
|
|
77
|
+
],
|
|
78
|
+
"service_name": "service",
|
|
79
|
+
"server_name": "server",
|
|
80
|
+
"ngrok_api": "<ngrok_api_key>"
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// initate ssh tunnel
|
|
84
|
+
sshModule.connect_ssh_sync(sshParams);
|
|
41
85
|
```
|