recker 1.0.15-next.7944604 → 1.0.15-next.99ff876
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 +602 -48
- 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 +43 -0
- package/dist/cli/tui/scroll-buffer.d.ts.map +1 -0
- package/dist/cli/tui/scroll-buffer.js +162 -0
- package/dist/cli/tui/search-panel.d.ts +41 -0
- package/dist/cli/tui/search-panel.d.ts.map +1 -0
- package/dist/cli/tui/search-panel.js +419 -0
- package/dist/cli/tui/shell.d.ts +14 -0
- package/dist/cli/tui/shell.d.ts.map +1 -1
- package/dist/cli/tui/shell.js +424 -46
- 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/index.d.ts +1 -0
- package/dist/dns/index.d.ts.map +1 -1
- package/dist/dns/index.js +1 -0
- package/dist/dns/propagation.d.ts +21 -0
- package/dist/dns/propagation.d.ts.map +1 -0
- package/dist/dns/propagation.js +169 -0
- 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/utils/tls-inspector.d.ts +6 -0
- package/dist/utils/tls-inspector.d.ts.map +1 -1
- package/dist/utils/tls-inspector.js +35 -1
- 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 +2 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Client } from '../core/client.js';
|
|
2
|
+
import pc from '../utils/colors.js';
|
|
3
|
+
const PROVIDERS = [
|
|
4
|
+
{ id: 'google', name: 'Google DNS', url: 'https://dns.google/resolve', location: 'Global' },
|
|
5
|
+
{ id: 'cloudflare', name: 'Cloudflare', url: 'https://cloudflare-dns.com/dns-query', location: 'Global' },
|
|
6
|
+
{ id: 'nextdns', name: 'NextDNS', url: 'https://dns.nextdns.io/dns-query', location: 'Global' },
|
|
7
|
+
];
|
|
8
|
+
const TYPE_MAP = {
|
|
9
|
+
'A': '1',
|
|
10
|
+
'AAAA': '28',
|
|
11
|
+
'CNAME': '5',
|
|
12
|
+
'MX': '15',
|
|
13
|
+
'NS': '2',
|
|
14
|
+
'TXT': '16',
|
|
15
|
+
'PTR': '12',
|
|
16
|
+
'SRV': '33',
|
|
17
|
+
'SOA': '6',
|
|
18
|
+
'CAA': '257'
|
|
19
|
+
};
|
|
20
|
+
const TYPE_ID_MAP = Object.entries(TYPE_MAP).reduce((acc, [k, v]) => {
|
|
21
|
+
acc[Number(v)] = k;
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
const DNS_STATUS_MAP = {
|
|
25
|
+
0: 'NoError',
|
|
26
|
+
1: 'FormErr',
|
|
27
|
+
2: 'ServFail',
|
|
28
|
+
3: 'NXDomain',
|
|
29
|
+
4: 'NotImp',
|
|
30
|
+
5: 'Refused',
|
|
31
|
+
6: 'YXDomain',
|
|
32
|
+
7: 'YXRRSet',
|
|
33
|
+
8: 'NXRRSet',
|
|
34
|
+
9: 'NotAuth',
|
|
35
|
+
10: 'NotZone'
|
|
36
|
+
};
|
|
37
|
+
export function getTypeName(typeId) {
|
|
38
|
+
return TYPE_ID_MAP[typeId] || `TYPE${typeId}`;
|
|
39
|
+
}
|
|
40
|
+
export async function checkPropagation(domainInput, type = 'A') {
|
|
41
|
+
const domain = domainInput.replace(/^https?:\/\//, '').split('/')[0].split('?')[0];
|
|
42
|
+
const typeId = TYPE_MAP[type.toUpperCase()] || type;
|
|
43
|
+
const client = new Client({
|
|
44
|
+
baseUrl: 'http://localhost',
|
|
45
|
+
http2: true,
|
|
46
|
+
timeout: 5000,
|
|
47
|
+
});
|
|
48
|
+
const queries = PROVIDERS.map(async (provider) => {
|
|
49
|
+
const start = performance.now();
|
|
50
|
+
try {
|
|
51
|
+
const url = new URL(provider.url);
|
|
52
|
+
url.searchParams.set('name', domain);
|
|
53
|
+
url.searchParams.set('type', typeId);
|
|
54
|
+
const json = await client.get(url.toString(), {
|
|
55
|
+
headers: { 'Accept': 'application/dns-json' }
|
|
56
|
+
}).json();
|
|
57
|
+
const duration = performance.now() - start;
|
|
58
|
+
return processJsonResponse(json, provider, duration);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
const duration = performance.now() - start;
|
|
62
|
+
let errorMessage;
|
|
63
|
+
if (err.name === 'TimeoutError' || err.name === 'AbortError' || err.code === 'UND_ERR_ABORTED') {
|
|
64
|
+
errorMessage = `Timeout (>${client.defaultTimeout || 5000}ms)`;
|
|
65
|
+
}
|
|
66
|
+
else if (err.name === 'HttpError') {
|
|
67
|
+
errorMessage = `HTTP ${err.status} ${err.statusText}`;
|
|
68
|
+
}
|
|
69
|
+
else if (err.name === 'NetworkError') {
|
|
70
|
+
errorMessage = `Network error: ${err.code || err.message}`;
|
|
71
|
+
}
|
|
72
|
+
else if (err.name === 'ParseError') {
|
|
73
|
+
errorMessage = `Parse error: ${err.message}`;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
errorMessage = err.message || 'Unknown error';
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
id: provider.id,
|
|
80
|
+
provider: provider.name,
|
|
81
|
+
status: 'error',
|
|
82
|
+
records: [],
|
|
83
|
+
rawRecords: [],
|
|
84
|
+
latency: duration,
|
|
85
|
+
error: errorMessage,
|
|
86
|
+
location: provider.location
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return Promise.all(queries);
|
|
91
|
+
}
|
|
92
|
+
function processJsonResponse(json, provider, duration) {
|
|
93
|
+
if (json.Status !== 0) {
|
|
94
|
+
const errorName = DNS_STATUS_MAP[json.Status] || `Code ${json.Status}`;
|
|
95
|
+
return {
|
|
96
|
+
id: provider.id,
|
|
97
|
+
provider: provider.name,
|
|
98
|
+
status: 'error',
|
|
99
|
+
records: [],
|
|
100
|
+
rawRecords: [],
|
|
101
|
+
latency: duration,
|
|
102
|
+
error: errorName,
|
|
103
|
+
location: provider.location
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const answers = (json.Answer || []);
|
|
107
|
+
const records = answers.map(r => r.data);
|
|
108
|
+
const minTTL = answers.length ? Math.min(...answers.map(r => r.TTL)) : undefined;
|
|
109
|
+
return {
|
|
110
|
+
id: provider.id,
|
|
111
|
+
provider: provider.name,
|
|
112
|
+
status: 'ok',
|
|
113
|
+
records,
|
|
114
|
+
rawRecords: answers,
|
|
115
|
+
latency: duration,
|
|
116
|
+
location: provider.location,
|
|
117
|
+
minTTL
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export function formatPropagationReport(results, domain, type) {
|
|
121
|
+
let output = '';
|
|
122
|
+
const displayDomain = domain.replace(/^https?:\/\//, '').split('/')[0];
|
|
123
|
+
output += `\n${pc.bold(pc.cyan('🌍 Global DNS Propagation Check'))}\n`;
|
|
124
|
+
output += `${pc.gray('Domain:')} ${pc.white(displayDomain)} ${pc.gray('Type:')} ${pc.white(type.toUpperCase())}\n\n`;
|
|
125
|
+
const consensus = {};
|
|
126
|
+
results.forEach(res => {
|
|
127
|
+
const key = res.status === 'ok' ? res.records.sort().join(', ') : `Error: ${res.error}`;
|
|
128
|
+
consensus[key] = (consensus[key] || 0) + 1;
|
|
129
|
+
const statusIcon = res.status === 'ok' ? pc.green('✔') : pc.red('✖');
|
|
130
|
+
const latencyColor = res.latency < 50 ? pc.green : res.latency < 200 ? pc.yellow : pc.red;
|
|
131
|
+
const latencyText = latencyColor(`${Math.round(res.latency)}ms`.padStart(6));
|
|
132
|
+
const providerName = pc.bold(res.provider.padEnd(12));
|
|
133
|
+
const ttlText = res.minTTL !== undefined ? pc.gray(`[TTL ${res.minTTL}s]`) : '';
|
|
134
|
+
let recordsText = '';
|
|
135
|
+
if (res.status === 'ok') {
|
|
136
|
+
if (res.records.length === 0) {
|
|
137
|
+
recordsText = pc.yellow('(No records)');
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
recordsText = res.records.join(', ');
|
|
141
|
+
if (recordsText.length > 50)
|
|
142
|
+
recordsText = recordsText.substring(0, 47) + '...';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
recordsText = pc.red(res.error || 'Unknown Error');
|
|
147
|
+
}
|
|
148
|
+
output += ` ${statusIcon} ${providerName} ${latencyText} ${recordsText} ${ttlText}\n`;
|
|
149
|
+
});
|
|
150
|
+
output += '\n';
|
|
151
|
+
const okResults = results.filter(r => r.status === 'ok');
|
|
152
|
+
const errorResults = results.filter(r => r.status === 'error');
|
|
153
|
+
const distinctAnswers = Object.keys(consensus);
|
|
154
|
+
if (errorResults.length === results.length) {
|
|
155
|
+
output += pc.red('❌ All providers returned errors.\n');
|
|
156
|
+
}
|
|
157
|
+
else if (okResults.length === results.length && distinctAnswers.length === 1) {
|
|
158
|
+
output += pc.green('✅ All providers agree. Propagation is complete.\n');
|
|
159
|
+
}
|
|
160
|
+
else if (distinctAnswers.length > 1) {
|
|
161
|
+
if (errorResults.length > 0) {
|
|
162
|
+
output += pc.yellow(`⚠ ${okResults.length}/${results.length} providers responded. Some errors occurred.\n`);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
output += pc.yellow('⚠ Inconsistent results (propagation in progress or split-horizon DNS).\n');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return output;
|
|
169
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export * from './constants/http-status.js';
|
|
|
58
58
|
export * from './utils/env-proxy.js';
|
|
59
59
|
export * from './utils/charset.js';
|
|
60
60
|
export * from './utils/client-pool.js';
|
|
61
|
+
export * from './utils/security-grader.js';
|
|
61
62
|
export * as presets from './presets/index.js';
|
|
62
63
|
export * as testing from './testing/index.js';
|
|
63
64
|
export * as protocols from './protocols/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{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,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAGlD,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAOpD,OAAO,EACL,GAAG,EACH,IAAI,EACJ,GAAG,EACH,KAAK,EACL,GAAG,EACH,GAAG,IAAI,MAAM,EACb,IAAI,EACJ,OAAO,EACP,KAAK,EACL,cAAc,EACd,GAAG,EACH,WAAW,EACX,EAAE,EACF,MAAM,GACP,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,7 @@ export * from './constants/http-status.js';
|
|
|
58
58
|
export * from './utils/env-proxy.js';
|
|
59
59
|
export * from './utils/charset.js';
|
|
60
60
|
export * from './utils/client-pool.js';
|
|
61
|
+
export * from './utils/security-grader.js';
|
|
61
62
|
export * as presets from './presets/index.js';
|
|
62
63
|
export * as testing from './testing/index.js';
|
|
63
64
|
export * as protocols from './protocols/index.js';
|
package/dist/mcp/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,OAAO,KAAK,EAGV,aAAa,EACb,OAAO,EAEP,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,g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I,OAAO,CAAC,IAAI,CAAC;IAI3B,aAAa,IAAI,aAAa,GAAG,SAAS;IAI1C,WAAW,IAAI,OAAO;YAIR,OAAO;YA2CP,UAAU;IAkBxB,OAAO,CAAC,cAAc;CAgCvB;AAYD,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAEpE"}
|
package/dist/mcp/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { createClient } from '../core/client.js';
|
|
3
|
-
import {
|
|
3
|
+
import { StateError, ProtocolError } from '../core/errors.js';
|
|
4
4
|
import { consoleLogger } from '../types/logger.js';
|
|
5
5
|
export class MCPClient extends EventEmitter {
|
|
6
6
|
client;
|
|
@@ -128,11 +128,10 @@ export class MCPClient extends EventEmitter {
|
|
|
128
128
|
}
|
|
129
129
|
async request(method, params) {
|
|
130
130
|
if (!this.initialized && method !== 'initialize') {
|
|
131
|
-
throw new
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
]);
|
|
131
|
+
throw new StateError('MCP client not initialized. Call connect() first.', {
|
|
132
|
+
expectedState: 'connected',
|
|
133
|
+
actualState: 'disconnected',
|
|
134
|
+
});
|
|
136
135
|
}
|
|
137
136
|
const request = {
|
|
138
137
|
jsonrpc: '2.0',
|
|
@@ -146,11 +145,11 @@ export class MCPClient extends EventEmitter {
|
|
|
146
145
|
.json();
|
|
147
146
|
this.emit('response', response);
|
|
148
147
|
if (response.error) {
|
|
149
|
-
const error = new
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
const error = new ProtocolError(response.error.message, {
|
|
149
|
+
protocol: 'mcp',
|
|
150
|
+
code: response.error.code,
|
|
151
|
+
retriable: false,
|
|
152
|
+
});
|
|
154
153
|
error.code = response.error.code;
|
|
155
154
|
error.data = response.error.data;
|
|
156
155
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embeddings-loader.d.ts","sourceRoot":"","sources":["../../src/mcp/embeddings-loader.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"embeddings-loader.d.ts","sourceRoot":"","sources":["../../src/mcp/embeddings-loader.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAgCxD,iBAAS,iBAAiB,IAAI,MAAM,CAKnC;AAyBD,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAI/D;AAKD,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAE5D;AAKD,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAa3E;AAKD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAUhF;AAKD,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CA4BlF;AAKD,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAsB5E;AAED,MAAM,WAAW,qBAAqB;IAEpC,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAsBD,wBAAsB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAsCxG;AAKD,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAW3D;AAKD,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -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"}
|