Skip to content

Commit 53d8b64

Browse files
committed
Addition of untrusted-HTTPs echo servers
1 parent a72648d commit 53d8b64

File tree

7 files changed

+1720
-92
lines changed

7 files changed

+1720
-92
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/driver_files/src" PREFIX "Source
4444
set_property(TARGET "${websocket_trackers_PROJECT}" PROPERTY CXX_STANDARD 17)
4545

4646
# OpenSSL support (uncomment below)
47-
# target_link_directories("${websocket_trackers_PROJECT}" PUBLIC "C:/Program Files/OpenSSL-Win64/lib")
48-
# target_include_directories("${websocket_trackers_PROJECT}" PUBLIC "C:/Program Files/OpenSSL-Win64/include")
49-
# find_package(OpenSSL REQUIRED)
50-
# target_link_libraries("${websocket_trackers_PROJECT}" PUBLIC OpenSSL::SSL)
47+
target_link_directories("${websocket_trackers_PROJECT}" PUBLIC "C:/Program Files/OpenSSL-Win64/lib")
48+
target_include_directories("${websocket_trackers_PROJECT}" PUBLIC "C:/Program Files/OpenSSL-Win64/include")
49+
find_package(OpenSSL REQUIRED)
50+
target_link_libraries("${websocket_trackers_PROJECT}" PUBLIC OpenSSL::SSL)
5151

5252

5353
# Copy driver assets to output folder

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ It also echoes back the position of all currently active VR devices, allowing yo
44

55
This is desirable as it allows simple applications (such as web based applications) to interface with SteamVR without the hassle of setting up their own driver.
66

