# yarrick/iodine architecture

> Architecture diagram of the GitHub repository yarrick/iodine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yarrick/iodine
- Repository: https://github.com/yarrick/iodine

## Overview

iodine tunnels IPv4 packets through DNS between a client and iodined server. The main workflow is client setup/authentication and negotiation, packet transfer over DNS-encoded queries and replies, then delivery through each endpoint’s virtual TUN interface. README also documents raw-UDP fallback and query/fragment tuning. The excerpts show endpoint orchestration and parts of the protocol, but not all server/client internals; uncertain relationships are omitted or dashed.

Main entry points: [`src/client.c`](https://github.com/yarrick/iodine/blob/master/src/client.c) (Client transfer), [`src/iodine.c`](https://github.com/yarrick/iodine/blob/master/src/iodine.c) (Client setup), [`src/iodined.c`](https://github.com/yarrick/iodine/blob/master/src/iodined.c) (Server transfer), [`src/encoding.c`](https://github.com/yarrick/iodine/blob/master/src/encoding.c) (Hostname encoding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_endpoints["Tunnel endpoints"]
  node_client_cli["Client setup<br/>[iodine.c]"]
  node_client_engine["Client transfer<br/>[client.c]"]
  node_server["Server transfer<br/>[iodined.c]"]
end

subgraph group_protocol["DNS tunnel protocol"]
  node_dns_codec["DNS codec<br/>[dns.c]"]
  node_encoding["Hostname encoding<br/>[encoding.c]"]
  node_base32["Base32<br/>[base32.c]"]
  node_base64["Base64<br/>[base64.c]"]
  node_base128["Base128<br/>[base128.c]"]
  node_authentication["Authentication<br/>[login.c]"]
  node_password_hash["MD5<br/>[md5.c]"]
  node_user_state["User sessions<br/>[user.c]"]
  node_firewall_probe["Raw-mode probe<br/>[fw_query.c]"]
end

subgraph group_platform["Network platform"]
  node_dns_network["DNS sockets<br/>[common.c]"]
  node_tun_api["TUN interface<br/>[tun_unix.c]"]
  node_tun_windows["Windows TUN<br/>[tun_windows.c]"]
  node_privilege["Privilege handling<br/>[run_as.c]"]
  node_process["Process control<br/>[process.c]"]
end

subgraph group_support["Protocol support"]
  node_compat["OS compatibility<br/>[compat.c]"]
  node_packet_support["Packet utilities<br/>[read.c]"]
end

node_client_actor(("Tunnel user"))
node_external_dns(("Relay DNS"))
node_virtual_network(("IPv4 network"))

node_client_actor -->|"configures"| node_client_cli
node_client_cli -->|"starts handshake"| node_client_engine
node_client_cli -->|"opens tunnel"| node_tun_api
node_client_cli -.->|"opens DNS"| node_dns_network
node_client_cli -.->|"drops privileges"| node_privilege
node_client_cli -.->|"controls process"| node_process
node_client_engine -->|"sends queries"| node_external_dns
node_external_dns -->|"routes queries"| node_server
node_client_engine -.->|"uses DNS packets"| node_dns_codec
node_server -.->|"encodes replies"| node_dns_codec
node_client_engine -->|"encodes data"| node_encoding
node_encoding -->|"uses codec"| node_base32
node_encoding -.->|"uses codec"| node_base64
node_encoding -.->|"uses codec"| node_base128
node_client_cli -.->|"sets password"| node_authentication
node_authentication -->|"uses digest"| node_password_hash
node_server -->|"tracks sessions"| node_user_state
node_client_engine -.->|"tests raw mode"| node_firewall_probe
node_client_engine -.->|"reads and writes"| node_tun_api
node_server -.->|"reads and writes"| node_tun_api
node_tun_api -->|"transfers IPv4"| node_virtual_network
node_tun_windows -.->|"transfers IPv4"| node_virtual_network
node_client_engine -.->|"raw UDP fallback"| node_external_dns
node_server -->|"listens for DNS"| node_dns_network
node_client_engine -.->|"uses packet helpers"| node_packet_support

click node_client_cli "https://github.com/yarrick/iodine/blob/master/src/iodine.c"
click node_client_engine "https://github.com/yarrick/iodine/blob/master/src/client.c"
click node_server "https://github.com/yarrick/iodine/blob/master/src/iodined.c"
click node_dns_codec "https://github.com/yarrick/iodine/blob/master/src/dns.c"
click node_encoding "https://github.com/yarrick/iodine/blob/master/src/encoding.c"
click node_base32 "https://github.com/yarrick/iodine/blob/master/src/base32.c"
click node_base64 "https://github.com/yarrick/iodine/blob/master/src/base64.c"
click node_base128 "https://github.com/yarrick/iodine/blob/master/src/base128.c"
click node_authentication "https://github.com/yarrick/iodine/blob/master/src/login.c"
click node_password_hash "https://github.com/yarrick/iodine/blob/master/src/md5.c"
click node_user_state "https://github.com/yarrick/iodine/blob/master/src/user.c"
click node_firewall_probe "https://github.com/yarrick/iodine/blob/master/src/fw_query.c"
click node_dns_network "https://github.com/yarrick/iodine/blob/master/src/common.c"
click node_tun_api "https://github.com/yarrick/iodine/blob/master/src/tun_unix.c"
click node_tun_windows "https://github.com/yarrick/iodine/blob/master/src/tun_windows.c"
click node_privilege "https://github.com/yarrick/iodine/blob/master/src/run_as.c"
click node_process "https://github.com/yarrick/iodine/blob/master/src/process.c"
click node_compat "https://github.com/yarrick/iodine/blob/master/src/compat.c"
click node_packet_support "https://github.com/yarrick/iodine/blob/master/src/read.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_cli,node_client_engine,node_server,node_client_actor toneBlue
class node_dns_codec,node_encoding,node_base32,node_base64,node_base128,node_authentication,node_password_hash,node_user_state,node_firewall_probe toneAmber
class node_dns_network,node_tun_api,node_tun_windows,node_privilege,node_process toneMint
class node_compat,node_packet_support toneRose
class node_external_dns,node_virtual_network toneIndigo
```

## Components

### Tunnel endpoints

- [Client setup](https://github.com/yarrick/iodine/blob/master/src/iodine.c): `src/iodine.c`
- [Client transfer](https://github.com/yarrick/iodine/blob/master/src/client.c): `src/client.c`
- [Server transfer](https://github.com/yarrick/iodine/blob/master/src/iodined.c): `src/iodined.c`

### DNS tunnel protocol

- [DNS codec](https://github.com/yarrick/iodine/blob/master/src/dns.c): `src/dns.c`
- [Hostname encoding](https://github.com/yarrick/iodine/blob/master/src/encoding.c): `src/encoding.c`
- [Base32](https://github.com/yarrick/iodine/blob/master/src/base32.c): `src/base32.c`
- [Base64](https://github.com/yarrick/iodine/blob/master/src/base64.c): `src/base64.c`
- [Base128](https://github.com/yarrick/iodine/blob/master/src/base128.c): `src/base128.c`
- [Authentication](https://github.com/yarrick/iodine/blob/master/src/login.c): `src/login.c`
- [MD5](https://github.com/yarrick/iodine/blob/master/src/md5.c): `src/md5.c`
- [User sessions](https://github.com/yarrick/iodine/blob/master/src/user.c): `src/user.c`
- [Raw-mode probe](https://github.com/yarrick/iodine/blob/master/src/fw_query.c): `src/fw_query.c`

### Network platform

- [DNS sockets](https://github.com/yarrick/iodine/blob/master/src/common.c): `src/common.c`
- [TUN interface](https://github.com/yarrick/iodine/blob/master/src/tun_unix.c): `src/tun_unix.c`
- [Windows TUN](https://github.com/yarrick/iodine/blob/master/src/tun_windows.c): `src/tun_windows.c`
- [Privilege handling](https://github.com/yarrick/iodine/blob/master/src/run_as.c): `src/run_as.c`
- [Process control](https://github.com/yarrick/iodine/blob/master/src/process.c): `src/process.c`

### Protocol support

- [OS compatibility](https://github.com/yarrick/iodine/blob/master/src/compat.c): `src/compat.c`
- [Packet utilities](https://github.com/yarrick/iodine/blob/master/src/read.c): `src/read.c`

### Other components

- **Tunnel user**
- **Relay DNS**
- **IPv4 network**

## Connections

- Tunnel user → Client setup: configures (evidence: `README.md`)
- Client setup → Client transfer: starts handshake (evidence: `src/iodine.c`)
- Client setup → TUN interface: opens tunnel (evidence: `src/iodine.c`)
- Client setup → DNS sockets: opens DNS
- Client setup → Privilege handling: drops privileges
- Client setup → Process control: controls process
- Client transfer → Relay DNS: sends queries (evidence: `README.md`)
- Relay DNS → Server transfer: routes queries (evidence: `README.md`)
- Client transfer → DNS codec: uses DNS packets
- Server transfer → DNS codec: encodes replies
- Client transfer → Hostname encoding: encodes data (evidence: `src/client.c`)
- Hostname encoding → Base32: uses codec
- Hostname encoding → Base64: uses codec
- Hostname encoding → Base128: uses codec
- Client setup → Authentication: sets password
- Authentication → MD5: uses digest (evidence: `src/login.c`)
- Server transfer → User sessions: tracks sessions (evidence: `src/iodined.c`)
- Client transfer → Raw-mode probe: tests raw mode
- Client transfer → TUN interface: reads and writes
- Server transfer → TUN interface: reads and writes
- TUN interface → IPv4 network: transfers IPv4 (evidence: `README.md`)
- Windows TUN → IPv4 network: transfers IPv4
- Client transfer → Relay DNS: raw UDP fallback (evidence: `README.md`)
- Server transfer → DNS sockets: listens for DNS (evidence: `README.md`)
- Client transfer → Packet utilities: uses packet helpers
