# radinpirouz/dns_changer architecture

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

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

## Overview

##### Main Components
- User Interface/Input: This is the command-line interaction in which the user runs the script and selects a DNS server.
- The Bash Script (dns.sh): This contains the logic for detecting /etc/resolv.conf’s status (such as being a symlink), unlinking it if necessary, and writing the new DNS configuration.
- System DNS Configuration: The /etc/resolv.conf file represents the final target component of the script’s actions.
- System Environment Dependencies: Indicate that the script requires Bash and sudo privileges (which implies that it interacts with system-level configuration and may also need to manage systemd-resolved).

##### Relationships and Interactions
- The user starts the process by executing the script.
- The script prompts for user selection from a predefined list.
- Upon selection, the script checks the type of /etc/resolv.conf (whether it’s a symlink) and unlinks it if necessary.
- The script then writes or creates a new /etc/resolv.conf with the chosen DNS.

##### Architectural Patterns or Design Principles
- Although it’s a single-file script, one can treat this as a simple pipeline of sequential operations.
- Error checking, user prompt flow, and system constraints (sudo privileges, symlink detection).
- That the design is “linear” or “procedural”, where each step depends on the previous operation.

##### Technologies and Dependencies
- Bash (as the scripting language).
- Linux system environment, with specific emphasis on systemd-resolved if present.
- Standard file manipulation commands and their execution through sudo.

## Diagram (Mermaid)

```mermaid
flowchart TD
    UI["User Command Line"]:::input
    Script["Bash Script (dns.sh)"]:::process
    DNSOptions["DNS Server Options"]:::process
    Symlink["Symlink Check & Unlink"]:::process
    Resolv["Modified /etc/resolv.conf"]:::file
    Dependencies["System Environment Dependencies (Bash,sudo,systemd-resolved)"]:::dependency

    UI -->|"executes"| Script
    Script -->|"presents"| DNSOptions
    DNSOptions -->|"triggers"| Symlink
    Symlink -->|"updates"| Resolv
    Script -->|"requires"| Dependencies

    click UI "https://github.com/radinpirouz/dns_changer/blob/main/dns.sh"
    click Script "https://github.com/radinpirouz/dns_changer/blob/main/dns.sh"
    click DNSOptions "https://github.com/radinpirouz/dns_changer/blob/main/dns.sh"

    classDef input fill:#bbf,stroke:#333,stroke-width:2px
    classDef process fill:#bfb,stroke:#333,stroke-width:2px
    classDef file fill:#ff9,stroke:#333,stroke-width:2px
    classDef dependency fill:#f99,stroke:#333,stroke-width:2px
```
