-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WSS Browser Dialer support (#421)
- Loading branch information
Showing
3 changed files
with
119 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Browser Dialer</title> | ||
</head> | ||
<body></body> | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
<script> | ||
// Copyright (c) 2021 XRAY. Mozilla Public License 2.0. | ||
var url = "ws://" + window.location.host + "/websocket" | ||
var count = 0 | ||
setInterval(check, 1000) | ||
function check() { | ||
if (count <= 0) { | ||
count += 1 | ||
console.log("Prepare", url) | ||
var ws = new WebSocket(url) | ||
var wss = undefined | ||
var first = true | ||
ws.onmessage = function (event) { | ||
if (first) { | ||
first = false | ||
count -= 1 | ||
var arr = event.data.split(" ") | ||
console.log("Dial", arr[0], arr[1]) | ||
wss = new WebSocket(arr[0], arr[1]) | ||
var opened = false | ||
wss.onopen = function (event) { | ||
opened = true | ||
ws.send("ok") | ||
} | ||
wss.onmessage = function (event) { | ||
ws.send(event.data) | ||
} | ||
wss.onclose = function (event) { | ||
ws.close() | ||
} | ||
wss.onerror = function (event) { | ||
!opened && ws.send("fail") | ||
wss.close() | ||
} | ||
check() | ||
} else wss.send(event.data) | ||
} | ||
ws.onclose = function (event) { | ||
if (first) count -= 1 | ||
else wss.close() | ||
} | ||
ws.onerror = function (event) { | ||
ws.close() | ||
} | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
多个
</body>