# xiu2/cloudflarespeedtest architecture

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

- Interactive diagram: https://gitdiagram.com/xiu2/cloudflarespeedtest
- Repository: https://github.com/xiu2/cloudflarespeedtest

## Overview

CloudflareSpeedTest is a command-line tool for finding fast, low-latency CDN or website IPs. Its main workflow loads IP ranges, probes candidates by TCP or optional HTTP, filters and ranks the latency results, optionally measures download speed, then prints and exports the results. The README also documents IPv4/IPv6 input, configurable test parameters, region filtering, and CSV output. The graph follows the sampled runtime calls; ancillary scripts are omitted because their behavior and connections were not sampled.

Main entry points: [`main.go`](https://github.com/xiu2/cloudflarespeedtest/blob/master/main.go) (CLI workflow), [`task/tcping.go`](https://github.com/xiu2/cloudflarespeedtest/blob/master/task/tcping.go) (Probe coordinator), [`task/download.go`](https://github.com/xiu2/cloudflarespeedtest/blob/master/task/download.go) (Download speed tests), [`task/ip.go`](https://github.com/xiu2/cloudflarespeedtest/blob/master/task/ip.go) (IP range loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI orchestration"]
  node_main["CLI workflow<br/>[main.go]"]
end

subgraph group_probe["Candidate testing"]
  node_iploader["IP range loader<br/>[ip.go]"]
  node_ping["Probe coordinator<br/>[tcping.go]"]
  node_tcp["TCP probes<br/>[tcping.go]"]
  node_http["HTTP probes<br/>[httping.go]"]
  node_download["Download speed tests<br/>[download.go]"]
end

subgraph group_results["Results and filtering"]
  node_filters["Latency and loss filters<br/>[csv.go]"]
  node_ranking["Speed ranking<br/>[download.go]"]
  node_csv["CSV and console output<br/>[csv.go]"]
end

subgraph group_support["Runtime support"]
  node_progress["Progress display<br/>[progress.go]"]
end

node_user(("CLI user"))
node_ranges["IP ranges<br/>[ip.txt]"]
node_target(("CDN or website"))

node_user -->|"runs"| node_main
node_main -->|"starts probes"| node_ping
node_ping -->|"loads candidates"| node_iploader
node_iploader -->|"reads ranges"| node_ranges
node_ping -->|"runs TCP probes"| node_tcp
node_ping -->|"dispatches HTTP"| node_http
node_tcp -->|"opens TCP connections"| node_target
node_http -->|"sends HTTP requests"| node_target
node_main -->|"filters results"| node_filters
node_main -->|"tests download speed"| node_download
node_download -->|"downloads test data"| node_target
node_download -->|"sorts by speed"| node_ranking
node_main -->|"exports and prints"| node_csv
node_ping -->|"updates progress"| node_progress
node_download -->|"updates progress"| node_progress

click node_main "https://github.com/xiu2/cloudflarespeedtest/blob/master/main.go"
click node_iploader "https://github.com/xiu2/cloudflarespeedtest/blob/master/task/ip.go"
click node_ranges "https://github.com/xiu2/cloudflarespeedtest/blob/master/ip.txt"
click node_ping "https://github.com/xiu2/cloudflarespeedtest/blob/master/task/tcping.go"
click node_tcp "https://github.com/xiu2/cloudflarespeedtest/blob/master/task/tcping.go"
click node_http "https://github.com/xiu2/cloudflarespeedtest/blob/master/task/httping.go"
click node_filters "https://github.com/xiu2/cloudflarespeedtest/blob/master/utils/csv.go"
click node_download "https://github.com/xiu2/cloudflarespeedtest/blob/master/task/download.go"
click node_ranking "https://github.com/xiu2/cloudflarespeedtest/blob/master/task/download.go"
click node_csv "https://github.com/xiu2/cloudflarespeedtest/blob/master/utils/csv.go"
click node_progress "https://github.com/xiu2/cloudflarespeedtest/blob/master/utils/progress.go"

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_main,node_user toneBlue
class node_iploader,node_ping,node_tcp,node_http,node_download toneAmber
class node_filters,node_ranking,node_csv toneMint
class node_progress toneRose
class node_ranges toneTeal
class node_target toneIndigo
```

## Components

### CLI orchestration

- [CLI workflow](https://github.com/xiu2/cloudflarespeedtest/blob/master/main.go): `main.go`

### Candidate testing

- [IP range loader](https://github.com/xiu2/cloudflarespeedtest/blob/master/task/ip.go): `task/ip.go`
- [Probe coordinator](https://github.com/xiu2/cloudflarespeedtest/blob/master/task/tcping.go): `task/tcping.go`
- [TCP probes](https://github.com/xiu2/cloudflarespeedtest/blob/master/task/tcping.go): `task/tcping.go`
- [HTTP probes](https://github.com/xiu2/cloudflarespeedtest/blob/master/task/httping.go): `task/httping.go`
- [Download speed tests](https://github.com/xiu2/cloudflarespeedtest/blob/master/task/download.go): `task/download.go`

### Results and filtering

- [Latency and loss filters](https://github.com/xiu2/cloudflarespeedtest/blob/master/utils/csv.go): `utils/csv.go`
- [Speed ranking](https://github.com/xiu2/cloudflarespeedtest/blob/master/task/download.go): `task/download.go`
- [CSV and console output](https://github.com/xiu2/cloudflarespeedtest/blob/master/utils/csv.go): `utils/csv.go`

### Runtime support

- [Progress display](https://github.com/xiu2/cloudflarespeedtest/blob/master/utils/progress.go): `utils/progress.go`

### Other components

- **CLI user**
- [IP ranges](https://github.com/xiu2/cloudflarespeedtest/blob/master/ip.txt): `ip.txt`
- **CDN or website**

## Connections

- CLI user → CLI workflow: runs (evidence: `README.md`)
- CLI workflow → Probe coordinator: starts probes (evidence: `main.go`)
- Probe coordinator → IP range loader: loads candidates (evidence: `task/tcping.go`)
- IP range loader → IP ranges: reads ranges (evidence: `task/ip.go`)
- Probe coordinator → TCP probes: runs TCP probes (evidence: `task/tcping.go`)
- Probe coordinator → HTTP probes: dispatches HTTP (evidence: `task/tcping.go`)
- TCP probes → CDN or website: opens TCP connections (evidence: `task/tcping.go`)
- HTTP probes → CDN or website: sends HTTP requests (evidence: `task/httping.go`)
- CLI workflow → Latency and loss filters: filters results (evidence: `main.go`)
- CLI workflow → Download speed tests: tests download speed (evidence: `main.go`)
- Download speed tests → CDN or website: downloads test data (evidence: `task/download.go`)
- Download speed tests → Speed ranking: sorts by speed (evidence: `task/download.go`)
- CLI workflow → CSV and console output: exports and prints (evidence: `main.go`)
- Probe coordinator → Progress display: updates progress (evidence: `task/tcping.go`)
- Download speed tests → Progress display: updates progress (evidence: `task/download.go`)
