timothymiller / cloudflare-ddns

🎉🌩️ Dynamic DNS (DDNS) service based on Cloudflare! Access your home network remotely via a custom domain name without a static IP!
https://timknowsbest.com/free-dynamic-dns
GNU General Public License v3.0
3.01k stars 316 forks source link

Error reading config.json #129

Closed VolcanicMG closed 1 year ago

VolcanicMG commented 1 year ago

Hello, for some reason I keep getting an error saying the config.json can't be read. I have the config.json file located within the cloudflareDDNS folder. Am I missing something? Here is my docker-compose:

> version: '3.9'
> services:
>   cloudflare-ddns:
>     image: timothyjmiller/cloudflare-ddns:latest
>     container_name: cloudflare-ddns
>     security_opt:
>       - no-new-privileges:true
>     network_mode: 'host'
>     environment:
>       - PUID=1000
>       - PGID=1000
>     volumes:
>       - /cloudflareDDNS/config.json:/config.json
>     restart: unless-stopped

Config.json:

> {
>   "cloudflare": [
>     {
>       "authentication": {
>         "api_token": "*Privated*",
>         }
>       },
>       "zone_id": "*Privated*",
>       "subdomains": [
>         {
>           "name": "panel",
>           "proxied": true
>         }
>       ]
>     }
>   ],
>   "a": true,
>   "aaaa": true,
>   "purgeUnknownRecords": false,
>   "ttl": 300
> }
jpmeijers commented 1 year ago

I just ran into the same error. Busy debugging it now.

Edit: I ran my config file through https://jsonlint.com/ and found a comma that shouldn't have been there. I see your config file has the same exact comma also there, at the end of "api_token": "*Privated*",. I removed it and now the container runs correctly.

VolcanicMG commented 1 year ago

Yep your right, I checked for that too since I removed stuff guess that one slipped past my sleepy eyes haha

timothymiller commented 1 year ago

Running your config through a JSON linter is a good idea @jpmeijers

Can you confirm @VolcanicMG if checking your config with a linter helps?

VolcanicMG commented 1 year ago

Running your config through a JSON linter is a good idea @jpmeijers

Can you confirm @VolcanicMG if checking your config with a linter helps?

Once I get some free time I'll give it a check. I'm more than positive that was the issue.

VolcanicMG commented 1 year ago

Running your config through a JSON linter is a good idea @jpmeijers

Can you confirm @VolcanicMG if checking your config with a linter helps?

After running it through the JSON linter, with positive results, I still get the error within the console. Here is the updated config.json

> {
>   "cloudflare": [{
>       "authentication": {
>           "api_token": "*private*"
>       },
>       "zone_id": "*private*",
>       "subdomains": [{
>           "name": "panel",
>           "proxied": false
>       }]
>   }],
>   "a": true,
>   "aaaa": true,
>   "purgeUnknownRecords": false,
>   "ttl": 300
> }

EDIT: I didn't add the home directory to the path, fixed now!

Nevah5 commented 5 months ago

Hmm weird, I cannot manage to get it to work still. I tried the following things:

  1. Linting the JSON file for errors (none found)
  2. Running the container as root
  3. chmod +r config.json
root@pulsar:/etc/cloudflare-ddns# ls -lah
total 16K
drwxr-xr-x  2 root root 4.0K Mar 30 19:22 .
drwxr-xr-x 96 root root 4.0K Mar 30 19:10 ..
-rw-r--r--  1 root root  513 Mar 30 19:22 config.json

Maybe something has changed between the version I was using before and the current one. This is why you should version pin your images...

Edit: It seems like nothing has changed. I will try to debug the code to see what else could cause this.