-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html~
55 lines (48 loc) · 1.5 KB
/
index.html~
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
<html>
<head>
<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://169.254.128.154: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://169.254.128.154: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>
<input type="text" id="wanIpAddress">
<button onClick="startLanProxy();">start</button>
</body>
</html>