-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html_tmp
62 lines (54 loc) · 1.88 KB
/
index.html_tmp
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
<html>
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no">
<meta http-equiv="Content-Type"content="text/html;charset=UTF-8">
<script src="/socket.io/socket.io.js"></script>
<script>
function startLanProxy() {
var wanIpAddress = 'http://' + document.getElementById("wanIpAddress").value
+':8123';
// フロント側のHttpProxyサーバから
var socket = io.connect('http://192.168.0.5:8000/');
// WS->HttpProxyサーバ
//var proxy = io.connect('http://118.153.61.84:8123');
var proxy = io.connect(wanIpAddress);
socket.on('httptows', function (data) {
console.log("to proxy : " + data);
proxy.emit('wstohttp', data);
});
// WS->HttpProxyサーバからの応答
proxy.on('httptows', function (data) {
console.log("from proxy : " + data);
socket.emit('wstohttp', data );
});
// WS->HttpProxyサーバからの応答(切断)
proxy.on('httpend', function (data) {
console.log("from proxy end ");
socket.emit('httpend', data );
});
proxy.on('end', function (data) {
proxy = io.connect('');
});
socket.on('end', function (data) {
socket = io.connect('http://192.168.0.5:8000');
});
//socket.on('disconnect' function() {
// console.log("client close");
//});
//proxy.on('disconnect', function() {
// console.log("proxy close");
//});
console.log("start!");
console.log("wanIpAddress = " + wanIpAddress);
}
</script>
</head>
<body>
<label>接続先のWAN側のWebSocketProxyのIPアドレス</label>
<input type="text" id="wanIpAddress">
<br>
<label>LAN側のクライアントに設定するHttpProxyのIPアドレス</label>
<input type="text" id="lanIpAddress" value="192.168.0.5">
<button onClick="startLanProxy();">start</button>
</body>
</html>