7-
Finally, the driver also has the ability to host a simple webserver, which serves the files in `/resources/webserver` on port 8088.
7+
The driver also hosts a simple webserver, which serves the files in `/resources/webserver` on port 8088.
88
This can be accessed from: [http://localhost:8088](http://localhost:8088), which serves `/resources/webserver/index.html`.
99

10+
11+
The driver also hosts 3 additional pseudo-https (non-trusted certificate) webservers, which serves the files in `/resources/webserver` on port 8089/8090/8091. By sending requests to these in binary (8090 = 0, 8091 = 1, 8089 = end) you can remotely store data in the echo value on the websocket. An example of this is included in `send-echo-ssl.js`.
12+
1013
This is built upon the work of [terminal29's](https://github.com/terminal29) ["Simple-OpenVR-Driver-Tutorial"](https://github.com/terminal29/Simple-OpenVR-Driver-Tutorial), the license for which is found at the bottom of this document.
1114

1215
---
@@ -95,9 +98,8 @@ socket.addEventListener('message', function (event) {
9598

9699
# Building
97100
To build the project do the following (tested with CMake 3.20.1 and Visual Studio 2019):
98-
- Download OpenSSL from here
99-
- `https://slproweb.com/products/Win32OpenSSL.html`
100-
Tested with `Win64 OpenSSL v3.0.1`.
101+
- Download OpenSSL from here `https://slproweb.com/products/Win32OpenSSL.html`
102+
Tested with `Win64 OpenSSL v3.0.1`. Install into the default location (`C:\Program Files\OpenSSL-Win64`).
101103
- Clone the project and submodules
102104
- `git clone --recursive https://github.com/John-Dean/OpenVR-Tracker-Websocket-Driver.git`
103105
- Build project with CMake
@@ -111,7 +113,7 @@ To build the project do the following (tested with CMake 3.20.1 and Visual Studi
111113
## Websocket OpenVR Driver license
112114
MIT License
113115

114-
Copyright (c) 2022 John Dean
116+
Copyright (c) 2021-2022 John Dean
115117

116118
Permission is hereby granted, free of charge, to any person obtaining a copy
117119
of this software and associated documentation files (the "Software"), to deal
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIC4TCCAcmgAwIBAgIUJo9oNcxAICfszEWp3dBSIKxYkIYwDQYJKoZIhvcNAQEL
3+
BQAwADAeFw0yMjAxMjkxNjUxMTZaFw00OTA2MTYxNjUxMTZaMAAwggEiMA0GCSqG
4+
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsLcw9Tjpn9AwPCHM3B5n8/R8RPauwO2sd
5+
2te481Yw+wkfeLeDUICYjXs1uI21dyQ8pJtRbrk2Yz2ix/amyEGGEGaGiW4rQjxg
6+
mCczTFdsp0eMV0Vqk5mcSZfT9iNg2IS3+K9K+89+K27PNp/eWOFWW3b7/s1DNELq
7+
R7uGtTcdAZmrXtlcntY6qyE7Ek17m92tnFrC+0bnK5lH5wJd7NMPXMUjVgHty4c1
8+
v13oUojS6dNl8S1XqWA5Dei3TIxHzuyP5/tOoJqmtDculZkbSSpQASsbFgzPIocp
9+
/KP0gw2vRU6+n5J4ACNyb/ebk2K6W2BVxuCPikaD02ITLG0Z6nOnAgMBAAGjUzBR
10+
MB0GA1UdDgQWBBSXwpTsF7g1RJ3rSS/osnLBhDsrbjAfBgNVHSMEGDAWgBSXwpTs
11+
F7g1RJ3rSS/osnLBhDsrbjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUA
12+
A4IBAQAJ9UTrIAYyqE8V7QgQ4FEnSDPp+DULPMkqW46FhOsLmq69369lqK+vHN7g
13+
AL88aqpJyjN10AHjwuuK046Jhpl/mDOtDknuk0XG+qJhKDi3g79KL9XOtaZJ36AR
14+
Tfaii+2WZKhZ+3INLNs4R/qqvH01BbJrrVi/DNetAz3/l+E9cMmtuvliMe0dYOqy
15+
p7NL9kf0M/tK7tqx/XnSph/5it32wmxaFEkoyIZwcSCYec5Qg+EkiIOgTPsz3t1q
16+
v53XPZTb6TMz2eQBWdWt+WZeRc8jtFZk3gCfCHkmDPFtjDNiHdbdYz90ay4f6gvC
17+
OQunhxxROzoHm+3KbkbYzw4ms1ob
18+
-----END CERTIFICATE-----
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-----BEGIN DH PARAMETERS-----
2+
MIIBCAKCAQEAhdAA2zXrlgO7G/YgRgXpskLOr6R45pwiNftto/ENa9UT7lzJ10cK
3+
elyPXkpR5rgv+FPzuwIqPQ2FfDI+h6VLFkhBjxPj2jBonVb+Y/dknKjJNFD+V3c0
4+
unyeaWAwZ/KOhntkz8LYTo1VEx++HcvAm1KvVDGtlyJDGPkONXy9EUrLuaHFBovH
5+
y+4d9iXjyslaV/5ci3YeAm+X/aDJzb8dXbz68Ct2GWM6+DT7S9CXylBfiFWaomzK
6+
z/wYlEVxclyNacsG7UbcvQeUI+jxETLdXKI22eYlQbaTq7fEII1VFV+SroTDxM4O
7+
daJbXLxe73aubjObiCAMG85c2LICup/lBwIBAg==
8+
-----END DH PARAMETERS-----
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-----BEGIN PRIVATE KEY-----
2+
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCsLcw9Tjpn9AwP
3+
CHM3B5n8/R8RPauwO2sd2te481Yw+wkfeLeDUICYjXs1uI21dyQ8pJtRbrk2Yz2i
4+
x/amyEGGEGaGiW4rQjxgmCczTFdsp0eMV0Vqk5mcSZfT9iNg2IS3+K9K+89+K27P
5+
Np/eWOFWW3b7/s1DNELqR7uGtTcdAZmrXtlcntY6qyE7Ek17m92tnFrC+0bnK5lH
6+
5wJd7NMPXMUjVgHty4c1v13oUojS6dNl8S1XqWA5Dei3TIxHzuyP5/tOoJqmtDcu
7+
lZkbSSpQASsbFgzPIocp/KP0gw2vRU6+n5J4ACNyb/ebk2K6W2BVxuCPikaD02IT
8+
LG0Z6nOnAgMBAAECggEAEcg/FjvMk2zki+7q+015LWQ0/7JXV4Gje/dcnTjgd3mN
9+
xSbSCSlYxqiiB3fShuHRp8O2WNAvJ7tTI8s0IaCAB+kMtate6e/SzYUZU1Z4lvul
10+
y4w92pZ44GfHWvhKShfCiT+RVxSvps+0h4kUNMIIL8ONg9QafezZVlnnN6/ii8ex
11+
qWE+375E2J2gWB295r6dii/enWQLMPeo6vwbFGGLbdqggLDT3VO5bL6fKZ+SECaT
12+
1iou2LKiR33ZPE6SMT6qUEdu82pmbCqpy0HMfSGcewWwG/yItsCEMMr0wrNSRlnn
13+
I5PN4nOkVrm0fAA0ExeCePusOIAFRdgSxl993Dgf3QKBgQDPzLEDdoqe4LzTyco6
14+
rWAxmBtMjJj9a3tKJs2+CoxyimJ2J84E0/luVMgKlRbCKF4KZTyYZ2NjeU5NITre
15+
ter/BAqkN5qmYZZRXuLfbqZyHhhEkR0nX8c0GhchG57vXf5tGNMaNyRSCF+T8OLL
16+
xLIWhwsAkB4fT9t/drLbiOHFMwKBgQDUHevflOgwDlNAbCdDETwO/yeTVkMZd6W5
17+
I77QAPnZGcS4RIjbQ1PHu3atM1JUeO/TVoX7/WYBNRF7/60W9/WIL03fJG/X/s1M
18+
yRNjw4Opx5XDIXbC2sg8YD6Pxso/uhg1icZJiH43QXqknmP1fDX3PegtEq8M5xmx
19+
nVDYGNqvvQKBgQCtss6stGQ/VmDBMEZJMi/chOcc39Hq0/NlEnacyriH7kFLvw4p
20+
Xv97SIdGwUUa2x9w1RsH0jR0LCxVsNdC3xImRTyX9JrjRWOfdQ9z8UxUy+9BMYQL
21+
K7aaSMzYsfvy3sEUdNHRchJ8N9+dDJin+C1dQ1jhCZcEWX6DV7c+Z3dBnQKBgBLT
22+
yRDiTa2eR+Nq9h0s1XDbUu7v9Cq5hPsm4hPiUkrjz6MvahpUIoaS7Bi5enBG/7p5
23+
bpEMT9aBmFiyO/HS9nctA7Nvr4GzexN6sX7kZrZWIcPdH4ZyFt3NCSCH24HGicmO
24+
vgve0p0i8bjU2jh62utkEkyV4PW7OXubZAaaRibdAoGBAJwUv9BMRO4Sy6wjDO/I
25+
KyQvgf8E9TaOXxsB8q88DTwLcm4vox/yHWehTegOP37PjEicZznYvgshIdFJ1vHi
26+
Cv9PxOVd/5oXtf2UXIm3e+SPbQsPpiYvUI4S/ga/i2yQ1x91bLGsAGSnVFGl6ibD
27+
LsNcu1Ry2e/1sWKD3aGgh2ZD
28+
-----END PRIVATE KEY-----
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
class SendEchoSSL{
2+
constructor(url, port_0, port_1, port_submit){
3+
if(port_0 == undefined){
4+
port_0 = 8090
5+
}
6+
if(port_1 == undefined){
7+
port_1 = 8091
8+
}
9+
if(port_submit == undefined){
10+
port_submit = 8089
11+
}
12+
13+
if(url.indexOf("https://")!=0){
14+
url = "https://"+url;
15+
}
16+
17+
const This = this;
18+
19+
This.url = url;
20+
This.port_0 = port_0;
21+
This.port_1 = port_1;
22+
This.port_submit = port_submit;
23+
}
24+
25+
convert_to_binary(string){
26+
const convert_to_byte_string = function(n){
27+
if(n < 0 || n > 255 || n % 1 !== 0){
28+
throw new Error(n + " does not fit in a byte");
29+
}
30+
return (("000000000" + n.toString(2)).substr(-8));
31+
}
32+
33+
let output = ""
34+
for(var i = 0; i < string.length; i++){
35+
output += convert_to_byte_string(string[i].charCodeAt(0));
36+
}
37+
38+
return output;
39+
}
40+
41+
send(message){
42+
const This = this;
43+
return Promise.resolve()
44+
.then(async function(){
45+
const binary_string = This.convert_to_binary(message);
46+
47+
let counter = 0;
48+
49+
const send_data = function(url){
50+
let Resolve, Reject;
51+
let promise = new Promise(function(resolve, reject){
52+
Resolve = resolve;
53+
Reject = reject;
54+
});
55+
56+
var oReq = new XMLHttpRequest();
57+
oReq.addEventListener("load", Resolve);
58+
oReq.addEventListener("error", Resolve);
59+
oReq.open("GET", url + "?" + counter);
60+
oReq.send();
61+
62+
counter++;
63+
return promise
64+
}
65+
66+
const send_0 = function(){
67+
const url = This.url + ":" + This.port_0;
68+
return send_data(url);
69+
}
70+
const send_1 = function(){
71+
const url = This.url + ":" + This.port_1;
72+
return send_data(url);
73+
}
74+
const send_submit = function(){
75+
const url = This.url + ":" + This.port_submit;
76+
return send_data(url);
77+
}
78+
79+
// Do an initial flush of all 3 so the browser doesn't double fire trying to connect
80+
await send_0();
81+
await send_1();
82+
await send_submit();
83+
counter = 0;
84+
85+
for(let i = 0; i < binary_string.length; i++){
86+
let number = Number(binary_string[i]);
87+
if(number == 0){
88+
await send_0();
89+
} else{
90+
await send_1();
91+
}
92+
}
93+
await send_submit()
94+
})
95+
}
96+
}
97+
98+
/*
99+
Example usage:
100+
101+
let send_data = new SendEchoSSL("192.168.1.167")
102+
send_data.send("Test message")
103+
*/
104+
105+
106+
export {SendEchoSSL}

0 commit comments

Comments
 (0)