### Compile Xray for Linux/macOS Source: https://github.com/xtls/xray-tun/blob/main/README.md Use this command to build the Xray executable for Linux and macOS. It includes flags for stripping symbols and removing debug information. ```bash go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main ``` -------------------------------- ### Compile Xray for Windows Source: https://github.com/xtls/xray-tun/blob/main/README.md Use this command to build the Xray executable for Windows. It includes flags for stripping symbols and removing debug information. ```bash go build -o xray.exe -trimpath -ldflags "-s -w -buildid=" ./main ``` -------------------------------- ### Browser WebSocket Dialer Source: https://github.com/xtls/xray-tun/blob/main/transport/internet/websocket/dialer.html Initiates a WebSocket connection to a specified URL. It then listens for a message containing details for a secondary WebSocket connection. This code is intended for browser environments. ```javascript 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() } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.