AI 에이전트 관찰
GPTBot, ClaudeBot, PerplexityBot 같은 AI 크롤러는 매일 사이트를 읽지만, 대부분의 운영자는 이를 전혀 보지 못합니다. 관찰 모드는 SilentShield AI 에이전트 제어의 1단계입니다: 아무것도 차단하지 않고 사이트 동작을 바꾸지 않으면서, 어떤 AI 서비스가 어떤 페이지를 방문하는지 기록합니다.
제어보다 가시성이 먼저입니다: 누가 콘텐츠를 읽는지 알아야 누구를 허용하고, 제한하고, 차단할지 제대로 결정할 수 있습니다. 그래서 모든 방문 기록은 세 가지 카테고리 중 하나로 분류됩니다:
이것은 관찰만 합니다 — 절대 차단하지 않습니다
이 페이지의 스니펫은 '설정 후 잊어버리는' 방식입니다. 어떤 AI 에이전트가 방문하는지 보고하며 응답은 절대 변경하지 않습니다. 대시보드에서 규칙을 "차단"으로 설정해도 이 스니펫만으로는 적용되지 않습니다. 실제 차단(허용되지 않은 봇에 대한 403)에는 서버에서 실행되는 별도의 엔포스 컴포넌트 — 2단계 — 가 필요합니다.
- 학습
- 크롤러가 향후 AI 모델 학습을 위해 콘텐츠를 수집합니다 (예: GPTBot, ClaudeBot, CCBot).
- AI 검색
- 서비스가 사용자 질문에 답하기 위해 페이지를 읽으며, 이때 사이트를 출처로 인용할 수 있습니다 (예: OAI-SearchBot, PerplexityBot).
- 에이전트
- 봇이 특정 사용자를 대신해 실시간으로 작동합니다. 예를 들어 상품을 조사하거나 사이트의 폼을 작성합니다 (예: ChatGPT-User, Claude-User).
플랫폼별 설정
WordPress
내장 옵저버는 SilentShield 플러그인의 향후 업데이트와 함께 제공됩니다. 그때까지는 작은 must-use 플러그인으로 관찰을 활성화하세요 — 파일 하나, 설정 불필요:
wp-content/mu-plugins/silentshield-observer.php 파일을 아래 내용으로 만드세요(mu-plugin은 자동으로 로드됩니다. 비활성화하려면 파일을 삭제하세요):
<?php
/**
* Plugin Name: SilentShield — AI Agent Observer
* Description: Reports AI crawler visits to SilentShield (fire-and-forget;
* IP/UA are hashed server-side, GDPR). Delete this file to disable.
*
* OBSERVE ONLY: this reports visits and NEVER blocks. Making a "Block" rule
* actually block (403) requires the separate enforce component (Stage 2).
*
* Install: save this file as wp-content/mu-plugins/silentshield-observer.php
* (mu-plugins load automatically — no activation needed). To force it off
* without deleting: define('SILENTSHIELD_OBSERVER', false) in wp-config.php.
* An upcoming SilentShield plugin update will build this in.
*/
if (!defined('ABSPATH')) exit;
if (defined('SILENTSHIELD_OBSERVER') && !SILENTSHIELD_OBSERVER) return;
const SS_OBSERVE_URL = "https://api.silentshield.io/api/v1/agent/telemetry";
const SS_API_KEY = "YOUR_API_KEY"; // publishable site key
// For the always-fresh list, cache https://api.silentshield.io/api/v1/agent/bot-directory daily.
$ss_bots = ["GPTBot","OAI-SearchBot","ChatGPT-User","ClaudeBot","Claude-User",
"PerplexityBot","Perplexity-User","Bingbot","Applebot","Amazonbot","CCBot",
"Bytespider","meta-externalagent","Google-Agent"];
// Where the visitor's address comes from. SilentShield confirms an agent by
// its address (published ranges), so it must be one your own infrastructure
// vouches for. Behind a proxy REMOTE_ADDR is the proxy, and anyone can send
// X-Forwarded-For: its LEFT-most entry is written by the client and is never
// used. Set ONE of:
// - SS_TRUSTED_PROXIES: your reverse proxies (CIDRs or bare IPs, e.g. nginx on
// "127.0.0.1", plus Cloudflare's ranges if it sits in front). Behind one of
// them, X-Forwarded-For is read from the RIGHT; the first address that is
// not one of them is the visitor.
// - SS_DIRECT_CONNECTION = true: no proxy in front, REMOTE_ADDR IS the visitor.
// Neither set: no address is sent. Visits are still reported, and signed
// agents are still confirmed; an unsigned agent is then neither confirmed nor
// flagged as spoofed.
const SS_TRUSTED_PROXIES = []; // e.g. ["127.0.0.1", "10.0.0.0/8"]
const SS_DIRECT_CONNECTION = false;
// ::ffff:a.b.c.d is the IPv4 address a.b.c.d.
function silentshield_observer_canonical_ip($ip) {
$ip = trim((string) $ip);
$v4 = preg_replace('/^::ffff:/i', '', $ip);
return filter_var($v4, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false ? $v4 : $ip;
}
function silentshield_observer_is_trusted($ip) {
if (filter_var($ip, FILTER_VALIDATE_IP) === false) return false;
$bin = inet_pton($ip);
foreach (SS_TRUSTED_PROXIES as $entry) {
$parts = explode("/", trim((string) $entry), 2);
if (filter_var($parts[0], FILTER_VALIDATE_IP) === false) continue; // unparsable: dropped
$net = inet_pton($parts[0]);
if (strlen($net) !== strlen($bin)) continue;
$max = strlen($net) * 8;
if (isset($parts[1]) && !preg_match('/^\d+$/', $parts[1])) continue;
$bits = isset($parts[1]) ? (int) $parts[1] : $max;
if ($bits > $max) continue;
$full = intdiv($bits, 8);
$rest = $bits % 8;
if (substr($bin, 0, $full) !== substr($net, 0, $full)) continue;
if ($rest === 0) return true;
$mask = (0xff << (8 - $rest)) & 0xff;
if ((ord($bin[$full]) & $mask) === (ord($net[$full]) & $mask)) return true;
}
return false;
}
// The visitor's address, or null when none can be vouched for.
function silentshield_observer_visitor_ip() {
$peer = silentshield_observer_canonical_ip($_SERVER["REMOTE_ADDR"] ?? "");
if (filter_var($peer, FILTER_VALIDATE_IP) === false) return null;
if (count(SS_TRUSTED_PROXIES) === 0) return SS_DIRECT_CONNECTION ? $peer : null;
if (!silentshield_observer_is_trusted($peer)) return $peer; // not your proxy: the peer is the visitor
$hops = explode(",", (string) ($_SERVER["HTTP_X_FORWARDED_FOR"] ?? ""));
for ($i = count($hops) - 1; $i >= 0; $i--) {
$hop = silentshield_observer_canonical_ip($hops[$i]);
if ($hop === "") continue;
if (filter_var($hop, FILTER_VALIDATE_IP) === false) return null; // garbage stops the walk
if (!silentshield_observer_is_trusted($hop)) return $hop;
}
return $peer; // only your own proxies
}
register_shutdown_function(function () use ($ss_bots) {
// Optional: skip observation for your own logged-in users so their visits
// are never reported.
// if (is_user_logged_in()) return;
$ua = $_SERVER["HTTP_USER_AGENT"] ?? "";
$signed = !empty($_SERVER["HTTP_SIGNATURE"]);
$isBot = $signed;
foreach ($ss_bots as $b) { if (stripos($ua, $b) !== false) { $isBot = true; break; } }
if (!$isBot) return;
if (function_exists("fastcgi_finish_request")) { fastcgi_finish_request(); }
$sighting = [
"ua" => $ua,
// Query strings are stripped here for data minimization. If you enabled
// "Capture query strings" for this key in the SilentShield dashboard,
// send the full URI instead: "path" => $_SERVER["REQUEST_URI"] ?? "/",
// With the PHP SDK (forge12interactive/silentshield-sdk 1.5.0+) the option
// 'send_full_uri' => true does this for you.
"path" => strtok($_SERVER["REQUEST_URI"] ?? "/", "?"),
"method" => $_SERVER["REQUEST_METHOD"] ?? "GET",
];
$ip = silentshield_observer_visitor_ip();
if ($ip !== null) { $sighting["ip"] = $ip; } // none: not sent (see SS_TRUSTED_PROXIES)
wp_remote_post(SS_OBSERVE_URL, [
"timeout" => 3,
"blocking" => false,
"headers" => ["Content-Type" => "application/json", "x-api-key" => SS_API_KEY],
"body" => wp_json_encode(["sightings" => [$sighting]]),
]);
});Next.js
독립형 미들웨어입니다 — SDK가 필요 없습니다. 관찰은 event.waitUntil()을 통해 응답 경로 밖에서 실행되므로 페이지가 지연되지 않습니다:
// proxy.ts — self-contained observer, no SDK required.
// Next.js 16+ uses proxy.ts. On Next.js 15 or older, name the file
// middleware.ts and the function middleware; nothing else changes.
// Sightings are reported via event.waitUntil(), off the response path,
// so your pages never wait. Best-effort and fail-open by design.
// OBSERVE ONLY: reports visits, never blocks. Blocking (403) needs the
// separate enforce component (Stage 2).
import { NextResponse, type NextRequest } from "next/server";
const OBSERVE_URL = "https://api.silentshield.io/api/v1/agent/telemetry";
const API_KEY = "YOUR_API_KEY"; // publishable site key
// Known AI-agent UA tokens. For the always-fresh list, fetch
// https://api.silentshield.io/api/v1/agent/bot-directory once a day and cache it.
const BOTS = ["GPTBot", "OAI-SearchBot", "ChatGPT-User", "ClaudeBot", "Claude-User",
"PerplexityBot", "Perplexity-User", "Bingbot", "Applebot", "Amazonbot", "CCBot",
"Bytespider", "meta-externalagent", "Google-Agent"];
// Where the visitor's address comes from. SilentShield confirms an agent by
// its address (published ranges), so it must be one your own infrastructure
// vouches for. Anyone can send X-Forwarded-For: its LEFT-most entry is written
// by the client and is never used. Set ONE of:
// - CLIENT_IP_HEADER: your platform's own single-address header, e.g.
// "x-real-ip" on Vercel or "cf-connecting-ip" behind Cloudflare.
// - TRUSTED_PROXIES: your reverse proxies (CIDRs or bare IPs, e.g. nginx on
// "127.0.0.1", plus Cloudflare's ranges if it sits in front). X-Forwarded-For
// is read from the RIGHT (the entries your proxies appended); the first
// address that is not one of them is the visitor. Make sure the app is only
// reachable through these proxies.
// Neither set: no address is sent. Visits are still reported, and signed
// agents are still confirmed; an unsigned agent is then neither confirmed nor
// flagged as spoofed.
const CLIENT_IP_HEADER = "";
const TRUSTED_PROXIES: string[] = [];
// IPv4 / IPv6 text → bytes; null for anything else.
function ipBytes(ip: string): number[] | null {
if (/^\d{1,3}(\.\d{1,3}){3}$/.test(ip)) {
const b = ip.split(".").map(Number);
return b.every((n) => n <= 255) ? b : null;
}
if (!/^[0-9a-f:]+$/i.test(ip)) return null;
const halves = ip.split("::");
if (halves.length > 2) return null;
const head = halves[0] ? halves[0].split(":") : [];
const tail = halves.length === 2 && halves[1] ? halves[1].split(":") : [];
const fill = 8 - head.length - tail.length;
if (halves.length === 2 ? fill < 1 : fill !== 0) return null;
const groups = [...head, ...Array(fill).fill("0"), ...tail];
if (groups.some((g) => g === "" || g.length > 4)) return null;
return groups.flatMap((g) => [parseInt(g, 16) >> 8, parseInt(g, 16) & 255]);
}
// ::ffff:a.b.c.d is the IPv4 address a.b.c.d.
const canonicalIp = (ip: string) => ip.trim().replace(/^::ffff:(?=\d+\.\d+\.\d+\.\d+$)/i, "");
function inNet(ip: number[], cidr: string): boolean {
const [base, bitsText] = cidr.trim().split("/");
const net = ipBytes(canonicalIp(base));
if (!net || net.length !== ip.length) return false;
if (bitsText !== undefined && !/^\d+$/.test(bitsText)) return false;
const bits = bitsText === undefined ? net.length * 8 : Number(bitsText);
if (bits > net.length * 8) return false;
for (let i = 0; i < net.length; i++) {
const mask = (0xff << (8 - Math.max(0, Math.min(8, bits - i * 8)))) & 0xff;
if ((ip[i] & mask) !== (net[i] & mask)) return false;
}
return true;
}
function visitorIp(req: NextRequest): string | undefined {
if (CLIENT_IP_HEADER) {
const ip = canonicalIp(req.headers.get(CLIENT_IP_HEADER) ?? "");
return ipBytes(ip) ? ip : undefined; // one address, nothing else
}
if (TRUSTED_PROXIES.length === 0) return undefined;
const hops = (req.headers.get("x-forwarded-for") ?? "").split(",");
for (let i = hops.length - 1; i >= 0; i--) {
const hop = canonicalIp(hops[i]);
if (hop === "") continue;
const bytes = ipBytes(hop);
if (!bytes) return undefined; // garbage stops the walk
if (!TRUSTED_PROXIES.some((c) => inNet(bytes, c))) return hop;
}
return undefined; // only your own proxies, or no header
}
export function proxy(req: NextRequest, event: { waitUntil(p: Promise<unknown>): void }) {
// Optional: skip observation for your own trusted traffic (e.g. logged-in
// users) so their visits are never reported. Plug in your own check.
// if (isLoggedIn(req)) return NextResponse.next();
const ua = req.headers.get("user-agent") ?? "";
const signed = !!req.headers.get("signature");
if (signed || BOTS.some((b) => ua.toLowerCase().includes(b.toLowerCase()))) {
const sighting = {
ua,
// pathname strips the query for data minimization. If you enabled
// "Capture query strings" for this key in the dashboard, send the full
// path instead: path: req.nextUrl.pathname + req.nextUrl.search,
path: req.nextUrl.pathname,
method: req.method,
ip: visitorIp(req), // undefined → not sent (see CLIENT_IP_HEADER)
...(signed && {
signature: req.headers.get("signature"),
signature_input: req.headers.get("signature-input"),
signature_agent: req.headers.get("signature-agent"),
authority: req.nextUrl.host,
scheme: req.nextUrl.protocol.replace(":", ""),
}),
};
event.waitUntil(
fetch(OBSERVE_URL, {
method: "POST",
headers: { "Content-Type": "application/json", "x-api-key": API_KEY },
body: JSON.stringify({ sightings: [sighting] }),
}).catch(() => {}) // best-effort, fail-open
);
}
return NextResponse.next();
}Node.js (Express)
Express(또는 다른 Node 서버)에는 fire-and-forget 미들웨어를 추가하세요. User-Agent가 알려진 AI 에이전트와 일치하거나 Web Bot Auth 서명이 있는 요청만 보고하며 — 응답을 절대 차단하지 않습니다:
// OBSERVE ONLY: reports AI-agent visits, never blocks. Blocking (403)
// needs the separate enforce component (Stage 2).
import express from "express";
import net from "node:net";
const app = express();
const OBSERVE_URL = "https://api.silentshield.io/api/v1/agent/telemetry";
const API_KEY = "YOUR_API_KEY";
// Where the visitor's address comes from. SilentShield confirms an agent by
// its address (published ranges), so it must be one your own infrastructure
// vouches for. Anyone can send X-Forwarded-For: its LEFT-most entry is written
// by the client and is never used (nor is req.ip, which takes it under
// "trust proxy"). Set ONE of:
// - TRUSTED_PROXIES: your reverse proxies (CIDRs or bare IPs, e.g. nginx on
// "127.0.0.1", plus Cloudflare's ranges if it sits in front). Behind one of
// them, X-Forwarded-For is read from the RIGHT; the first address that is
// not one of them is the visitor.
// - DIRECT_CONNECTION = true: no proxy in front, the connection peer IS the visitor.
// Neither set: no address is sent. Visits are still reported, and signed
// agents are still confirmed; an unsigned agent is then neither confirmed nor
// flagged as spoofed.
const TRUSTED_PROXIES = []; // e.g. ["127.0.0.1", "10.0.0.0/8"]
const DIRECT_CONNECTION = false;
const trusted = new net.BlockList();
for (const entry of TRUSTED_PROXIES) {
const [addr, bits] = String(entry).trim().split("/");
const type = net.isIPv4(addr) ? "ipv4" : net.isIPv6(addr) ? "ipv6" : null;
if (!type) continue; // unparsable entries are dropped
try {
if (bits === undefined) trusted.addAddress(addr, type);
else if (/^\d+$/.test(bits)) trusted.addSubnet(addr, Number(bits), type);
} catch {}
}
const canonicalIp = (ip) => {
const t = String(ip || "").trim();
const v4 = t.replace(/^::ffff:/i, ""); // IPv4-mapped peer (dual-stack socket)
return net.isIPv4(v4) ? v4 : t;
};
const isTrusted = (ip) => net.isIP(ip) !== 0 && trusted.check(ip, net.isIPv4(ip) ? "ipv4" : "ipv6");
function visitorIp(req) {
const peer = canonicalIp(req.socket && req.socket.remoteAddress);
if (net.isIP(peer) === 0) return undefined;
if (TRUSTED_PROXIES.length === 0) return DIRECT_CONNECTION ? peer : undefined;
if (!isTrusted(peer)) return peer; // not your proxy: the peer is the visitor
const xff = req.headers["x-forwarded-for"];
const hops = String(Array.isArray(xff) ? xff.join(",") : xff || "").split(",");
for (let i = hops.length - 1; i >= 0; i--) {
const hop = canonicalIp(hops[i]);
if (hop === "") continue;
if (net.isIP(hop) === 0) return undefined; // garbage stops the walk
if (!isTrusted(hop)) return hop;
}
return peer; // only your own proxies
}
// Known AI-agent UA tokens. For the always-fresh list, fetch
// https://api.silentshield.io/api/v1/agent/bot-directory once a day and cache it.
const BOTS = ["GPTBot", "OAI-SearchBot", "ChatGPT-User", "ClaudeBot", "Claude-User",
"PerplexityBot", "Perplexity-User", "Bingbot", "Applebot", "Amazonbot", "CCBot",
"Bytespider", "meta-externalagent", "Google-Agent"];
// Fire-and-forget observer — never blocks the response.
app.use((req, res, next) => {
// Optional: skip observation for your own trusted traffic (e.g. logged-in
// users) so their visits are never reported. Plug in your own check.
// if (isLoggedIn(req)) return next();
const ua = req.headers["user-agent"] || "";
const signed = !!req.headers["signature"];
if (signed || BOTS.some((b) => ua.toLowerCase().includes(b.toLowerCase()))) {
const sighting = {
// req.path strips the query for data minimization. If you enabled
// "Capture query strings" for this key in the dashboard, use
// req.originalUrl instead of req.path to send the full path. With the
// Node SDK (@forge12interactive/silentshield-sdk-js 1.7.0+) the option
// sendFullUri: true does this for you.
ua, ip: visitorIp(req), path: req.path, method: req.method,
...(signed && {
signature: req.headers["signature"],
signature_input: req.headers["signature-input"],
signature_agent: req.headers["signature-agent"],
authority: req.headers["host"], scheme: req.protocol,
}),
};
fetch(OBSERVE_URL, {
method: "POST",
headers: { "Content-Type": "application/json", "x-api-key": API_KEY },
body: JSON.stringify({ sightings: [sighting] }),
}).catch(() => {}); // best-effort, fail-open
}
next();
});PHP
순수 PHP에서는 이 옵저버를 프런트 컨트롤러 맨 위에 포함하세요. 응답이 전달된 후에만(fastcgi_finish_request) 방문 기록을 전송하므로 페이지가 느려지지 않습니다:
<?php
// Drop-in observer: include at the very top of your front controller.
// It runs after the response is sent (fastcgi_finish_request) so it never
// slows down the page. Reuses the same publishable key.
// OBSERVE ONLY: reports visits, never blocks. Blocking (403) needs the
// separate enforce component (Stage 2).
const SS_OBSERVE_URL = "https://api.silentshield.io/api/v1/agent/telemetry";
const SS_API_KEY = "YOUR_API_KEY";
// For the always-fresh list, cache https://api.silentshield.io/api/v1/agent/bot-directory daily.
$ss_bots = ["GPTBot","OAI-SearchBot","ChatGPT-User","ClaudeBot","Claude-User",
"PerplexityBot","Perplexity-User","Bingbot","Applebot","Amazonbot","CCBot",
"Bytespider","meta-externalagent","Google-Agent"];
// Where the visitor's address comes from. SilentShield confirms an agent by
// its address (published ranges), so it must be one your own infrastructure
// vouches for. Behind a proxy REMOTE_ADDR is the proxy, and anyone can send
// X-Forwarded-For: its LEFT-most entry is written by the client and is never
// used. Set ONE of:
// - SS_TRUSTED_PROXIES: your reverse proxies (CIDRs or bare IPs, e.g. nginx on
// "127.0.0.1", plus Cloudflare's ranges if it sits in front). Behind one of
// them, X-Forwarded-For is read from the RIGHT; the first address that is
// not one of them is the visitor.
// - SS_DIRECT_CONNECTION = true: no proxy in front, REMOTE_ADDR IS the visitor.
// Neither set: no address is sent. Visits are still reported, and signed
// agents are still confirmed; an unsigned agent is then neither confirmed nor
// flagged as spoofed.
const SS_TRUSTED_PROXIES = []; // e.g. ["127.0.0.1", "10.0.0.0/8"]
const SS_DIRECT_CONNECTION = false;
// ::ffff:a.b.c.d is the IPv4 address a.b.c.d.
function silentshield_observer_canonical_ip($ip) {
$ip = trim((string) $ip);
$v4 = preg_replace('/^::ffff:/i', '', $ip);
return filter_var($v4, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false ? $v4 : $ip;
}
function silentshield_observer_is_trusted($ip) {
if (filter_var($ip, FILTER_VALIDATE_IP) === false) return false;
$bin = inet_pton($ip);
foreach (SS_TRUSTED_PROXIES as $entry) {
$parts = explode("/", trim((string) $entry), 2);
if (filter_var($parts[0], FILTER_VALIDATE_IP) === false) continue; // unparsable: dropped
$net = inet_pton($parts[0]);
if (strlen($net) !== strlen($bin)) continue;
$max = strlen($net) * 8;
if (isset($parts[1]) && !preg_match('/^\d+$/', $parts[1])) continue;
$bits = isset($parts[1]) ? (int) $parts[1] : $max;
if ($bits > $max) continue;
$full = intdiv($bits, 8);
$rest = $bits % 8;
if (substr($bin, 0, $full) !== substr($net, 0, $full)) continue;
if ($rest === 0) return true;
$mask = (0xff << (8 - $rest)) & 0xff;
if ((ord($bin[$full]) & $mask) === (ord($net[$full]) & $mask)) return true;
}
return false;
}
// The visitor's address, or null when none can be vouched for.
function silentshield_observer_visitor_ip() {
$peer = silentshield_observer_canonical_ip($_SERVER["REMOTE_ADDR"] ?? "");
if (filter_var($peer, FILTER_VALIDATE_IP) === false) return null;
if (count(SS_TRUSTED_PROXIES) === 0) return SS_DIRECT_CONNECTION ? $peer : null;
if (!silentshield_observer_is_trusted($peer)) return $peer; // not your proxy: the peer is the visitor
$hops = explode(",", (string) ($_SERVER["HTTP_X_FORWARDED_FOR"] ?? ""));
for ($i = count($hops) - 1; $i >= 0; $i--) {
$hop = silentshield_observer_canonical_ip($hops[$i]);
if ($hop === "") continue;
if (filter_var($hop, FILTER_VALIDATE_IP) === false) return null; // garbage stops the walk
if (!silentshield_observer_is_trusted($hop)) return $hop;
}
return $peer; // only your own proxies
}
register_shutdown_function(function () use ($ss_bots) {
// Optional: skip observation for your own trusted traffic (e.g. logged-in
// users) so their visits are never reported. Plug in your own session check.
// if (!empty($_SESSION["user_id"])) return;
$ua = $_SERVER["HTTP_USER_AGENT"] ?? "";
$signed = !empty($_SERVER["HTTP_SIGNATURE"]);
$isBot = $signed;
foreach ($ss_bots as $b) { if (stripos($ua, $b) !== false) { $isBot = true; break; } }
if (!$isBot) return;
if (function_exists("fastcgi_finish_request")) { fastcgi_finish_request(); }
$sighting = [
"ua" => $ua,
// Query strings are stripped here for data minimization. If you enabled
// "Capture query strings" for this key in the SilentShield dashboard,
// send the full URI instead: "path" => $_SERVER["REQUEST_URI"] ?? "/",
// With the PHP SDK (forge12interactive/silentshield-sdk 1.5.0+) the option
// 'send_full_uri' => true does this for you.
"path" => strtok($_SERVER["REQUEST_URI"] ?? "/", "?"),
"method" => $_SERVER["REQUEST_METHOD"] ?? "GET",
];
$ip = silentshield_observer_visitor_ip();
if ($ip !== null) { $sighting["ip"] = $ip; } // none: not sent (see SS_TRUSTED_PROXIES)
$ch = curl_init(SS_OBSERVE_URL);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 3,
CURLOPT_HTTPHEADER => ["Content-Type: application/json", "x-api-key: " . SS_API_KEY],
CURLOPT_POSTFIELDS => json_encode(["sightings" => [$sighting]]),
]);
curl_exec($ch); // best-effort, fail-open
curl_close($ch);
});Go
몇 줄로 끝나는 독립형 옵저버입니다 — 표준 라이브러리만 사용, SDK 불필요. 감지는 fire-and-forget 방식으로 전송되므로 어떤 요청도 느려지지 않습니다:
// Self-contained observer — stdlib only, no SDK required.
// Reports AI-agent sightings fire-and-forget: never blocks a request,
// fail-open on any error. For the always-fresh bot list, cache
// https://api.silentshield.io/api/v1/agent/bot-directory daily.
// OBSERVE ONLY: reports visits, never blocks. Blocking (403) needs the
// separate enforce component (Stage 2).
const observeURL = "https://api.silentshield.io/api/v1/agent/telemetry"
const siteKey = "YOUR_API_KEY" // publishable — or os.Getenv("SILENTSHIELD_SITE_KEY")
var bots = []string{"GPTBot", "OAI-SearchBot", "ChatGPT-User", "ClaudeBot",
"Claude-User", "PerplexityBot", "Perplexity-User", "Bingbot", "Applebot",
"Amazonbot", "CCBot", "Bytespider", "meta-externalagent", "Google-Agent"}
// Where the visitor's address comes from. SilentShield confirms an agent by
// its address (published ranges), so it must be one your own infrastructure
// vouches for. Behind a proxy r.RemoteAddr is the proxy, and anyone can send
// X-Forwarded-For: its LEFT-most entry is written by the client and is never
// used. Set ONE of:
// - trustedProxies: your reverse proxies (CIDRs or bare IPs, e.g. nginx on
// "127.0.0.1", plus Cloudflare's ranges if it sits in front). Behind one of
// them, X-Forwarded-For is read from the RIGHT; the first address that is
// not one of them is the visitor.
// - directConnection = true: no proxy in front, r.RemoteAddr IS the visitor.
// Neither set: no address is sent. Visits are still reported, and signed
// agents are still confirmed; an unsigned agent is then neither confirmed nor
// flagged as spoofed.
var trustedProxies = []string{} // e.g. {"127.0.0.1", "10.0.0.0/8"}
var directConnection = false
var trustedNets = parseTrustedProxies(trustedProxies)
// parseTrustedProxies accepts CIDRs and bare IPs; unparsable entries are dropped.
func parseTrustedProxies(entries []string) []*net.IPNet {
var nets []*net.IPNet
for _, entry := range entries {
entry = strings.TrimSpace(entry)
if !strings.Contains(entry, "/") {
if ip := canonicalIP(entry); ip != nil {
bits := len(ip) * 8
nets = append(nets, &net.IPNet{IP: ip, Mask: net.CIDRMask(bits, bits)})
}
continue
}
if _, n, err := net.ParseCIDR(entry); err == nil {
nets = append(nets, n)
}
}
return nets
}
// canonicalIP parses an address; ::ffff:a.b.c.d becomes the IPv4 a.b.c.d.
func canonicalIP(s string) net.IP {
ip := net.ParseIP(strings.TrimSpace(s))
if v4 := ip.To4(); v4 != nil {
return v4
}
return ip
}
func isTrusted(ip net.IP) bool {
for _, n := range trustedNets {
if n.Contains(ip) {
return true
}
}
return false
}
// visitorIP returns the visitor's address, or "" when none can be vouched for.
func visitorIP(r *http.Request) string {
host, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
host = r.RemoteAddr
}
peer := canonicalIP(host)
if peer == nil {
return ""
}
if len(trustedNets) == 0 {
if directConnection {
return peer.String()
}
return ""
}
if !isTrusted(peer) {
return peer.String() // not your proxy: the peer is the visitor
}
hops := strings.Split(r.Header.Get("X-Forwarded-For"), ",")
for i := len(hops) - 1; i >= 0; i-- {
if strings.TrimSpace(hops[i]) == "" {
continue
}
hop := canonicalIP(hops[i])
if hop == nil {
return "" // garbage stops the walk
}
if !isTrusted(hop) {
return hop.String()
}
}
return peer.String() // only your own proxies
}
func observe(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Optional: skip observation for your own trusted traffic (e.g.
// logged-in users) so their visits are never reported. Plug in your
// own check — keep it cheap (inspect a session cookie / JWT), no I/O.
// if isLoggedIn(r) { next.ServeHTTP(w, r); return }
ua, signed := r.UserAgent(), r.Header.Get("Signature") != ""
hit := signed
for _, b := range bots {
if strings.Contains(strings.ToLower(ua), strings.ToLower(b)) {
hit = true
break
}
}
if hit {
// r.URL.Path strips the query for data minimization. If you enabled
// "Capture query strings" for this key in the dashboard, use
// r.URL.RequestURI() instead of r.URL.Path to send the full path.
// With the Go SDK (github.com/forge12interactive/silentshield-go
// 1.6.0+) the option WithSendFullURI(true) does this for you.
s := map[string]any{"ua": ua, "path": r.URL.Path, "method": r.Method}
if ip := visitorIP(r); ip != "" { // none: not sent (see trustedProxies)
s["ip"] = ip
}
if signed { // Web Bot Auth (RFC 9421) — forward for verification
s["signature"] = r.Header.Get("Signature")
s["signature_input"] = r.Header.Get("Signature-Input")
s["signature_agent"] = r.Header.Get("Signature-Agent")
s["authority"] = r.Host
}
body, _ := json.Marshal(map[string]any{"sightings": []any{s}})
go func() { // best-effort, fail-open
req, _ := http.NewRequest("POST", observeURL, bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-api-key", siteKey)
if resp, err := (&http.Client{Timeout: 3 * time.Second}).Do(req); err == nil {
resp.Body.Close()
}
}()
}
next.ServeHTTP(w, r)
})
}
// net/http: http.ListenAndServe(":8080", observe(mux))
// Gin: srv := &http.Server{Addr: ":8080", Handler: observe(r)}
// srv.ListenAndServe()프록시 뒤에서의 방문자 주소
두 가지 검사에는 실제 방문자 주소가 필요합니다. 공개된 IP 범위로 크롤러를 확인하는 것과, 잘 알려진 이름만 빌린 위장(spoof)을 알아보는 것입니다. 리버스 프록시, 로드 밸런서 또는 CDN 뒤에서는 서버에 프록시의 주소만 보입니다. X-Forwarded-For 헤더만으로는 아무것도 증명되지 않습니다. 왼쪽 부분은 발신자가 직접 쓰기 때문입니다. 그래서 템플릿은 지정하신 프록시를 거친 경우에만 방문자 주소를 받아들입니다.
SS_TRUSTED_PROXIES(WordPress, PHP) ·TRUSTED_PROXIES(Next.js, Node) ·trustedProxies(Go)- 일반적인 경우: 서버 앞에 리버스 프록시, 로드 밸런서 또는 CDN이 있습니다. 그 주소나 범위를 입력하십시오(예: 127.0.0.1 또는 10.0.0.0/8). 템플릿은 X-Forwarded-For를 오른쪽부터 읽고 귀하의 프록시에 속하지 않는 첫 번째 주소를 사용합니다.
CLIENT_IP_HEADER(Next.js)- Next.js 전용: 호스팅 플랫폼이 방문자 주소를 자체 헤더에 기록하는 경우입니다(예: Vercel의 x-real-ip, Cloudflare의 cf-connecting-ip). 플랫폼이 설정하고 방문자가 보낸 값을 덮어쓰는 헤더만 지정하십시오.
SS_DIRECT_CONNECTION(WordPress, PHP) ·DIRECT_CONNECTION(Node) ·directConnection(Go)- 서버 앞에 아무것도 없고 방문자가 직접 연결하는 경우에만: 그때는 연결 상대의 주소가 방문자입니다.
설정이 없으면 템플릿은 방문자 주소를 보내지 않습니다. 방문은 계속 기록되지만 IP 범위로 확인하거나 위장으로 표시할 수 없습니다.
이전 버전의 템플릿을 복사하셨습니까? 다시 복사하고 설정 중 하나를 지정하십시오. 서버에 프록시 없이 접근할 수 있다면 직접 연결을 설정하십시오. 그렇지 않으면 업데이트 후 IP 범위를 통한 확인이 중단됩니다.
연결 테스트
통합이 작동하는지 확인하려고 첫 번째 실제 AI 크롤러를 기다릴 필요가 없습니다. 빈 배치를 보내 보세요 — 가짜 방문 기록을 남기지 않으면서 키에 하트비트를 등록합니다:
curl -X POST https://api.silentshield.io/api/v1/agent/telemetry \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
--data '{"sightings":[]}'그러면 API 키의 에이전트 허브(API 키 → 키 선택 → 에이전트)가 "연결되지 않음"에서 "연결됨 — 수신 대기 중"으로 바뀝니다. 실제 에이전트가 방문할 때까지 리포트는 비어 있습니다: SilentShield는 데이터를 지어내지 않습니다.
GDPR
관찰은 정당한 이익(GDPR Art. 6(1)(f))에 근거합니다. IP 주소는 매일 바뀌는 솔트로 서버 측에서 해시되며 — 원본 IP는 절대 저장되지 않습니다. 방문 기록은 14일간 보관되고, 알려진 AI 에이전트의 요청만 저장됩니다: 일반 방문자 트래픽은 절대 기록되지 않습니다.
FAQ
사이트가 느려지나요?
아니요. 모든 통합은 fire-and-forget 방식입니다: Next.js는 event.waitUntil()을 사용하고, PHP는 응답 전송 후에만 보고하며, Node와 Go는 백그라운드에서 전송합니다. SilentShield API에 연결할 수 없더라도 사이트에는 영향이 없습니다 — 모든 것이 fail-open으로 동작합니다.
무엇이 AI 에이전트로 집계되나요?
SilentShield의 알려진 AI 크롤러·에이전트 봇 디렉터리(GPTBot, ClaudeBot, PerplexityBot 등)와 일치하거나 Web Bot Auth 서명이 있는 요청만 해당합니다. 항상 최신 목록은 https://api.silentshield.io/api/v1/agent/bot-directory 에서 확인할 수 있습니다.
왜 아직 데이터가 보이지 않나요?
AI 크롤러는 자체 일정에 따라 방문합니다. 대부분의 사이트에서는 24–72시간 안에 첫 방문 기록이 나타나며, 작은 사이트는 더 오래 걸릴 수 있습니다. 그동안에는 에이전트 허브의 하트비트가 통합 자체가 작동하고 있음을 확인해 줍니다.
개요 및 이점: AI 크롤러와 에이전트 제어 →