import { NativeModules } from 'react-native';

const { TcpProxyModule } = NativeModules;

export interface TcpProxyConfig {
  wsUrl: string;
  host: string;
  port: number;
  messageId: string;
}

/**
 * 启动TCP代理
 * 客户端连接到wsUrl的WebSocket服务器，建立到host:port的TCP连接，双向转发流量
 */
export async function startTcpProxy(config: TcpProxyConfig): Promise<boolean> {
  if (!TcpProxyModule) {
    throw new Error('TcpProxyModule not available');
  }
  
  return TcpProxyModule.startProxy(
    config.wsUrl,
    config.host,
    config.port,
    config.messageId
  );
}
