Skip to content

Commit 6007c7f

Browse files
authored
Revise README for usage and configuration clarity
Updated usage instructions and configuration details in README.
1 parent 9b72d73 commit 6007c7f

1 file changed

Lines changed: 159 additions & 10 deletions

File tree

README.md

Lines changed: 159 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A [dreamhost](https://dreamhost.com) API key is required. To obtain one, follow
88

99
## Download & Setup
1010
1. Choose the appropriate architecture inside the [binaries](/binaries) directory and download the contents (both files)
11-
3. Open and edit the config.toml file with your personal credentials and DNS A record
11+
2. Optionally open and edit the config.toml file with your personal credentials and DNS A record
1212
<br><br>
1313

1414
## Usage
@@ -19,29 +19,178 @@ Usage: dreamhost-ddns.exe [OPTIONS]
1919
2020
Options:
2121
-v, --verbose
22-
-c, --config <CONFIG> [default: config.toml]
23-
--dry-run
22+
--log-level <LOG_LEVEL> [possible values: error, warn, info, debug, trace]
23+
-c, --config <CONFIG>
2424
--api-key <API_KEY>
2525
--record <RECORD>
26-
-h, --help Print help
27-
-V, --version Print version
26+
--dry-run
27+
-h, --help Print help
28+
-V, --version Print version
2829
```
30+
<br><br>
31+
2932
### Linux / Others
3033
```
31-
Usage: dreamhost-ddns.exe [OPTIONS]
34+
Usage: dreamhost-ddns [OPTIONS]
3235
3336
Options:
3437
-v, --verbose
35-
-c, --config <CONFIG> [default: config.toml]
36-
--dry-run
38+
--log-level <LOG_LEVEL> [possible values: error, warn, info, debug, trace]
39+
-c, --config <CONFIG>
3740
--api-key <API_KEY>
3841
--record <RECORD>
39-
-h, --help Print help
40-
-V, --version Print version
42+
--dry-run
43+
-h, --help Print help
44+
-V, --version Print version
4145
```
4246
You will likely need to make the dreamhost-ddns file executable first:
4347
```bash
4448
chmod +x dreamhost-ddns
4549
```
4650

4751
Note: When setting this up as a cronjob, it is recommended that you use the --config flag in the crontab entry, and specify the FULL path to your config.toml file
52+
<br><br>
53+
54+
55+
## Configuration
56+
Configuration is quite flexible, suitable for any situation
57+
58+
When using a .toml (or config.toml) file, it should be in the following format:
59+
```toml
60+
dreamhost_api_key = "ENTER-YOUR-DREAMHOST-API-KEY-HERE"
61+
dns_record = "ENTER-THE-TARGET-DNS-A-RECORD"
62+
```
63+
If you've placed a file named **config.toml** into the same directory as the executable, you can run the program simply:
64+
```bash
65+
$ ./dreamhost-ddns
66+
```
67+
If you've named the .toml file differently, or placed it in a different direcory, you can execute the program like this:
68+
```bash
69+
$ ./dreamhost-ddns --config /path/to/my/config/myconfig.toml
70+
```
71+
<br><br>
72+
To override a value in your config file, or to bypass the usage of a config file completely, you can pass the required arguments directly.
73+
74+
In this example, a .toml config file is not required:
75+
```bash
76+
$ ./dreamhost-ddns --api-key 8SIX753OH9 --record jenny.mydomain.com
77+
```
78+
79+
Values passed in the command line will override values from your configuration file. In this example, your config file is used only for the API Key, but not for the record:
80+
```bash
81+
$ ./dreamhost-ddns --record jenny.mydomain.com
82+
```
83+
<br><br>
84+
85+
## Important Notes
86+
### Dreamhost API Rate limiting
87+
The dreamhost API is limited to 500 calls daily. This DDNS client makes a minimum of one API call per run, and between four and eight calls (typically four) when updating the DNS record. When scheduling this to run, please keep this in mind when deciding how often to run. When reaching this limit, you will see this error message:
88+
```txt
89+
Error: DreamHost API error: rate error: module dns used more than 500 times in 1 day(s)
90+
```
91+
92+
### Crontab recommendation
93+
It is recommended to pass a configuration file parameter when defining the crontab entry even if you are using the default of config.toml. It is also recommended to set a sane yet aggressive scheduling interval. For example, this would run every 10 minutes:
94+
```cron
95+
*/10 * * * * /opt/dreamhost-ddns --config /opt/config.toml >> /var/log/dreamhost-ddns.log 2>&1
96+
```
97+
98+
<br><br>
99+
## Under the Hood
100+
### TL/DR:
101+
At the highest level, this is the execution flow:
102+
```txt
103+
Detect WAN IP
104+
105+
106+
Get current DNS record IP
107+
108+
109+
Compare values
110+
111+
├─ same → exit
112+
113+
└─ different
114+
115+
116+
Safely update DNS
117+
```
118+
<br><br>
119+
### Basic execution is as follows:
120+
```txt
121+
main()
122+
123+
├─ parse CLI args
124+
125+
├─ configure logging
126+
127+
├─ resolve configuration
128+
│ ├─ CLI args
129+
│ ├─ env vars
130+
│ ├─ config file
131+
│ └─ default config.toml
132+
133+
├─ build HTTP client
134+
135+
├─ create DreamhostClient
136+
137+
├─ detect WAN IP
138+
│ └─ parallel IP service queries
139+
140+
├─ fetch DNS record IP
141+
│ └─ DreamHost API
142+
143+
├─ compare WAN vs DNS
144+
│ │
145+
│ ├─ match → exit
146+
│ │
147+
│ └─ mismatch
148+
│ │
149+
│ ├─ dry-run → log only
150+
│ │
151+
│ └─ update_dns()
152+
153+
└─ exit
154+
```
155+
<br><br>
156+
157+
### Detecting WAN IP
158+
Multiple services are queried simultaneously to determine your WAN IP. If your firewall is blocking all of these services, the application will fail:
159+
- https://icanhazip.com
160+
- https://api.ipify.org
161+
- https://ifconfig.me/ip
162+
- https://checkip.amazonaws.com
163+
164+
This is how those are used
165+
```txt
166+
get_wan_ip()
167+
168+
├─ shuffle service list
169+
170+
├─ spawn parallel threads
171+
172+
├─ query IP services
173+
174+
├─ first successful response wins
175+
176+
└─ cancel remaining workers
177+
```
178+
<br><br>
179+
180+
### Updating DNS
181+
In the best case scenario, three API calls are made to update the DNS record. For safety reasons, a verification is done before the old DNS record is removed. If the verification fails, it is retried up to five times which involves one additional API call each time.
182+
```txt
183+
update_dns()
184+
185+
├─ add new DNS record
186+
187+
├─ wait for propagation
188+
189+
├─ verify new record exists
190+
│ │
191+
│ ├─ retry up to 5 times
192+
│ │
193+
│ └─ fail → abort update
194+
195+
└─ remove old DNS record
196+
```

0 commit comments

Comments
 (0)