showme Posted November 14, 2011 Posted November 14, 2011 How to get client IP address and computer name? Quote
Administrators Farshad Mohajeri Posted November 14, 2011 Administrators Posted November 14, 2011 How to get client IP address and computer name? UniLabel1.Caption:=UniApplication.RemoteAddress; Quote
jackamin Posted January 18, 2023 Posted January 18, 2023 UniApplication.RemoteAddress; this returns the ip address of the server where the application is running. How do we get the client IP? Quote
jackamin Posted January 18, 2023 Posted January 18, 2023 tested again UniApplication.RemoteAddress; does return the cleint's static ip. this will return same IP for all users on the same network. is there a way to also get the local ip or some other identification to identify the pc. Quote
irigsoft Posted January 18, 2023 Posted January 18, 2023 52 minutes ago, jackamin said: is there a way to also get the local ip or some other identification to identify the pc Hello, I use unique identificator for PC like POS ID, generated from Session ID (because Session ID is unique) Quote
irigsoft Posted January 18, 2023 Posted January 18, 2023 maybe this will help too: https://www.c-sharpcorner.com/blogs/getting-client-ip-address-or-local-ip-address-in-javascript https://stackoverflow.com/questions/20194722/can-you-get-a-users-local-lan-ip-address-via-javascript https://www.geeksforgeeks.org/how-to-get-client-ip-address-using-javascript/ Quote
irigsoft Posted January 18, 2023 Posted January 18, 2023 4 hours ago, jackamin said: is there a way to also get the local ip or some other identification to identify the pc. this work for me on Chrome: https://stackoverflow.com/questions/20194722/can-you-get-a-users-local-lan-ip-address-via-javascript "Last year I used Linblow's answer (2018-Oct-19) to successfully discover my local IP via javascript. However, recent Chrome updates (76?) have wonked this method so that it now returns an obfuscated IP, such as: 1f4712db-ea17-4bcf-a596-105139dfd8bf.local If you have full control over your browser, you can undo this behavior by turning it off in Chrome Flags, by typing this into your address bar: chrome://flags/#enable-webrtc-allow-input-volume-adjustment and DISABLING the flag Anonymize local IPs exposed by WebRTC In my case, I require the IP for a TamperMonkey script to determine my present location and do different things based on my location. I also have full control over my own browser settings (no Corporate Policies, etc). So for me, changing the chrome://flags setting does the trick." and use this code in uniButtonClick uniSession.AddJS ('const findLocalIp = (logInfo = true) => new Promise( (resolve, reject) => {' + ' window.RTCPeerConnection = window.RTCPeerConnection' + ' || window.mozRTCPeerConnection' + ' || window.webkitRTCPeerConnection;' + ' if ( typeof window.RTCPeerConnection == ''undefined'' )' + ' return reject(''WebRTC not supported by browser'');' + ' let pc = new RTCPeerConnection();' + ' let ips = [];' + ' pc.createDataChannel("");' + ' pc.createOffer()' + ' .then(offer => pc.setLocalDescription(offer))' + ' .catch(err => reject(err));' + ' pc.onicecandidate = event => {' + ' if ( !event || !event.candidate ) {' // All ICE candidates have been sent. + ' if ( ips.length == 0 )' + ' return reject(''WebRTC disabled or restricted by browser'');' + ' return resolve(ips);' + ' }' + ' let parts = event.candidate.candidate.split('' '');' + ' let [base,componentId,protocol,priority,ip,port,,type,...attr] = parts;' + ' let component = [''rtp'', ''rtpc''];' + ' if ( ! ips.some(e => e == ip) )' + ' ips.push(ip);' + ' if ( ! logInfo )' + ' return;' // + ' console.log(" candidate: " + base.split('':'')[1]);' // + ' console.log(" component: " + component[componentId - 1]);' // + ' console.log(" protocol: " + protocol);' // + ' console.log(" priority: " + priority);' // + ' console.log(" ip: " + ip);' // + ' console.log(" port: " + port);' // + ' console.log(" type: " + type);' // + ' if ( attr.length ) {' // + ' console.log("attributes: ");' // + ' for(let i = 0; i < attr.length; i += 2)' // + ' console.log("> " + attr[i] + ": " + attr[i+1]);' // + ' };' // + ' console.log();' + ' let p = document.getElementById(''' + UniLabel10.JSID + ''');' + ' p.innerHTML = ip;' + ' alert (ip);' + ' };' + '} );' //read local IP on Client Side // + 'let p = document.getElementById(''ip'');' // + 'findLocalIp().then(' // + ' ips => {' // + ' let s = '';' // + ' ips.forEach( ip => s += ip + ''<br>'' );' // + ' p.innerHTML = s;' // + ' };' // + ' err => p.innerHTML = err' // + ' );' + 'findLocalIp();' ); Here is a demo Project ClientInfo.zip Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.