<?php
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/../includes/functions.php';

$page_title   = 'WebRTC Leak Test – Check if your Real IP is Exposed';
$page_desc    = 'Free WebRTC Leak Test: check if your browser reveals your real IP address through WebRTC – even when using a VPN on ipcheck.tools.';
$page_current = 'webrtc';

require_once __DIR__ . '/header.php';
?>

<div class="hero">
  <div class="hero-label">Tool</div>
  <div class="hero-title">WebRTC Leak Test</div>
  <div class="hero-sub">Check if your browser reveals your real IP address through WebRTC</div>
</div>

<div class="wrap">

  <div class="ad-slot"><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-8287576653347400" data-ad-slot="2715725452" data-ad-format="auto" data-full-width-responsive="true"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></div>

  <div class="card card-blue">
    <div class="card-title"><i class="ti ti-broadcast"></i> WebRTC IP Detection</div>
    <div id="webrtc-loading" style="text-align:center; padding:20px; color:var(--text4);">
      <div class="spinner" style="margin:0 auto 12px;"></div>
      <p style="font-size:13px;">Checking WebRTC...</p>
    </div>
    <div id="webrtc-result" style="display:none;">
      <div id="webrtc-ips"></div>
    </div>
    <div id="webrtc-unsupported" style="display:none;">
      <div class="alert alert-info">
        <i class="ti ti-info-circle"></i>
        <span>Your browser does not support WebRTC or it is disabled. No leak possible.</span>
      </div>
    </div>
  </div>

  <div class="grid2">
    <div class="card">
      <div class="card-title"><i class="ti ti-info-circle"></i> What is a WebRTC Leak?</div>
      <p style="font-size:13px; color:var(--text3); line-height:1.7;">WebRTC (Web Real-Time Communication) is a browser technology for video calls and file sharing. It can reveal your real IP address – even if you use a VPN. This happens because WebRTC creates direct peer-to-peer connections that bypass VPN tunnels.</p>
    </div>
    <div class="card">
      <div class="card-title"><i class="ti ti-shield"></i> How to prevent WebRTC leaks</div>
      <div class="data-row"><span class="dk">Firefox</span><span class="dv" style="font-size:12px;">about:config → media.peerconnection.enabled = false</span></div>
      <div class="data-row"><span class="dk">Chrome</span><span class="dv" style="font-size:12px;">Use WebRTC leak prevention extension</span></div>
      <div class="data-row"><span class="dk">Brave</span><span class="dv" style="font-size:12px;">Settings → Privacy → WebRTC IP policy</span></div>
      <div class="data-row"><span class="dk">VPN</span><span class="dv" style="font-size:12px;">Use a VPN with WebRTC leak protection</span></div>
    </div>
  </div>

  <div class="card">
    <div class="card-title"><i class="ti ti-arrow-right"></i> Continue with</div>
    <div style="display:flex; gap:8px; flex-wrap:wrap;">
      <a href="/en/dns-leak.php" class="btn btn-primary" style="font-size:12px; padding:6px 14px;">
        <i class="ti ti-shield-off"></i> DNS Leak Test
      </a>
      <a href="/en/ip-lookup.php" class="btn btn-ghost" style="font-size:12px; padding:6px 14px;">
        <i class="ti ti-world-search"></i> IP Lookup
      </a>
    </div>
  </div>

  <div class="ad-slot"><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-8287576653347400" data-ad-slot="2715725452" data-ad-format="auto" data-full-width-responsive="true"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></div>

  <div class="tools-row">
    <a href="/en/"              class="tool-btn"><i class="ti ti-home"></i><span>My IP</span></a>
    <a href="/en/webrtc.php"    class="tool-btn current"><i class="ti ti-broadcast"></i><span>WebRTC</span></a>
    <a href="/en/dns-leak.php"  class="tool-btn"><i class="ti ti-shield-off"></i><span>DNS Leak</span></a>
    <a href="/en/ip-lookup.php" class="tool-btn"><i class="ti ti-world-search"></i><span>IP Lookup</span></a>
    <a href="/en/"              class="tool-btn"><i class="ti ti-home"></i><span>My IP</span></a>
  </div>

  <div class="seo-box">
    <h2>WebRTC and privacy</h2>
    <p>WebRTC is built into most modern browsers and can expose your local and public IP addresses. This is especially problematic when using a VPN – the VPN hides your IP at the network level, but WebRTC can bypass this protection and reveal your real IP to websites. A WebRTC leak test checks whether your browser is affected.</p>
  </div>



<script>
async function detectWebRTC() {
  if (!window.RTCPeerConnection) {
    document.getElementById('webrtc-loading').style.display = 'none';
    document.getElementById('webrtc-unsupported').style.display = 'block';
    return;
  }

  const ips = new Set();
  const pc  = new RTCPeerConnection({iceServers: [{urls: 'stun:stun.l.google.com:19302'}]});
  pc.createDataChannel('');

  pc.onicecandidate = (e) => {
    if (!e.candidate) {
      pc.close();
      showResults(ips);
      return;
    }
    const parts = e.candidate.candidate.split(' ');
    if (parts[7] === 'host' || parts[7] === 'srflx') {
      const ip = parts[4];
      if (ip && ip !== '0.0.0.0') ips.add(ip);
    }
  };

  await pc.createOffer().then(o => pc.setLocalDescription(o));
  setTimeout(() => { pc.close(); showResults(ips); }, 3000);
}

function showResults(ips) {
  document.getElementById('webrtc-loading').style.display = 'none';
  document.getElementById('webrtc-result').style.display = 'block';

  const container = document.getElementById('webrtc-ips');
  if (ips.size === 0) {
    container.innerHTML = '<div class="alert alert-success"><i class="ti ti-shield-check"></i><span>No WebRTC leak detected. Your real IP address is not exposed.</span></div>';
    return;
  }

  let html = '';
  ips.forEach(ip => {
    const isLocal = ip.startsWith('192.168.') || ip.startsWith('10.') || ip.startsWith('172.') || ip.startsWith('169.254.') || ip.endsWith('.local');
    html += `<div class="data-row">
      <span class="dk">${isLocal ? 'Local IP' : '<strong style="color:var(--red);">Public IP (leak!)</strong>'}</span>
      <span class="dv mono ${isLocal ? '' : 'red'}">${ip}</span>
    </div>`;
  });

  const hasPublic = [...ips].some(ip => !ip.startsWith('192.168.') && !ip.startsWith('10.') && !ip.startsWith('172.') && !ip.startsWith('169.254.') && !ip.endsWith('.local'));
  if (hasPublic) {
    html = '<div class="alert alert-danger"><i class="ti ti-alert-triangle"></i><span>WebRTC leak detected! Your real IP address is exposed.</span></div>' + html;
  } else {
    html = '<div class="alert alert-warn"><i class="ti ti-info-circle"></i><span>Only local IP addresses detected via WebRTC. No public IP leak.</span></div>' + html;
  }

  container.innerHTML = html;
}

detectWebRTC();
</script>

<?php require_once __DIR__ . '/footer.php'; ?>
