fixed build libs

This commit is contained in:
Boki 2025-06-25 08:29:53 -04:00
parent b03231b849
commit 42baadae38
26 changed files with 981 additions and 541 deletions

View file

@ -1,14 +1,24 @@
import type { ProxyInfo, ProxyConfig } from './types';
import type { ProxyInfo } from './types';
export interface ProxyConfig {
protocol: string;
host: string;
port: number;
auth?: {
username: string;
password: string;
};
}
/**
* Simple proxy manager for testing
*/
export class SimpleProxyManager {
private proxies: ProxyInfo[] = [];
private proxies: Array<ProxyInfo & { id: string; active: boolean }> = [];
private currentIndex = 0;
private activeProxyIndex = 0;
addProxy(proxy: ProxyInfo): void {
addProxy(proxy: ProxyInfo & { id: string; active: boolean }): void {
this.proxies.push(proxy);
}
@ -23,15 +33,15 @@ export class SimpleProxyManager {
}
}
getProxies(): ProxyInfo[] {
getProxies(): Array<ProxyInfo & { id: string; active: boolean }> {
return [...this.proxies];
}
getActiveProxies(): ProxyInfo[] {
getActiveProxies(): Array<ProxyInfo & { id: string; active: boolean }> {
return this.proxies.filter(p => p.active);
}
getNextProxy(): ProxyInfo | null {
getNextProxy(): (ProxyInfo & { id: string; active: boolean }) | null {
const activeProxies = this.getActiveProxies();
if (activeProxies.length === 0) {
return null;
@ -39,10 +49,10 @@ export class SimpleProxyManager {
const proxy = activeProxies[this.activeProxyIndex % activeProxies.length];
this.activeProxyIndex++;
return proxy;
return proxy || null;
}
getProxyConfig(proxy: ProxyInfo): ProxyConfig {
getProxyConfig(proxy: ProxyInfo & { id: string; active: boolean }): ProxyConfig {
const config: ProxyConfig = {
protocol: proxy.protocol,
host: proxy.host,

View file

@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, mock } from 'bun:test';
import { SimpleProxyManager } from './simple-proxy-manager';
import type { ProxyConfig, ProxyInfo } from './types';
import { SimpleProxyManager } from '../src/simple-proxy-manager';
import type { ProxyConfig, ProxyInfo } from '../src/types';
describe('ProxyManager', () => {
let manager: SimpleProxyManager;