TorLens is a comprehensive library for querying, analyzing, and monitoring Tor network nodes.TorLens provides developers with fine-grained access to detailed information about Tor relays and bridges.
For a live, visual exploration of the Tor network, visit our companion web platform:
Peel the Net is a real-time web platform that visualizes and documents every active Tor node with detailed public metadata. From entry guards to exit relays, Peel the Net helps you peel back the layers of the Tor network and explore its architecture in depth.
Features:
Repository: GitHub - 0xPratikPatil/peel-the-net Dataset: Tor Node Dataset
npm install torlens
import { TorLens } from 'torlens';
// Create a new TorLens instance
const torLens = new TorLens();
// Basic search
async function searchNodes() {
const results = await torLens.search('exit');
console.log(`Found ${results.relays.length} relays`);
}
// Get a specific relay by fingerprint
async function getRelay() {
const relay = await torLens.getRelayByFingerprint('000F3EB75342BE371F1D8D3FAE90890AEB5664EE');
console.log(relay?.nickname);
}
// Get relays by country
async function getRelaysByCountry() {
const relays = await torLens.getRelaysByCountry('us');
console.log(`Found ${relays.length} relays in the US`);
}
// Get relays with specific flags
async function getGuardRelays() {
const relays = await torLens.getRelaysByFlags(['Guard', 'Fast']);
console.log(`Found ${relays.length} relays with Guard and Fast flags`);
}
// Find relays that allow specific ports
async function findRelaysWithPort() {
const relays = await torLens.getRelaysByPort(80);
console.log(`Found ${relays.length} relays that allow port 80`);
}
// Find relays by AS number
async function findRelaysByAS() {
const relays = await torLens.getRelaysByAS('399820');
console.log(`Found ${relays.length} relays with AS number 399820`);
}
// Find top relays by consensus weight
async function findTopRelays() {
const relays = await torLens.getTopRelaysByWeight(5);
console.log('Top 5 relays by consensus weight:');
relays.forEach(relay => {
console.log(`${relay.nickname}: ${relay.consensus_weight}`);
});
}
// Find relays by OR address
async function findRelaysByORAddress() {
const relays = await torLens.getRelaysByORAddress('204.137.14.106');
console.log(`Found ${relays.length} relays with the specified OR address`);
}
// Find relays by exit address
async function findRelaysByExitAddress() {
const relays = await torLens.getRelaysByExitAddress('204.137.14.106');
console.log(`Found ${relays.length} relays with the specified exit address`);
}
// Find relays by hostname
async function findRelaysByHostname() {
const relays = await torLens.getRelaysByHostname('atomicnetworks.co');
console.log(`Found ${relays.length} relays with the specified hostname`);
}
// Advanced search with multiple parameters
async function advancedSearch() {
const results = await torLens.advancedSearch({
running: 'true',
country: 'us',
flag: 'Guard'
});
console.log(`Found ${results.relays.length} relays`);
}
search(searchTerm?: string): Promise<TorDetails>
- Search for Tor nodesadvancedSearch(params: Record<string, string>): Promise<TorDetails>
- Advanced search with multiple parametersgetRelayByFingerprint(fingerprint: string): Promise<TorRelay | undefined>
- Get relay by fingerprintgetRelaysByNickname(nickname: string): Promise<TorRelay[]>
- Get relays by nicknamegetRelaysByORAddress(orAddress: string): Promise<TorRelay[]>
- Get relays by OR addressgetRelaysByExitAddress(exitAddress: string): Promise<TorRelay[]>
- Get relays by exit addressgetRelaysByHostname(hostname: string): Promise<TorRelay[]>
- Get relays by hostname (verified or unverified)getRelaysByVerifiedHostname(hostname: string): Promise<TorRelay[]>
- Get relays by verified hostnamegetRelaysByUnverifiedHostname(hostname: string): Promise<TorRelay[]>
- Get relays by unverified hostnamegetRelaysByCountry(countryCode: string): Promise<TorRelay[]>
- Get relays by country codegetRelaysByAS(asNumber: string): Promise<TorRelay[]>
- Get relays by AS numbergetRelaysByASName(asName: string): Promise<TorRelay[]>
- Get relays by AS namegetRelaysByPlatform(platform: string): Promise<TorRelay[]>
- Get relays by platformgetRelaysByVersion(version: string): Promise<TorRelay[]>
- Get relays by Tor versiongetRelaysByVersionStatus(status: string): Promise<TorRelay[]>
- Get relays by version statusgetRelaysByMinBandwidth(minBandwidth: number): Promise<TorRelay[]>
- Get relays by minimum bandwidthgetRelaysByContact(contactInfo: string): Promise<TorRelay[]>
- Get relays by contact informationgetRelaysByPort(port: number): Promise<TorRelay[]>
- Get relays that allow a specific portgetTopRelaysByWeight(limit?: number): Promise<TorRelay[]>
- Get top relays by consensus weightgetRelaysByMinRunTime(minDays: number): Promise<TorRelay[]>
- Get relays running for at least the specified durationgetRelaysByFlags(flags: string[]): Promise<TorRelay[]>
- Get relays with specific flagsgetAllBridges(): Promise<TorBridge[]>
- Get all bridgesgetBridgeByFingerprint(fingerprint: string): Promise<TorBridge | undefined>
- Get bridge by fingerprintgetBridgesByTransport(transport: string): Promise<TorBridge[]>
- Get bridges by transport typeContributions are welcome! Feel free to open issues or submit pull requests.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)Distributed under the MIT License. See LICENSE
for more information.