recker 1.0.15-next.0e216c0 → 1.0.15-next.0eabd39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/ai/providers/anthropic.d.ts.map +1 -1
- package/dist/ai/providers/anthropic.js +4 -1
- package/dist/ai/providers/base.d.ts.map +1 -1
- package/dist/ai/providers/base.js +7 -2
- package/dist/ai/rate-limiter.d.ts.map +1 -1
- package/dist/ai/rate-limiter.js +4 -1
- package/dist/bench/generator.d.ts.map +1 -1
- package/dist/bench/generator.js +7 -3
- package/dist/bench/stats.d.ts.map +1 -1
- package/dist/bench/stats.js +43 -10
- package/dist/cache/memory-storage.d.ts.map +1 -1
- package/dist/cache/memory-storage.js +3 -2
- package/dist/cli/handler.js +14 -14
- package/dist/cli/index.js +582 -49
- package/dist/cli/presets.js +5 -5
- package/dist/cli/tui/ai-chat.js +10 -10
- package/dist/cli/tui/load-dashboard.d.ts.map +1 -1
- package/dist/cli/tui/load-dashboard.js +96 -55
- package/dist/cli/tui/scroll-buffer.d.ts +1 -1
- package/dist/cli/tui/scroll-buffer.d.ts.map +1 -1
- package/dist/cli/tui/scroll-buffer.js +2 -2
- package/dist/cli/tui/shell.d.ts +3 -0
- package/dist/cli/tui/shell.d.ts.map +1 -1
- package/dist/cli/tui/shell.js +202 -14
- package/dist/cli/tui/websocket.js +17 -17
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +18 -26
- package/dist/core/errors.d.ts +109 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +214 -1
- package/dist/core/request-promise.d.ts.map +1 -1
- package/dist/core/request-promise.js +5 -6
- package/dist/core/response.d.ts.map +1 -1
- package/dist/core/response.js +5 -6
- package/dist/dns/propagation.d.ts +3 -1
- package/dist/dns/propagation.d.ts.map +1 -1
- package/dist/dns/propagation.js +99 -59
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +10 -11
- package/dist/mcp/embeddings-loader.d.ts.map +1 -1
- package/dist/mcp/embeddings-loader.js +12 -2
- package/dist/mcp/geoip-loader.d.ts +11 -0
- package/dist/mcp/geoip-loader.d.ts.map +1 -0
- package/dist/mcp/geoip-loader.js +107 -0
- package/dist/mcp/ip-intel.d.ts +28 -0
- package/dist/mcp/ip-intel.d.ts.map +1 -0
- package/dist/mcp/ip-intel.js +209 -0
- package/dist/mcp/search/hybrid-search.d.ts.map +1 -1
- package/dist/mcp/search/hybrid-search.js +5 -1
- package/dist/mcp/search/math.d.ts.map +1 -1
- package/dist/mcp/search/math.js +5 -1
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +114 -1
- package/dist/plugins/compression.js +4 -2
- package/dist/plugins/har-player.d.ts.map +1 -1
- package/dist/plugins/har-player.js +8 -11
- package/dist/plugins/odata.d.ts.map +1 -1
- package/dist/plugins/odata.js +5 -2
- package/dist/protocols/ftp.d.ts.map +1 -1
- package/dist/protocols/ftp.js +69 -16
- package/dist/protocols/sftp.d.ts.map +1 -1
- package/dist/protocols/sftp.js +13 -3
- package/dist/protocols/telnet.d.ts.map +1 -1
- package/dist/protocols/telnet.js +25 -6
- package/dist/transport/base-udp.d.ts.map +1 -1
- package/dist/transport/base-udp.js +7 -4
- package/dist/transport/udp-response.d.ts.map +1 -1
- package/dist/transport/udp-response.js +10 -3
- package/dist/transport/udp.d.ts.map +1 -1
- package/dist/transport/udp.js +5 -1
- package/dist/transport/undici.d.ts.map +1 -1
- package/dist/transport/undici.js +75 -63
- package/dist/utils/agent-manager.d.ts +1 -0
- package/dist/utils/agent-manager.d.ts.map +1 -1
- package/dist/utils/agent-manager.js +11 -0
- package/dist/utils/client-pool.d.ts.map +1 -1
- package/dist/utils/client-pool.js +4 -1
- package/dist/utils/dns-toolkit.d.ts +88 -1
- package/dist/utils/dns-toolkit.d.ts.map +1 -1
- package/dist/utils/dns-toolkit.js +704 -6
- package/dist/utils/doh.d.ts.map +1 -1
- package/dist/utils/doh.js +13 -16
- package/dist/utils/download.d.ts.map +1 -1
- package/dist/utils/download.js +10 -11
- package/dist/utils/rdap.d.ts +9 -0
- package/dist/utils/rdap.d.ts.map +1 -1
- package/dist/utils/rdap.js +78 -9
- package/dist/utils/security-grader.d.ts +47 -0
- package/dist/utils/security-grader.d.ts.map +1 -0
- package/dist/utils/security-grader.js +637 -0
- package/dist/utils/sparkline.d.ts +18 -0
- package/dist/utils/sparkline.d.ts.map +1 -0
- package/dist/utils/sparkline.js +55 -0
- package/dist/utils/sse.d.ts.map +1 -1
- package/dist/utils/sse.js +5 -6
- package/dist/utils/system-metrics.d.ts +26 -0
- package/dist/utils/system-metrics.d.ts.map +1 -0
- package/dist/utils/system-metrics.js +81 -0
- package/dist/webrtc/index.d.ts.map +1 -1
- package/dist/webrtc/index.js +21 -7
- package/dist/websocket/client.d.ts.map +1 -1
- package/dist/websocket/client.js +13 -16
- package/package.json +3 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
+
import { DownloadError } from '../core/errors.js';
|
|
4
5
|
function getPackageVersionFromPkg() {
|
|
5
6
|
try {
|
|
6
7
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -78,14 +79,23 @@ export async function downloadEmbeddings(version) {
|
|
|
78
79
|
try {
|
|
79
80
|
const response = await fetch(url);
|
|
80
81
|
if (!response.ok) {
|
|
81
|
-
throw new
|
|
82
|
+
throw new DownloadError(`Failed to download embeddings: ${response.status} ${response.statusText}`, {
|
|
83
|
+
url,
|
|
84
|
+
statusCode: response.status,
|
|
85
|
+
retriable: response.status >= 500,
|
|
86
|
+
});
|
|
82
87
|
}
|
|
83
88
|
const data = await response.json();
|
|
84
89
|
saveLocalEmbeddings(data, ver);
|
|
85
90
|
return data;
|
|
86
91
|
}
|
|
87
92
|
catch (error) {
|
|
88
|
-
|
|
93
|
+
if (error instanceof DownloadError)
|
|
94
|
+
throw error;
|
|
95
|
+
throw new DownloadError(`Failed to download embeddings from ${url}: ${error}`, {
|
|
96
|
+
url,
|
|
97
|
+
retriable: true,
|
|
98
|
+
});
|
|
89
99
|
}
|
|
90
100
|
}
|
|
91
101
|
export async function loadBundledEmbeddings() {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function getGeoIPDatabasePath(): string;
|
|
2
|
+
export declare function hasLocalGeoIPDatabase(): boolean;
|
|
3
|
+
export declare function downloadGeoIPDatabase(): Promise<string>;
|
|
4
|
+
export interface LoadGeoIPOptions {
|
|
5
|
+
forceDownload?: boolean;
|
|
6
|
+
offline?: boolean;
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function ensureGeoIPDatabase(options?: LoadGeoIPOptions): Promise<string | null>;
|
|
10
|
+
export declare function clearGeoIPCache(): void;
|
|
11
|
+
//# sourceMappingURL=geoip-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geoip-loader.d.ts","sourceRoot":"","sources":["../../src/mcp/geoip-loader.ts"],"names":[],"mappings":"AA4CA,wBAAgB,oBAAoB,IAAI,MAAM,CAG7C;AAKD,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAKD,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,CAiD7D;AAED,MAAM,WAAW,gBAAgB;IAE/B,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAuBD,wBAAsB,mBAAmB,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoChG;AAKD,wBAAgB,eAAe,IAAI,IAAI,CAUtC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, createWriteStream, unlinkSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { createGunzip } from 'zlib';
|
|
5
|
+
import { pipeline } from 'stream/promises';
|
|
6
|
+
import { Readable } from 'stream';
|
|
7
|
+
import { DownloadError } from '../core/errors.js';
|
|
8
|
+
const GEOLITE2_CDN_URL = 'https://cdn.jsdelivr.net/npm/geolite2-city/GeoLite2-City.mmdb.gz';
|
|
9
|
+
const DB_FILENAME = 'GeoLite2-City.mmdb';
|
|
10
|
+
function getCacheDir() {
|
|
11
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
12
|
+
if (homeDir) {
|
|
13
|
+
return join(homeDir, '.cache', 'recker');
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
return join(__dirname, '..', '..', 'node_modules', '.cache', 'recker');
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return join(process.cwd(), 'node_modules', '.cache', 'recker');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function getGeoIPDatabasePath() {
|
|
24
|
+
const cacheDir = getCacheDir();
|
|
25
|
+
return join(cacheDir, DB_FILENAME);
|
|
26
|
+
}
|
|
27
|
+
export function hasLocalGeoIPDatabase() {
|
|
28
|
+
return existsSync(getGeoIPDatabasePath());
|
|
29
|
+
}
|
|
30
|
+
export async function downloadGeoIPDatabase() {
|
|
31
|
+
const dbPath = getGeoIPDatabasePath();
|
|
32
|
+
const cacheDir = dirname(dbPath);
|
|
33
|
+
if (!existsSync(cacheDir)) {
|
|
34
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const response = await fetch(GEOLITE2_CDN_URL);
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
throw new DownloadError(`Failed to download GeoLite2 database: ${response.status} ${response.statusText}`, {
|
|
40
|
+
url: GEOLITE2_CDN_URL,
|
|
41
|
+
statusCode: response.status,
|
|
42
|
+
retriable: response.status >= 500,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (!response.body) {
|
|
46
|
+
throw new DownloadError('No response body received', {
|
|
47
|
+
url: GEOLITE2_CDN_URL,
|
|
48
|
+
retriable: true,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const tempPath = dbPath + '.tmp';
|
|
52
|
+
const gunzip = createGunzip();
|
|
53
|
+
const writeStream = createWriteStream(tempPath);
|
|
54
|
+
const nodeStream = Readable.fromWeb(response.body);
|
|
55
|
+
await pipeline(nodeStream, gunzip, writeStream);
|
|
56
|
+
const fs = await import('fs/promises');
|
|
57
|
+
await fs.rename(tempPath, dbPath);
|
|
58
|
+
return dbPath;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error instanceof DownloadError)
|
|
62
|
+
throw error;
|
|
63
|
+
throw new DownloadError(`Failed to download GeoLite2 database: ${error}`, {
|
|
64
|
+
url: GEOLITE2_CDN_URL,
|
|
65
|
+
retriable: true,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export async function ensureGeoIPDatabase(options = {}) {
|
|
70
|
+
const { forceDownload = false, offline = false, debug = false } = options;
|
|
71
|
+
const log = (msg) => {
|
|
72
|
+
if (debug)
|
|
73
|
+
console.log(`[geoip-loader] ${msg}`);
|
|
74
|
+
};
|
|
75
|
+
const dbPath = getGeoIPDatabasePath();
|
|
76
|
+
if (!forceDownload && hasLocalGeoIPDatabase()) {
|
|
77
|
+
log(`Using cached database: ${dbPath}`);
|
|
78
|
+
return dbPath;
|
|
79
|
+
}
|
|
80
|
+
if (!offline) {
|
|
81
|
+
try {
|
|
82
|
+
log('Downloading GeoLite2-City database...');
|
|
83
|
+
const downloaded = await downloadGeoIPDatabase();
|
|
84
|
+
log(`Downloaded and cached: ${downloaded}`);
|
|
85
|
+
return downloaded;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
log(`Download failed: ${error}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (hasLocalGeoIPDatabase()) {
|
|
92
|
+
log(`Using stale cached database: ${dbPath}`);
|
|
93
|
+
return dbPath;
|
|
94
|
+
}
|
|
95
|
+
log('No GeoIP database available');
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
export function clearGeoIPCache() {
|
|
99
|
+
const dbPath = getGeoIPDatabasePath();
|
|
100
|
+
try {
|
|
101
|
+
if (existsSync(dbPath)) {
|
|
102
|
+
unlinkSync(dbPath);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface IpInfo {
|
|
2
|
+
ip: string;
|
|
3
|
+
hostname?: string;
|
|
4
|
+
city?: string;
|
|
5
|
+
region?: string;
|
|
6
|
+
country?: string;
|
|
7
|
+
countryCode?: string;
|
|
8
|
+
continent?: string;
|
|
9
|
+
loc?: string;
|
|
10
|
+
org?: string;
|
|
11
|
+
asn?: number;
|
|
12
|
+
timezone?: string;
|
|
13
|
+
postal?: string;
|
|
14
|
+
accuracy?: number;
|
|
15
|
+
bogon?: boolean;
|
|
16
|
+
bogonType?: string;
|
|
17
|
+
isIPv6?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function isIPv6(ip: string): boolean;
|
|
20
|
+
export declare function isBogon(ip: string): {
|
|
21
|
+
isBogon: boolean;
|
|
22
|
+
type?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function isValidIP(ip: string): boolean;
|
|
25
|
+
export declare function getIpInfo(ip: string): Promise<IpInfo>;
|
|
26
|
+
export declare function isGeoIPAvailable(): boolean;
|
|
27
|
+
export { getGeoIPDatabasePath } from './geoip-loader.js';
|
|
28
|
+
//# sourceMappingURL=ip-intel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip-intel.d.ts","sourceRoot":"","sources":["../../src/mcp/ip-intel.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAyID,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE1C;AAKD,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAKvE;AAKD,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAoB7C;AAsCD,wBAAsB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqD3D;AAKD,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAKD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Reader } from '@maxmind/geoip2-node';
|
|
2
|
+
import { ensureGeoIPDatabase, hasLocalGeoIPDatabase } from './geoip-loader.js';
|
|
3
|
+
const IPV4_BOGON_RANGES = [
|
|
4
|
+
{ prefix: '0.', desc: 'This Network (RFC 1122)' },
|
|
5
|
+
{ prefix: '10.', desc: 'Private-Use (RFC 1918)' },
|
|
6
|
+
{ prefix: '100.64.', desc: 'Carrier-Grade NAT (RFC 6598)' },
|
|
7
|
+
{ prefix: '127.', desc: 'Loopback (RFC 1122)' },
|
|
8
|
+
{ prefix: '169.254.', desc: 'Link-Local (RFC 3927)' },
|
|
9
|
+
{ prefix: '172.16.', desc: 'Private-Use (RFC 1918)' },
|
|
10
|
+
{ prefix: '172.17.', desc: 'Private-Use (RFC 1918)' },
|
|
11
|
+
{ prefix: '172.18.', desc: 'Private-Use (RFC 1918)' },
|
|
12
|
+
{ prefix: '172.19.', desc: 'Private-Use (RFC 1918)' },
|
|
13
|
+
{ prefix: '172.20.', desc: 'Private-Use (RFC 1918)' },
|
|
14
|
+
{ prefix: '172.21.', desc: 'Private-Use (RFC 1918)' },
|
|
15
|
+
{ prefix: '172.22.', desc: 'Private-Use (RFC 1918)' },
|
|
16
|
+
{ prefix: '172.23.', desc: 'Private-Use (RFC 1918)' },
|
|
17
|
+
{ prefix: '172.24.', desc: 'Private-Use (RFC 1918)' },
|
|
18
|
+
{ prefix: '172.25.', desc: 'Private-Use (RFC 1918)' },
|
|
19
|
+
{ prefix: '172.26.', desc: 'Private-Use (RFC 1918)' },
|
|
20
|
+
{ prefix: '172.27.', desc: 'Private-Use (RFC 1918)' },
|
|
21
|
+
{ prefix: '172.28.', desc: 'Private-Use (RFC 1918)' },
|
|
22
|
+
{ prefix: '172.29.', desc: 'Private-Use (RFC 1918)' },
|
|
23
|
+
{ prefix: '172.30.', desc: 'Private-Use (RFC 1918)' },
|
|
24
|
+
{ prefix: '172.31.', desc: 'Private-Use (RFC 1918)' },
|
|
25
|
+
{ prefix: '192.0.0.', desc: 'IETF Protocol Assignments (RFC 6890)' },
|
|
26
|
+
{ prefix: '192.0.2.', desc: 'Documentation TEST-NET-1 (RFC 5737)' },
|
|
27
|
+
{ prefix: '192.88.99.', desc: '6to4 Relay Anycast (RFC 3068)' },
|
|
28
|
+
{ prefix: '192.168.', desc: 'Private-Use (RFC 1918)' },
|
|
29
|
+
{ prefix: '198.18.', desc: 'Benchmarking (RFC 2544)' },
|
|
30
|
+
{ prefix: '198.19.', desc: 'Benchmarking (RFC 2544)' },
|
|
31
|
+
{ prefix: '198.51.100.', desc: 'Documentation TEST-NET-2 (RFC 5737)' },
|
|
32
|
+
{ prefix: '203.0.113.', desc: 'Documentation TEST-NET-3 (RFC 5737)' },
|
|
33
|
+
{ prefix: '224.', desc: 'Multicast (RFC 5771)' },
|
|
34
|
+
{ prefix: '240.', desc: 'Reserved for Future Use (RFC 1112)' },
|
|
35
|
+
{ prefix: '255.255.255.255', desc: 'Limited Broadcast (RFC 919)' }
|
|
36
|
+
];
|
|
37
|
+
function checkIPv4Bogon(ip) {
|
|
38
|
+
if (ip.startsWith('100.')) {
|
|
39
|
+
const secondOctet = parseInt(ip.split('.')[1], 10);
|
|
40
|
+
if (secondOctet >= 64 && secondOctet <= 127) {
|
|
41
|
+
return { isBogon: true, type: 'Carrier-Grade NAT (RFC 6598)' };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const firstOctet = parseInt(ip.split('.')[0], 10);
|
|
45
|
+
if (firstOctet >= 224 && firstOctet <= 239) {
|
|
46
|
+
return { isBogon: true, type: 'Multicast (RFC 5771)' };
|
|
47
|
+
}
|
|
48
|
+
for (const range of IPV4_BOGON_RANGES) {
|
|
49
|
+
if (ip.startsWith(range.prefix) || ip === range.prefix.slice(0, -1)) {
|
|
50
|
+
return { isBogon: true, type: range.desc };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return { isBogon: false };
|
|
54
|
+
}
|
|
55
|
+
function normalizeIPv6(ip) {
|
|
56
|
+
const lower = ip.toLowerCase();
|
|
57
|
+
if (lower.includes('.')) {
|
|
58
|
+
if (lower.startsWith('::ffff:')) {
|
|
59
|
+
return '0000:0000:0000:0000:0000:ffff:' + lower.slice(7);
|
|
60
|
+
}
|
|
61
|
+
if (lower.startsWith('::')) {
|
|
62
|
+
return '0000:0000:0000:0000:0000:0000:' + lower.slice(2);
|
|
63
|
+
}
|
|
64
|
+
return lower;
|
|
65
|
+
}
|
|
66
|
+
const parts = lower.split(':');
|
|
67
|
+
const emptyIndex = parts.findIndex((p, i) => p === '' && parts[i + 1] === '');
|
|
68
|
+
if (emptyIndex !== -1) {
|
|
69
|
+
const nonEmptyParts = parts.filter(p => p !== '');
|
|
70
|
+
const missingParts = 8 - nonEmptyParts.length;
|
|
71
|
+
const expansion = Array(missingParts).fill('0000');
|
|
72
|
+
const before = parts.slice(0, emptyIndex).filter(p => p !== '');
|
|
73
|
+
const after = parts.slice(emptyIndex).filter(p => p !== '');
|
|
74
|
+
const expanded = [...before, ...expansion, ...after];
|
|
75
|
+
return expanded.map(p => p.padStart(4, '0')).join(':');
|
|
76
|
+
}
|
|
77
|
+
if (parts[0] === '') {
|
|
78
|
+
const nonEmpty = parts.filter(p => p !== '');
|
|
79
|
+
const padding = Array(8 - nonEmpty.length).fill('0000');
|
|
80
|
+
return [...padding, ...nonEmpty].map(p => p.padStart(4, '0')).join(':');
|
|
81
|
+
}
|
|
82
|
+
return parts.map(p => p.padStart(4, '0')).join(':');
|
|
83
|
+
}
|
|
84
|
+
function checkIPv6Bogon(ip) {
|
|
85
|
+
const normalized = normalizeIPv6(ip);
|
|
86
|
+
if (normalized === '0000:0000:0000:0000:0000:0000:0000:0000') {
|
|
87
|
+
return { isBogon: true, type: 'Unspecified Address (RFC 4291)' };
|
|
88
|
+
}
|
|
89
|
+
if (normalized === '0000:0000:0000:0000:0000:0000:0000:0001') {
|
|
90
|
+
return { isBogon: true, type: 'Loopback (RFC 4291)' };
|
|
91
|
+
}
|
|
92
|
+
if (normalized.startsWith('0000:0000:0000:0000:0000:ffff:')) {
|
|
93
|
+
return { isBogon: true, type: 'IPv4-Mapped IPv6 (RFC 4291)' };
|
|
94
|
+
}
|
|
95
|
+
if (normalized.startsWith('fe8') || normalized.startsWith('fe9') ||
|
|
96
|
+
normalized.startsWith('fea') || normalized.startsWith('feb')) {
|
|
97
|
+
return { isBogon: true, type: 'Link-Local Unicast (RFC 4291)' };
|
|
98
|
+
}
|
|
99
|
+
if (normalized.startsWith('fc') || normalized.startsWith('fd')) {
|
|
100
|
+
return { isBogon: true, type: 'Unique Local Address (RFC 4193)' };
|
|
101
|
+
}
|
|
102
|
+
if (normalized.startsWith('ff')) {
|
|
103
|
+
return { isBogon: true, type: 'Multicast (RFC 4291)' };
|
|
104
|
+
}
|
|
105
|
+
if (normalized.startsWith('2001:0db8:')) {
|
|
106
|
+
return { isBogon: true, type: 'Documentation (RFC 3849)' };
|
|
107
|
+
}
|
|
108
|
+
return { isBogon: false };
|
|
109
|
+
}
|
|
110
|
+
export function isIPv6(ip) {
|
|
111
|
+
return ip.includes(':');
|
|
112
|
+
}
|
|
113
|
+
export function isBogon(ip) {
|
|
114
|
+
if (isIPv6(ip)) {
|
|
115
|
+
return checkIPv6Bogon(ip);
|
|
116
|
+
}
|
|
117
|
+
return checkIPv4Bogon(ip);
|
|
118
|
+
}
|
|
119
|
+
export function isValidIP(ip) {
|
|
120
|
+
if (!ip.includes(':')) {
|
|
121
|
+
const parts = ip.split('.');
|
|
122
|
+
if (parts.length !== 4)
|
|
123
|
+
return false;
|
|
124
|
+
return parts.every(p => {
|
|
125
|
+
const num = parseInt(p, 10);
|
|
126
|
+
return !isNaN(num) && num >= 0 && num <= 255 && p === num.toString();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const parts = ip.split(':');
|
|
130
|
+
if (parts.length < 2 || parts.length > 8)
|
|
131
|
+
return false;
|
|
132
|
+
const emptyParts = parts.filter(p => p === '').length;
|
|
133
|
+
if (emptyParts > 1 && !(emptyParts === 2 && parts[0] === '' && parts[1] === ''))
|
|
134
|
+
return false;
|
|
135
|
+
return parts.every(p => {
|
|
136
|
+
if (p === '')
|
|
137
|
+
return true;
|
|
138
|
+
if (p.includes('.'))
|
|
139
|
+
return isValidIP(p);
|
|
140
|
+
return /^[0-9a-fA-F]{1,4}$/.test(p);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
let _reader = null;
|
|
144
|
+
async function getReader() {
|
|
145
|
+
if (_reader) {
|
|
146
|
+
return _reader;
|
|
147
|
+
}
|
|
148
|
+
const dbPath = await ensureGeoIPDatabase();
|
|
149
|
+
if (!dbPath) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
_reader = await Reader.open(dbPath);
|
|
154
|
+
return _reader;
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export async function getIpInfo(ip) {
|
|
161
|
+
const ipv6 = isIPv6(ip);
|
|
162
|
+
const bogonCheck = isBogon(ip);
|
|
163
|
+
if (bogonCheck.isBogon) {
|
|
164
|
+
return {
|
|
165
|
+
ip,
|
|
166
|
+
bogon: true,
|
|
167
|
+
bogonType: bogonCheck.type,
|
|
168
|
+
isIPv6: ipv6,
|
|
169
|
+
org: bogonCheck.type
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const reader = await getReader();
|
|
173
|
+
if (!reader) {
|
|
174
|
+
return {
|
|
175
|
+
ip,
|
|
176
|
+
isIPv6: ipv6,
|
|
177
|
+
org: 'GeoIP database not available'
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
const result = reader.city(ip);
|
|
182
|
+
return {
|
|
183
|
+
ip,
|
|
184
|
+
city: result.city?.names?.en,
|
|
185
|
+
region: result.subdivisions?.[0]?.names?.en,
|
|
186
|
+
country: result.country?.names?.en,
|
|
187
|
+
countryCode: result.country?.isoCode,
|
|
188
|
+
continent: result.continent?.names?.en,
|
|
189
|
+
loc: result.location?.latitude && result.location?.longitude
|
|
190
|
+
? `${result.location.latitude},${result.location.longitude}`
|
|
191
|
+
: undefined,
|
|
192
|
+
timezone: result.location?.timeZone,
|
|
193
|
+
postal: result.postal?.code,
|
|
194
|
+
accuracy: result.location?.accuracyRadius,
|
|
195
|
+
isIPv6: ipv6,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
return {
|
|
200
|
+
ip,
|
|
201
|
+
isIPv6: ipv6,
|
|
202
|
+
org: 'IP not found in GeoIP database'
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
export function isGeoIPAvailable() {
|
|
207
|
+
return hasLocalGeoIPDatabase();
|
|
208
|
+
}
|
|
209
|
+
export { getGeoIPDatabasePath } from './geoip-loader.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hybrid-search.d.ts","sourceRoot":"","sources":["../../../src/mcp/search/hybrid-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hybrid-search.d.ts","sourceRoot":"","sources":["../../../src/mcp/search/hybrid-search.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAGnB,MAAM,YAAY,CAAC;AAkBpB,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,IAAI,CAAoB;IAChC,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,MAAM,CAA+B;gBAEjC,MAAM,GAAE,kBAAuB;IAYrC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAmCrC,yBAAyB;IAoCjC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAsDjF,OAAO,CAAC,WAAW;IAiCnB,OAAO,CAAC,cAAc;IA8GtB,OAAO,CAAC,cAAc;IAoDtB,OAAO,CAAC,MAAM,CAAC,UAAU,CAoCtB;IAKH,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,cAAc;IAmBtB,aAAa,IAAI,OAAO;IAOxB,QAAQ,IAAI;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;IAYD,OAAO,CAAC,GAAG;CAKZ;AAKD,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,YAAY,CAE5E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Fuse from 'fuse.js';
|
|
2
2
|
import { cosineSimilarity, combineScores, levenshtein } from './math.js';
|
|
3
3
|
import { loadEmbeddings } from '../embeddings-loader.js';
|
|
4
|
+
import { StateError } from '../../core/errors.js';
|
|
4
5
|
let cachedEmbeddings = null;
|
|
5
6
|
export class HybridSearch {
|
|
6
7
|
fuse = null;
|
|
@@ -68,7 +69,10 @@ export class HybridSearch {
|
|
|
68
69
|
async search(query, options = {}) {
|
|
69
70
|
const { limit = 10, category, mode = 'hybrid', minScore = 0 } = options;
|
|
70
71
|
if (!this.initialized) {
|
|
71
|
-
throw new
|
|
72
|
+
throw new StateError('HybridSearch not initialized. Call initialize() first.', {
|
|
73
|
+
expectedState: 'initialized',
|
|
74
|
+
actualState: 'not-initialized',
|
|
75
|
+
});
|
|
72
76
|
}
|
|
73
77
|
const cleanedQuery = this.cleanQuery(query);
|
|
74
78
|
this.log(`Original query: "${query}" → Cleaned: "${cleanedQuery}"`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/mcp/search/math.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/mcp/search/math.ts"],"names":[],"mappings":"AAsBA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAwBjE;AAgBD,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAyCxD;AAeD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAI7D;AAmBD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,SAAK,GAAG,MAAM,CAEpE;AAWD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,SAAK,GAAG,MAAM,CAK5E"}
|
package/dist/mcp/search/math.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { ValidationError } from '../../core/errors.js';
|
|
1
2
|
export function cosineSimilarity(a, b) {
|
|
2
3
|
if (a.length !== b.length) {
|
|
3
|
-
throw new
|
|
4
|
+
throw new ValidationError(`Vector length mismatch: ${a.length} vs ${b.length}`, {
|
|
5
|
+
field: 'vectorLength',
|
|
6
|
+
value: { a: a.length, b: b.length },
|
|
7
|
+
});
|
|
4
8
|
}
|
|
5
9
|
if (a.length === 0) {
|
|
6
10
|
return 0;
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export declare class MCPServer {
|
|
|
51
51
|
private getCodeExamples;
|
|
52
52
|
private getApiSchema;
|
|
53
53
|
private getSuggestions;
|
|
54
|
+
private ipLookupResult;
|
|
55
|
+
private ipLookupPending;
|
|
56
|
+
private ipLookup;
|
|
57
|
+
private formatIpResult;
|
|
54
58
|
private getFeatureConfig;
|
|
55
59
|
private getCombinedConfig;
|
|
56
60
|
handleRequest(req: JsonRpcRequest): JsonRpcResponse;
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAMhB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAMhB,MAAM,YAAY,CAAC;AAIpB,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AA0CD,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,MAAM,CAAC,CAAkC;IACjD,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,eAAe,CAAwB;IAC/C,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,WAAW,CAAS;gBAEhB,OAAO,GAAE,gBAAqB;IAsB1C,OAAO,CAAC,UAAU,CAA8B;YAKlC,gBAAgB;IAO9B,OAAO,CAAC,GAAG;IAUX,OAAO,CAAC,YAAY;IAyBpB,OAAO,CAAC,gBAAgB;IAiBxB,OAAO,CAAC,WAAW;YAwBL,UAAU;YAoBV,SAAS;IAiCvB,OAAO,CAAC,iBAAiB;IA6BzB,OAAO,CAAC,gBAAgB;IAqCxB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,YAAY;IA0BpB,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,mBAAmB;IA6B3B,OAAO,CAAC,oBAAoB;IA8B5B,OAAO,CAAC,sBAAsB;IA0E9B,OAAO,CAAC,wBAAwB;IAoBhC,OAAO,CAAC,OAAO;IAyBf,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,QAAQ;IAgIhB,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,cAAc;IAsBtB,OAAO,CAAC,UAAU;IA0ElB,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,MAAM;IAmCd,OAAO,CAAC,eAAe;IAgDvB,OAAO,CAAC,YAAY;IAmEpB,OAAO,CAAC,cAAc;IAmFtB,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,eAAe,CAA8B;IAErD,OAAO,CAAC,QAAQ;IA+DhB,OAAO,CAAC,cAAc;IA6CtB,OAAO,CAAC,gBAAgB;IA+DxB,OAAO,CAAC,iBAAiB;IAuCzB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,eAAe;IA8DnD,OAAO,CAAC,gBAAgB;YAOV,UAAU;YAgCV,SAAS;YA8CT,QAAQ;IAuFhB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAe3B,OAAO,IAAI,MAAM;IAIjB,YAAY,IAAI,MAAM;IAItB,gBAAgB,IAAI,MAAM;IAI1B,aAAa,IAAI,MAAM;IAIvB,YAAY,IAAI,gBAAgB;CAGjC;AAoBD,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAErE"}
|
package/dist/mcp/server.js
CHANGED
|
@@ -4,6 +4,8 @@ import { join, relative, extname, basename, dirname } from 'path';
|
|
|
4
4
|
import { createInterface } from 'readline';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import { createHybridSearch } from './search/index.js';
|
|
7
|
+
import { UnsupportedError } from '../core/errors.js';
|
|
8
|
+
import { getIpInfo, isValidIP, isGeoIPAvailable, isBogon, isIPv6 } from './ip-intel.js';
|
|
7
9
|
export class MCPServer {
|
|
8
10
|
options;
|
|
9
11
|
server;
|
|
@@ -505,6 +507,20 @@ export class MCPServer {
|
|
|
505
507
|
required: ['useCase'],
|
|
506
508
|
},
|
|
507
509
|
},
|
|
510
|
+
{
|
|
511
|
+
name: 'ip_lookup',
|
|
512
|
+
description: 'Get geolocation and network information for an IP address using the local MaxMind GeoLite2 database. Returns city, country, coordinates, timezone, and more. Works offline after first download.',
|
|
513
|
+
inputSchema: {
|
|
514
|
+
type: 'object',
|
|
515
|
+
properties: {
|
|
516
|
+
ip: {
|
|
517
|
+
type: 'string',
|
|
518
|
+
description: 'IPv4 or IPv6 address to lookup (e.g., "8.8.8.8", "2001:4860:4860::8888")',
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
required: ['ip'],
|
|
522
|
+
},
|
|
523
|
+
},
|
|
508
524
|
];
|
|
509
525
|
if (this.options.toolsFilter.length > 0) {
|
|
510
526
|
return allTools.filter(tool => this.isToolEnabled(tool.name));
|
|
@@ -546,6 +562,8 @@ export class MCPServer {
|
|
|
546
562
|
return this.getApiSchema(args);
|
|
547
563
|
case 'suggest':
|
|
548
564
|
return this.getSuggestions(args);
|
|
565
|
+
case 'ip_lookup':
|
|
566
|
+
return this.ipLookup(args);
|
|
549
567
|
default:
|
|
550
568
|
return {
|
|
551
569
|
content: [{ type: 'text', text: `Unknown tool: ${name}` }],
|
|
@@ -820,6 +838,99 @@ export class MCPServer {
|
|
|
820
838
|
}],
|
|
821
839
|
};
|
|
822
840
|
}
|
|
841
|
+
ipLookupResult = null;
|
|
842
|
+
ipLookupPending = null;
|
|
843
|
+
ipLookup(args) {
|
|
844
|
+
const ip = String(args.ip || '').trim();
|
|
845
|
+
if (!ip) {
|
|
846
|
+
return {
|
|
847
|
+
content: [{ type: 'text', text: 'Error: ip is required' }],
|
|
848
|
+
isError: true,
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
if (!isValidIP(ip)) {
|
|
852
|
+
return {
|
|
853
|
+
content: [{ type: 'text', text: `Error: "${ip}" is not a valid IP address` }],
|
|
854
|
+
isError: true,
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
const bogonCheck = isBogon(ip);
|
|
858
|
+
const ipv6 = isIPv6(ip);
|
|
859
|
+
if (bogonCheck.isBogon) {
|
|
860
|
+
return {
|
|
861
|
+
content: [{
|
|
862
|
+
type: 'text',
|
|
863
|
+
text: this.formatIpResult({
|
|
864
|
+
ip,
|
|
865
|
+
bogon: true,
|
|
866
|
+
bogonType: bogonCheck.type,
|
|
867
|
+
isIPv6: ipv6,
|
|
868
|
+
org: bogonCheck.type,
|
|
869
|
+
}),
|
|
870
|
+
}],
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
if (!isGeoIPAvailable()) {
|
|
874
|
+
getIpInfo(ip).catch(() => { });
|
|
875
|
+
return {
|
|
876
|
+
content: [{
|
|
877
|
+
type: 'text',
|
|
878
|
+
text: `# GeoIP Database Required\n\nThe MaxMind GeoLite2 database is being downloaded (~70MB).\n\nPlease try again in a few seconds, or use the CLI:\n\n\`\`\`bash\nrek ip ${ip}\n\`\`\``,
|
|
879
|
+
}],
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
this.ipLookupPending = getIpInfo(ip).then(info => {
|
|
883
|
+
this.ipLookupResult = info;
|
|
884
|
+
});
|
|
885
|
+
return {
|
|
886
|
+
content: [{
|
|
887
|
+
type: 'text',
|
|
888
|
+
text: `# IP Intelligence: ${ip}\n\n**Status:** Public ${ipv6 ? 'IPv6' : 'IPv4'} Address\n\nFor detailed geolocation data (city, country, coordinates, timezone), use the CLI:\n\n\`\`\`bash\nrek ip ${ip}\n\`\`\`\n\n_Note: The MCP server uses a synchronous protocol. Full GeoIP lookups are available via CLI._`,
|
|
889
|
+
}],
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
formatIpResult(info) {
|
|
893
|
+
const lines = [`# IP Intelligence: ${info.ip}\n`];
|
|
894
|
+
if (info.bogon) {
|
|
895
|
+
lines.push(`**Type:** Private/Reserved IP (Bogon)`);
|
|
896
|
+
lines.push(`**Category:** ${info.bogonType}`);
|
|
897
|
+
lines.push(`\nThis is a non-routable IP address used for internal networks or special purposes.`);
|
|
898
|
+
}
|
|
899
|
+
else {
|
|
900
|
+
if (info.city || info.region || info.country) {
|
|
901
|
+
const location = [info.city, info.region, info.country].filter(Boolean).join(', ');
|
|
902
|
+
lines.push(`**Location:** ${location}`);
|
|
903
|
+
}
|
|
904
|
+
if (info.countryCode) {
|
|
905
|
+
lines.push(`**Country Code:** ${info.countryCode}`);
|
|
906
|
+
}
|
|
907
|
+
if (info.continent) {
|
|
908
|
+
lines.push(`**Continent:** ${info.continent}`);
|
|
909
|
+
}
|
|
910
|
+
if (info.loc) {
|
|
911
|
+
lines.push(`**Coordinates:** ${info.loc}`);
|
|
912
|
+
}
|
|
913
|
+
if (info.timezone) {
|
|
914
|
+
lines.push(`**Timezone:** ${info.timezone}`);
|
|
915
|
+
}
|
|
916
|
+
if (info.postal) {
|
|
917
|
+
lines.push(`**Postal Code:** ${info.postal}`);
|
|
918
|
+
}
|
|
919
|
+
if (info.org) {
|
|
920
|
+
lines.push(`**Organization:** ${info.org}`);
|
|
921
|
+
}
|
|
922
|
+
if (info.asn) {
|
|
923
|
+
lines.push(`**ASN:** ${info.asn}`);
|
|
924
|
+
}
|
|
925
|
+
if (info.accuracy) {
|
|
926
|
+
lines.push(`**Accuracy:** ~${info.accuracy} km`);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
if (info.isIPv6) {
|
|
930
|
+
lines.push(`\n_IPv6 Address_`);
|
|
931
|
+
}
|
|
932
|
+
return lines.join('\n');
|
|
933
|
+
}
|
|
823
934
|
getFeatureConfig(feature) {
|
|
824
935
|
const configs = {
|
|
825
936
|
retry: `retry: {
|
|
@@ -1127,7 +1238,9 @@ const client = createClient({
|
|
|
1127
1238
|
case 'sse':
|
|
1128
1239
|
return this.startSSE();
|
|
1129
1240
|
default:
|
|
1130
|
-
throw new
|
|
1241
|
+
throw new UnsupportedError(`Unknown transport: ${this.options.transport}`, {
|
|
1242
|
+
feature: this.options.transport,
|
|
1243
|
+
});
|
|
1131
1244
|
}
|
|
1132
1245
|
}
|
|
1133
1246
|
async stop() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gzip, deflate, brotliCompress } from 'node:zlib';
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
|
-
import {
|
|
3
|
+
import { UnsupportedError } from '../core/errors.js';
|
|
4
4
|
const gzipAsync = promisify(gzip);
|
|
5
5
|
const deflateAsync = promisify(deflate);
|
|
6
6
|
const brotliAsync = promisify(brotliCompress);
|
|
@@ -72,7 +72,9 @@ async function compress(data, algorithm) {
|
|
|
72
72
|
case 'br':
|
|
73
73
|
return await brotliAsync(data);
|
|
74
74
|
default:
|
|
75
|
-
throw new
|
|
75
|
+
throw new UnsupportedError(`Unsupported compression algorithm: ${algorithm}`, {
|
|
76
|
+
feature: algorithm,
|
|
77
|
+
});
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
export function compression(options = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"har-player.d.ts","sourceRoot":"","sources":["../../src/plugins/har-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA6C,MAAM,mBAAmB,CAAC;AAKtF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAgBD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"har-player.d.ts","sourceRoot":"","sources":["../../src/plugins/har-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA6C,MAAM,mBAAmB,CAAC;AAKtF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAgBD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAgF3D"}
|