work on proxy
This commit is contained in:
parent
953b361d30
commit
0937651f67
4 changed files with 59 additions and 237 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { proxyService } from './services/proxy.service.js';
|
||||
import { proxyService, ProxySource } from './services/proxy.service.js';
|
||||
|
||||
/**
|
||||
* Example usage of the ProxyService
|
||||
|
|
@ -90,24 +90,10 @@ async function demonstrateProxyService() {
|
|||
async function demonstrateCustomProxySource() {
|
||||
console.log('🔧 Demonstrating custom proxy source...');
|
||||
|
||||
const customSources = [
|
||||
const customSources : ProxySource[] = [
|
||||
{
|
||||
url: 'https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks4.txt',
|
||||
type: 'free' as const,
|
||||
format: 'text' as const,
|
||||
parser: (content: string) => {
|
||||
return content.split('\n')
|
||||
.filter(line => line.trim() && !line.startsWith('#'))
|
||||
.map(line => {
|
||||
const [host, port] = line.trim().split(':');
|
||||
return {
|
||||
type: 'socks4' as const,
|
||||
host: host.trim(),
|
||||
port: parseInt(port.trim())
|
||||
};
|
||||
})
|
||||
.filter(proxy => proxy.host && !isNaN(proxy.port));
|
||||
}
|
||||
url: 'https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/socks5.txt',
|
||||
protocol: 'socks5'
|
||||
}
|
||||
];
|
||||
|
||||
|
|
@ -127,7 +113,7 @@ export {
|
|||
|
||||
// If this file is run directly, execute the demo
|
||||
if (import.meta.main) {
|
||||
demonstrateProxyService()
|
||||
.then(() => demonstrateCustomProxySource())
|
||||
// demonstrateProxyService()
|
||||
demonstrateCustomProxySource()
|
||||
.catch(console.error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue