# fyxme/dnsfaster architecture

> Architecture diagram of the GitHub repository fyxme/dnsfaster, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fyxme/dnsfaster
- Repository: https://github.com/fyxme/dnsfaster

## Overview

Key Components to Include:

##### Core Components
- DNS Query Generator
- Worker Pool Manager
- DNS Resolution Engine
- Results Aggregator
- Statistics Calculator

##### External Dependencies
- DNS Servers (Test Targets)
- miekg/dns library
- File System (for input/output)

##### Component Details

a. Input Processing:
- Input file reader
- Domain name configuration
- Worker/test count parameters

b. Core Processing:
- Worker pool architecture
- Parallel DNS query execution
- Demonstrate how random subdomain generation works

c. DNS Resolution:
- Connection to external DNS servers
- DNS query/response flow
- Miekg/dns library integration

d. Results Processing:
- Statistics collection mechanism
- Averaging and reliability calculations
- Output file generation

##### Specific Elements

a. Input Section:
- [Input File] -> [Config Parser] -> [Query Generator]

b. Processing Section:
- [Worker Pool Manager] <-> [DNS Resolution Workers (1..N)]

c. DNS Communication:
- [DNS Workers] <-> [DNS Servers Pool]

d. Results Section:
- [Results Collector] -> [Statistics Calculator] -> [Output File]

##### Important Flows to Highlight
- Parallel processing of DNS queries
- Error handling and retry mechanisms
- Performance metrics collection
- Success/failure rate tracking

##### Performance Aspects
- Concurrent operations
- Bottleneck points
- Scalability aspects

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2b95d6',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#7C0000',
    'lineColor': '#F8B229',
    'secondaryColor': '#006100',
    'tertiaryColor': '#fff'
  }
}}%%

flowchart TB
    classDef core fill:#2b95d6,stroke:#333,stroke-width:2px,color:white
    classDef input fill:#4CAF50,stroke:#333,stroke-width:2px,color:white
    classDef external fill:#FFC107,stroke:#333,stroke-width:2px,color:black
    classDef output fill:#4CAF50,stroke:#333,stroke-width:2px,color:white
    classDef config fill:#9C27B0,stroke:#333,stroke-width:2px,color:white

    subgraph Input
        IF["Input File"]:::input
        CP["Config Parser"]:::core
        click IF "https://github.com/fyxme/dnsfaster/blob/master/test-input/10.txt"
    end

    subgraph Core["Core Processing"]
        QG["DNS Query Generator"]:::core
        WPM["Worker Pool Manager"]:::core
        DRE["DNS Resolution Engine"]:::core
        click QG "https://github.com/fyxme/dnsfaster/blob/master/dnsfaster.go"
        click WPM "https://github.com/fyxme/dnsfaster/blob/master/dnsfaster.go"
        click DRE "https://github.com/fyxme/dnsfaster/blob/master/dnsfaster.go"
    end

    subgraph Workers["Worker Pool"]
        W1["Worker 1"]:::core
        W2["Worker 2"]:::core
        W3["Worker N"]:::core
    end

    subgraph External["External Services"]
        DNS1[("DNS Server 1")]:::external
        DNS2[("DNS Server 2")]:::external
        DNS3[("DNS Server N")]:::external
    end

    subgraph Results["Results Processing"]
        RA["Results Aggregator"]:::core
        SC["Statistics Calculator"]:::core
        OF["Output File"]:::output
        click RA "https://github.com/fyxme/dnsfaster/blob/master/dnsfaster.go"
        click SC "https://github.com/fyxme/dnsfaster/blob/master/dnsfaster.go"
    end

    Config["Execution Config"]:::config
    click Config "https://github.com/fyxme/dnsfaster/blob/master/run.sh"

    Dependencies["Project Dependencies"]:::config
    click Dependencies "https://github.com/fyxme/dnsfaster/blob/master/go.mod"

    IF --> CP
    CP --> QG
    Config --> WPM
    QG --> WPM
    WPM --> W1 & W2 & W3
    W1 & W2 & W3 --> |DNS Queries| DNS1 & DNS2 & DNS3
    DNS1 & DNS2 & DNS3 --> |Responses| W1 & W2 & W3
    W1 & W2 & W3 --> RA
    RA --> SC
    SC --> OF
    Dependencies -.-> Core

    subgraph Legend
        L1["Process"]:::core
        L2["Input/Output"]:::input
        L3[("External Service")]:::external
        L4["Configuration"]:::config
    end
```
