I tried many different codes, But all of them only returned local IP address of the user. (e.g. 192.168.1.2).
How may I obtain user's public IPv4 address using WebRTC? (e.g. 104.200.21.83)
I know it's possible because a website could show my leaked public IPv4 address even when I used VPN.
Here's a popular proof-of-concept:
https://github.com/diafygi/webrtc-ips
For me, it was only sending back my private IP. It appears you can get around this by changing the server IP:
https://github.com/diafygi/webrtc-ips/issues/33
The site you linked to uses the server address stun:stun.l.google.com:19302
, which returned my public address as expected.