<html>
    <head>
    	<meta name=viewport content="width=device-width,initial-scale=1">
        <link rel="icon" href="//cdn.amegroups.cn/assets/public/img/ame-logo.ico" type="image/x-icon">
    </head>
    <body style="margin: 0;">
        <div style="display: flex;justify-content: center;align-items: center;height:100vh;">
            <p id="ip" style="padding: 20px;border: 1px solid #ddd;border-radius: 5px;">
                Welcome to AME; <span>Your IP Address: 216.73.216.158,216.73.216.158, 104.23.243.112</span>
            </p>
        </div>
    </body>
    <script>
        let myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
        let pc = new myPeerConnection({
            iceServers: [{
                urls: [
                	  "stun:turn.cloudflare.com:3478", 
                      "stun:stun.nextcloud.com:3478",
                      "stun:fwa.lifesizecloud.com:3478"
                ]
            }],
        })
          , noop = function() {}
          , localIPs = {}
          , ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g;

        function ipIterate(ip) {
            if (!localIPs[ip])
                return ip;
            localIPs[ip] = true;
        };
        pc.createDataChannel("");
        pc.createOffer(function(sdp) {
            pc.setLocalDescription(sdp, noop, noop);
        }, noop);
        pc.onicecandidate = (ice)=>{
            if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex))
                return;
            if (ice.candidate.type === "host") {
                this.webrtcHost = ice.candidate.address;
                let sp = document.createElement("span")
                sp.innerHTML = "    Webrtc Host: " + ice.candidate.address
                document.getElementById("ip").append(sp)
            } else if (ice.candidate.type === "srflx") {
                this.webrtcIP = ice.candidate.address;
                let sp = document.createElement("span")
                sp.innerHTML = "    Webrtc IP: " + ice.candidate.address
                document.getElementById("ip").append(sp)
            }
        };
    </script>
</html>