# seydef/dns_changer architecture

> Architecture diagram of the GitHub repository seydef/dns_changer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/seydef/dns_changer
- Repository: https://github.com/seydef/dns_changer

## Overview

##### Main Components
- Script Entry Points: There are two scripts – one for Linux (dns.sh) and one for Windows (dns.ps1).
- Interactive UI: Both scripts provide an interactive menu for selecting a DNS server, so you want to capture that component.
- System Operations Layer: The part of the script that:
– Detects the active network connection.
– Displays the current DNS settings.
– Modifies the DNS for the selected connection.
– Restarts the network interface to apply new settings.
- Predefined DNS Server List: Represented in configurable arrays/hashtables in each script, which act as configuration data.
- Environment/Platform Dependencies:
– For Linux: Bash, nmcli (part of NetworkManager), and other OS-level network commands.
– For Windows: PowerShell commands and permissions (Administrator vs. non-admin).

##### Relationships and Data Flow
- Input Processing: The scripts read the selection, determine the corresponding DNS values from the DNS server list, and then update the network configuration.
- System Modification: The scripts then execute system commands to change the DNS settings and to trigger a restart of the network connection.
- Output Feedback: The changes are applied to the system, and the new settings become active.

##### Highlighting Architectural Patterns or Design Principles
- Separation of Concerns: Each script is self-contained, managing its user interface, configuration data, and system-level changes.
- Platform-Specific Implementation: Two parallel code paths exist in the repository, one tailored for Linux and one for Windows, with their own environment-specific commands and prerequisites.
- Modularity & Configurability: The scripts allow customization by simply modifying arrays or hashtables for DNS options, demonstrating an easily modifiable design.

##### Considering Technologies and Frameworks
- Linux: Bash scripting and NetworkManager's nmcli tool.
- Windows: PowerShell scripting and built-in network configuration commands.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Linux Environment
    subgraph "Linux Environment"
        L1["dns.sh"]:::entrypoint
        L2["Interactive Menu (Linux)"]:::ui
        L3["DNS Configuration Module (Linux)"]:::conf
        L4["Network Settings Manager (nmcli)"]:::system
        L5["Network Restart/Feedback (Linux)"]:::restart
        L1 -->|"start"| L2
        L2 -->|"select_DNS"| L3
        L3 -->|"apply_configuration"| L4
        L4 -->|"restart_network"| L5
    end

    %% Windows Environment
    subgraph "Windows Environment"
        W1["dns.ps1"]:::entrypoint
        W2["Interactive Menu (Windows)"]:::ui
        W3["DNS Configuration Module (Windows)"]:::conf
        W4["Network Settings Manager (PowerShell)"]:::system
        W5["Network Restart/Feedback (Windows)"]:::restart
        W1 -->|"start"| W2
        W2 -->|"select_DNS"| W3
        W3 -->|"apply_configuration"| W4
        W4 -->|"restart_network"| W5
    end

    %% Customization Note
    CP["Customization Points: Modify DNS Server List"]:::note
    L3 -.-> CP
    W3 -.-> CP

    %% Click Events for Entry Points
    click L1 "https://github.com/seydef/dns_changer/blob/master/dns.sh"
    click W1 "https://github.com/seydef/dns_changer/blob/master/dns.ps1"

    %% Style Definitions
    classDef entrypoint fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef conf fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef system fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef restart fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef note fill:#D3D3D3,stroke:#333,stroke-dasharray: 5 5,stroke-width:2px;
```
