Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3361744
D7691.id25969.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7691.id25969.diff
View Options
diff --git a/keyserver/package.json b/keyserver/package.json
--- a/keyserver/package.json
+++ b/keyserver/package.json
@@ -82,7 +82,8 @@
"twin-bcrypt": "^2.1.1",
"uuid": "^3.3.3",
"web": "0.0.1",
- "web-push": "^3.5.0"
+ "web-push": "^3.5.0",
+ "ws": "^8.13.0"
},
"optionalDependencies": {
"bufferutil": "^4.0.5",
diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js
--- a/keyserver/src/keyserver.js
+++ b/keyserver/src/keyserver.js
@@ -25,6 +25,7 @@
} from './responders/website-responders.js';
import { webWorkerResponder } from './responders/webworker-responders.js';
import { onConnection } from './socket/socket.js';
+import { createTunnelbrokerWebsocket } from './socket/tunnelbroker.js';
import {
multerProcessor,
multimediaUploadResponder,
@@ -63,6 +64,7 @@
cluster.fork();
}
cluster.on('exit', () => cluster.fork());
+ createTunnelbrokerWebsocket();
} else {
const server = express();
expressWs(server);
diff --git a/keyserver/src/socket/tunnelbroker.js b/keyserver/src/socket/tunnelbroker.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/socket/tunnelbroker.js
@@ -0,0 +1,38 @@
+// @flow
+import WebSocket from 'ws';
+
+function createTunnelbrokerWebsocket() {
+ try {
+ const tunnelbrokerSocket = new WebSocket('ws://localhost:51001');
+ tunnelbrokerSocket.on('open', () => {
+ // TODO: Replace keyserver details with actual details
+ const message: SessionRequestMessage = {
+ type: 'sessionRequest',
+ accessToken: 'foobar',
+ deviceId: 'foo',
+ deviceType: 'keyserver',
+ };
+ console.log(
+ 'Sending message to tunnelbroker: ' + JSON.stringify(message),
+ );
+ tunnelbrokerSocket.send(JSON.stringify(message));
+ });
+
+ tunnelbrokerSocket.on('message', message => {
+ // TODO: Handle RefreshKeyMessage
+ console.log('Received message from tunnelbroker: {}' + message);
+ });
+
+ tunnelbrokerSocket.on('close', () => {
+ console.log('Connection to tunnelbroker closed');
+ });
+
+ tunnelbrokerSocket.on('error', event => {
+ console.log('Tunnelbroker socket error: ' + event.message);
+ });
+ } catch (err) {
+ console.log('Failed to open connection with tunnelbroker');
+ }
+}
+
+export { createTunnelbrokerWebsocket };
diff --git a/yarn.lock b/yarn.lock
--- a/yarn.lock
+++ b/yarn.lock
@@ -24027,6 +24027,11 @@
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591"
integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==
+ws@^8.13.0:
+ version "8.13.0"
+ resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0"
+ integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==
+
ws@^8.4.2:
version "8.12.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.12.0.tgz#485074cc392689da78e1828a9ff23585e06cddd8"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 7:07 PM (20 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2580761
Default Alt Text
D7691.id25969.diff (2 KB)
Attached To
Mode
D7691: [Keyserver] Open websocket connection with tunnelbroker
Attached
Detach File
Event Timeline
Log In to Comment