/**
 * Common Protocol Types
 * 
 * Shared types used across different protocol implementations
 */

/**
 * Supported protocol types
 */
export type TProtocolType = 'tls' | 'http' | 'https' | 'websocket' | 'unknown';

/**
 * Protocol detection result
 */
export interface IProtocolDetectionResult {
  protocol: TProtocolType;
  confidence: number; // 0-100
  requiresMoreData?: boolean;
  metadata?: {
    version?: string;
    method?: string;
    [key: string]: any;
  };
}

/**
 * Routing information extracted from protocols
 */
export interface IRoutingInfo {
  domain?: string;
  port?: number;
  path?: string;
  protocol: TProtocolType;
}

/**
 * Connection context for protocol operations
 */
export interface IConnectionContext {
  id: string;
  sourceIp?: string;
  sourcePort?: number;
  destIp?: string;
  destPort?: number;
  timestamp?: number;
}

/**
 * Protocol detection options
 */
export interface IProtocolDetectionOptions {
  quickMode?: boolean;        // Only do minimal detection
  extractRouting?: boolean;   // Extract routing information
  maxWaitTime?: number;       // Max time to wait for complete data
  maxBufferSize?: number;     // Max buffer size for fragmented data
}

/**
 * Base interface for protocol detectors
 */
export interface IProtocolDetector {
  /**
   * Check if this detector can handle the data
   */
  canHandle(data: Buffer): boolean;
  
  /**
   * Perform quick detection (first few bytes only)
   */
  quickDetect(data: Buffer): IProtocolDetectionResult;
  
  /**
   * Extract routing information if possible
   */
  extractRouting?(data: Buffer, context?: IConnectionContext): IRoutingInfo | null;
}