Παρακολούθηση πρακτόρων AI
Οι AI crawlers — από το GPTBot και το ClaudeBot έως το PerplexityBot — διαβάζουν τον ιστότοπό σας καθημερινά, και οι περισσότεροι ιδιοκτήτες ιστότοπων δεν το βλέπουν ποτέ. Η λειτουργία παρατήρησης είναι το στάδιο 1 του Ελέγχου πρακτόρων AI του SilentShield: καταγράφει ποιες υπηρεσίες AI επισκέπτονται ποιες σελίδες, χωρίς να μπλοκάρει τίποτα και χωρίς να αλλάζει τη συμπεριφορά του ιστότοπού σας.
Η ορατότητα προηγείται του ελέγχου: μόνο όταν γνωρίζετε ποιος διαβάζει το περιεχόμενό σας μπορείτε να αποφασίσετε ουσιαστικά ποιον θα επιτρέψετε, θα περιορίσετε ή θα μπλοκάρετε. Κάθε καταγραφή κατατάσσεται γι' αυτό σε μία από τρεις κατηγορίες:
Αυτό μόνο παρατηρεί — δεν αποκλείει ποτέ
Τα αποσπάσματα σε αυτή τη σελίδα λειτουργούν με τη λογική «fire-and-forget»: αναφέρουν ποιοι AI agents επισκέπτονται και δεν αλλάζουν ποτέ την απόκριση. Η ρύθμιση ενός κανόνα σε "Block" στον πίνακα ελέγχου δεν τίθεται σε ισχύ μόνο με αυτό το απόσπασμα. Ο πραγματικός αποκλεισμός (ένα 403 για μη επιτρεπόμενα bots) απαιτεί το ξεχωριστό στοιχείο επιβολής — στάδιο 2 — που εκτελείται στον διακομιστή σας.
- Εκπαίδευση
- Ο crawler συλλέγει το περιεχόμενό σας για να εκπαιδεύσει μελλοντικά μοντέλα AI (π.χ. GPTBot, ClaudeBot, CCBot).
- Αναζήτηση AI
- Η υπηρεσία διαβάζει σελίδες για να απαντήσει σε ερωτήσεις χρηστών και μπορεί να αναφέρει τον ιστότοπό σας ως πηγή (π.χ. OAI-SearchBot, PerplexityBot).
- Πράκτορες
- Ένα bot ενεργεί σε πραγματικό χρόνο για λογαριασμό ενός συγκεκριμένου χρήστη, για παράδειγμα ερευνά ένα προϊόν ή συμπληρώνει μια φόρμα στον ιστότοπό σας (π.χ. ChatGPT-User, Claude-User).
Ρύθμιση ανά πλατφόρμα
WordPress
Ο ενσωματωμένος observer έρχεται με μια επερχόμενη ενημέρωση του πρόσθετου SilentShield. Μέχρι τότε, ενεργοποιήστε την παρακολούθηση με ένα μικρό must-use πρόσθετο — ένα αρχείο, χωρίς ρυθμίσεις:
Δημιουργήστε το αρχείο wp-content/mu-plugins/silentshield-observer.php με αυτό το περιεχόμενο (τα mu-plugins φορτώνονται αυτόματα· διαγράψτε το αρχείο για απενεργοποίηση):
<?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
Ένα αυτόνομο middleware — χωρίς 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 middleware. Αναφέρει μόνο αιτήματα των οποίων ο 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, συμπεριλάβετε αυτόν τον παρατηρητή στην κορυφή του front controller σας. Στέλνει την καταγραφή μόνο αφού έχει παραδοθεί η απόκριση (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
Ένας αυτόνομος observer σε λίγες γραμμές — μόνο η τυπική βιβλιοθήκη, χωρίς 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: η πλατφόρμα φιλοξενίας σας γράφει τη διεύθυνση του επισκέπτη σε δική της κεφαλίδα, για παράδειγμα x-real-ip στη Vercel ή cf-connecting-ip στο Cloudflare. Δηλώστε κεφαλίδα μόνο αν την ορίζει η πλατφόρμα και αντικαθιστά κάθε τιμή που στέλνει ο επισκέπτης.
SS_DIRECT_CONNECTION(WordPress, PHP) ·DIRECT_CONNECTION(Node) ·directConnection(Go)- Μόνο αν δεν υπάρχει τίποτα μπροστά από τον διακομιστή σας και οι επισκέπτες συνδέονται απευθείας: η διεύθυνση της σύνδεσης είναι τότε ο επισκέπτης.
Χωρίς ρύθμιση, το πρότυπο δεν στέλνει διεύθυνση επισκέπτη. Οι επισκέψεις καταγράφονται κανονικά, αλλά δεν μπορούν ούτε να επιβεβαιωθούν μέσω περιοχής IP ούτε να εμφανιστούν ως πλαστές.
Αντιγράψατε παλαιότερη έκδοση ενός προτύπου; Αντιγράψτε το ξανά και ορίστε μία από τις ρυθμίσεις. Αν ο διακομιστής σας είναι προσβάσιμος χωρίς διακομιστή μεσολάβησης, ορίστε την άμεση σύνδεση· διαφορετικά, μετά την ενημέρωση η επιβεβαίωση μέσω περιοχής IP σταματά.
Δοκιμή σύνδεσης
Δεν χρειάζεται να περιμένετε τον πρώτο πραγματικό AI crawler για να επιβεβαιώσετε ότι η ενσωμάτωσή σας λειτουργεί. Στείλτε ένα κενό batch — καταχωρίζει ένα heartbeat για το κλειδί σας χωρίς να γράφει ψεύτικες καταγραφές:
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)
Η παρατήρηση βασίζεται στο έννομο συμφέρον (Άρθρο 6 παρ. 1 στοιχ. στ΄ ΓΚΠΔ). Οι διευθύνσεις IP κατακερματίζονται από την πλευρά του διακομιστή με ένα salt που εναλλάσσεται καθημερινά — οι ακατέργαστες IP δεν αποθηκεύονται ποτέ. Οι καταγραφές διατηρούνται για 14 ημέρες, και αποθηκεύονται αποκλειστικά αιτήματα από γνωστούς πράκτορες AI: η κανονική επισκεψιμότητα των επισκεπτών σας δεν καταγράφεται ποτέ.
FAQ
Επιβραδύνει τον ιστότοπό μου;
Όχι. Κάθε ενσωμάτωση είναι fire-and-forget: το Next.js χρησιμοποιεί το event.waitUntil(), η PHP αναφέρει μόνο μετά την αποστολή της απόκρισης, το Node και το Go στέλνουν στο παρασκήνιο. Και αν το API του SilentShield δεν είναι κάποια στιγμή προσβάσιμο, ο ιστότοπός σας δεν επηρεάζεται — όλα λειτουργούν fail-open.
Τι μετράει ως πράκτορας AI;
Μόνο αιτήματα που αντιστοιχούν στον κατάλογο bots του SilentShield με γνωστούς AI crawlers και πράκτορες (GPTBot, ClaudeBot, PerplexityBot, …) ή που φέρουν υπογραφή Web Bot Auth. Η πάντα ενημερωμένη λίστα είναι διαθέσιμη στο https://api.silentshield.io/api/v1/agent/bot-directory.
Γιατί δεν βλέπω ακόμη δεδομένα;
Οι AI crawlers έρχονται με το δικό τους πρόγραμμα. Στους περισσότερους ιστότοπους οι πρώτες καταγραφές εμφανίζονται εντός 24–72 ωρών· σε μικρότερους ιστότοπους μπορεί να χρειαστεί περισσότερος χρόνος. Στο μεταξύ, το heartbeat στο κέντρο πρακτόρων σας επιβεβαιώνει ότι η ίδια η ενσωμάτωση λειτουργεί.
Επόμενο: επιβολή κανόνων πρακτόρων (στάδιο 2) →
Επισκόπηση και οφέλη: Έλεγχος crawlers και πρακτόρων AI →