Addressing in Config.xml via API

I’m having an issue with modifying some addresses in the syncthing.xml file via the API.

If I set the address fields, it’s accepted by the API; however, the fields revert to either default (for device tags) or tcp://default for the options/listenAddress.

In the end case, I’m trying to use Ansible to config Syncthing. I did take it to the raw bash command line to test with the same results.

I feel as though I’m missing something; however, I can’t seem to track it down.

Any assistance would be much appreciated.

Make sure that you only mutate the config you get out of syncthing. If you are constructing it yourself, you’re in for a disappointment, as every time we add a new field, and you not including it, will probably result in the config being refused.

Thanks for the response.

The config isn’t being refused. I can set up the other device properties and folders correctly.

I will revert to mutating the config as a whole and take it from there.

Perhaps it’s being overwritten by something. You can run syncthing with STTRACE=config and see what’s happening in the logs.

Thank you for your help with this and my apologies for the delay. I was tasked with another fire before I could return to this.

I set my environmental variables to STTRACE=config, connections, main, http

Below is the result. I apologize for the length but I tried to get as much as I could to be helpful.

[XUDDR] 2018/06/13 11:00:31.814893 limiter.go:84: INFO: Send rate is unlimited, receive rate is unlimited [XUDDR] 2018/06/13 11:00:31.814924 limiter.go:89: INFO: Rate limits do not apply to LAN connections [XUDDR] 2018/06/13 11:00:31.815036 service.go:491: DEBUG: Starting listener tcp://default [XUDDR] 2018/06/13 11:00:31.815893 service.go:305: DEBUG: Reconnect loop [XUDDR] 2018/06/13 11:00:31.815940 service.go:342: DEBUG: Reconnect loop for XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP [] [XUDDR] 2018/06/13 11:00:31.815957 service.go:423: DEBUG: initial rampup; sleep 1s and update to 2s [XUDDR] 2018/06/13 11:00:31.833170 gui.go:373: INFO: GUI and API listening on [::]:8384 [XUDDR] 2018/06/13 11:00:31.833269 gui.go:374: INFO: Access the GUI via the following URL: http://127.0.0.1:8384/ [XUDDR] 2018/06/13 11:00:31.833448 main.go:861: INFO: Device XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP is “10.10.160.32” at [dynamic] [XUDDR] 2018/06/13 11:00:31.833511 main.go:861: INFO: Device XUDDRUB-5A42OSA-24SDZY7-OTIBJRJ-MLBO3JY-ZG3ORHU-JU3KLMW-EWZXCA2 is “nocvm” at [dynamic] [XUDDR] 2018/06/13 11:00:31.833937 wrapper.go:156: DEBUG: ProgressEmitter@0xc420091720 verifying configuration [XUDDR] 2018/06/13 11:00:31.833996 wrapper.go:156: DEBUG: model@0xc42009c7e0 verifying configuration [XUDDR] 2018/06/13 11:00:31.834038 wrapper.go:156: DEBUG: connections.limiter verifying configuration [XUDDR] 2018/06/13 11:00:31.834095 wrapper.go:156: DEBUG: connections.Service verifying configuration [XUDDR] 2018/06/13 11:00:31.834155 wrapper.go:156: DEBUG: apiService@0xc42009cb40 verifying configuration [XUDDR] 2018/06/13 11:00:31.835979 wrapper.go:183: DEBUG: ProgressEmitter@0xc420091720 committing configuration [XUDDR] 2018/06/13 11:00:31.836066 wrapper.go:183: DEBUG: model@0xc42009c7e0 committing configuration [XUDDR] 2018/06/13 11:00:31.836348 wrapper.go:183: DEBUG: connections.limiter committing configuration [XUDDR] 2018/06/13 11:00:31.836421 wrapper.go:183: DEBUG: connections.Service committing configuration [XUDDR] 2018/06/13 11:00:31.836521 wrapper.go:183: DEBUG: apiService@0xc42009cb40 committing configuration [XUDDR] 2018/06/13 11:00:31.848641 tcp_listen.go:55: INFO: Listen (BEP/tcp): lookup default on 8.8.8.8:53: no such host [XUDDR] 2018/06/13 11:00:31.848851 service.go:106: INFO: c.S.listenerSupervisor: Failed service ‘tcp://default:22000’ (1.000000 failures of 2.000000), restarting: true, error: “{tcp://default:22000 tcp://default:22000} returned unexpectedly”, stacktrace: [unknown stack trace] [XUDDR] 2018/06/13 11:00:31.878535 tcp_listen.go:55: INFO: Listen (BEP/tcp): lookup default on 8.8.8.8:53: no such host [XUDDR] 2018/06/13 11:00:31.878659 service.go:106: INFO: c.S.listenerSupervisor: Failed service ‘tcp://default:22000’ (1.999310 failures of 2.000000), restarting: true, error: “{tcp://default:22000 tcp://default:22000} returned unexpectedly”, stacktrace: [unknown stack trace] [XUDDR] 2018/06/13 11:00:31.914485 tcp_listen.go:55: INFO: Listen (BEP/tcp): lookup default on 8.8.8.8:53: no such host [XUDDR] 2018/06/13 11:00:31.914586 service.go:130: INFO: Entering the backoff state. [XUDDR] 2018/06/13 11:00:31.914663 service.go:106: INFO: c.S.listenerSupervisor: Failed service ‘tcp://default:22000’ (2.997650 failures of 2.000000), restarting: false, error: “{tcp://default:22000 tcp://default:22000} returned unexpectedly”, stacktrace: [unknown stack trace] [XUDDR] 2018/06/13 11:00:31.925916 folder.go:152: INFO: Completed initial scan of readwrite folder “ticketing” (ticketing) [XUDDR] 2018/06/13 11:00:31.939048 folder.go:152: INFO: Completed initial scan of readwrite folder “c2” (c2) [XUDDR] 2018/06/13 11:00:32.816090 service.go:305: DEBUG: Reconnect loop [XUDDR] 2018/06/13 11:00:32.816130 service.go:342: DEBUG: Reconnect loop for XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP [] [XUDDR] 2018/06/13 11:00:32.816145 service.go:423: DEBUG: initial rampup; sleep 2s and update to 4s [XUDDR] 2018/06/13 11:00:34.833312 service.go:305: DEBUG: Reconnect loop [XUDDR] 2018/06/13 11:00:34.833360 service.go:342: DEBUG: Reconnect loop for XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP [] [XUDDR] 2018/06/13 11:00:34.833378 service.go:423: DEBUG: initial rampup; sleep 4s and update to 8s [XUDDR] 2018/06/13 11:00:38.708918 folder.go:152: INFO: Completed initial scan of readwrite folder “cswapi_c2” (cswapi_c2) [XUDDR] 2018/06/13 11:00:38.833686 service.go:305: DEBUG: Reconnect loop [XUDDR] 2018/06/13 11:00:38.833745 service.go:342: DEBUG: Reconnect loop for XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP [] [XUDDR] 2018/06/13 11:00:38.833762 service.go:423: DEBUG: initial rampup; sleep 8s and update to 16s [XUDDR] 2018/06/13 11:00:46.834011 service.go:305: DEBUG: Reconnect loop [XUDDR] 2018/06/13 11:00:46.834300 service.go:342: DEBUG: Reconnect loop for XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP [] [XUDDR] 2018/06/13 11:00:46.834527 service.go:423: DEBUG: initial rampup; sleep 16s and update to 32s [XUDDR] 2018/06/13 11:01:02.838509 service.go:305: DEBUG: Reconnect loop [XUDDR] 2018/06/13 11:01:02.838584 service.go:342: DEBUG: Reconnect loop for XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP [] [XUDDR] 2018/06/13 11:01:02.838614 service.go:423: DEBUG: initial rampup; sleep 32s and update to 1m4s [XUDDR] 2018/06/13 11:01:04.917607 folder.go:152: INFO: Completed initial scan of readwrite folder “cswapi_ticketing” (cswapi_ticketing) [XUDDR] 2018/06/13 11:01:26.995887 wrapper.go:156: DEBUG: ProgressEmitter@0xc420091720 verifying configuration [XUDDR] 2018/06/13 11:01:26.995924 wrapper.go:156: DEBUG: model@0xc42009c7e0 verifying configuration [XUDDR] 2018/06/13 11:01:26.995935 wrapper.go:156: DEBUG: connections.limiter verifying configuration [XUDDR] 2018/06/13 11:01:26.995964 wrapper.go:156: DEBUG: connections.Service verifying configuration [XUDDR] 2018/06/13 11:01:26.995976 wrapper.go:156: DEBUG: apiService@0xc42009cb40 verifying configuration [XUDDR] 2018/06/13 11:01:26.995996 wrapper.go:156: DEBUG: usageReportingService verifying configuration [XUDDR] 2018/06/13 11:01:26.996169 wrapper.go:183: DEBUG: connections.limiter committing configuration [XUDDR] 2018/06/13 11:01:26.996250 wrapper.go:183: DEBUG: ProgressEmitter@0xc420091720 committing configuration [XUDDR] 2018/06/13 11:01:26.996299 wrapper.go:183: DEBUG: model@0xc42009c7e0 committing configuration [XUDDR] 2018/06/13 11:01:26.996680 wrapper.go:183: DEBUG: connections.Service committing configuration [XUDDR] 2018/06/13 11:01:26.996737 wrapper.go:183: DEBUG: apiService@0xc42009cb40 committing configuration [XUDDR] 2018/06/13 11:01:26.996761 gui.go:403: DEBUG: restarting (config changed) [XUDDR] 2018/06/13 11:01:26.997318 main.go:596: DEBUG: main: Failed service ‘apiService@0xc42009cb40’ (1.000000 failures of 5.000000), restarting: true, error: “{apiService@0xc42009cb40 apiService@0xc42009cb40} returned unexpectedly”, stacktrace: [unknown stack trace] [XUDDR] 2018/06/13 11:01:26.997616 gui.go:475: DEBUG: http: POST “/rest/system/config”: status 0, 0 bytes in 2.63 ms [XUDDR] 2018/06/13 11:01:26.998758 gui.go:373: INFO: GUI and API listening on [::]:8384 [XUDDR] 2018/06/13 11:01:26.998792 gui.go:374: INFO: Access the GUI via the following URL: http://127.0.0.1:8384/ [XUDDR] 2018/06/13 11:01:26.999020 wrapper.go:183: DEBUG: usageReportingService committing configuration [XUDDR] 2018/06/13 11:01:34.838892 service.go:305: DEBUG: Reconnect loop [XUDDR] 2018/06/13 11:01:34.838966 service.go:342: DEBUG: Reconnect loop for XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP [] [XUDDR] 2018/06/13 11:01:34.838990 service.go:427: DEBUG: sleep until next dial 1m0s [XUDDR] 2018/06/13 11:02:34.839360 service.go:305: DEBUG: Reconnect loop [XUDDR] 2018/06/13 11:02:34.839440 service.go:342: DEBUG: Reconnect loop for XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP [] [XUDDR] 2018/06/13 11:02:34.839463 service.go:427: DEBUG: sleep until next dial 1m0s [XUDDR] 2018/06/13 11:03:34.839692 service.go:305: DEBUG: Reconnect loop [XUDDR] 2018/06/13 11:03:34.839746 service.go:342: DEBUG: Reconnect loop for XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP [] [XUDDR] 2018/06/13 11:03:34.839762 service.go:427: DEBUG: sleep until next dial 1m0s

The JSON config string is:

curl -k -vvv -X POST -H “X-API-Key:WVKjJqCRUW63TXYtNxqaUNMezeHDFNWS” -d ‘{“folders”: [{“path”: “/var/www/c2”, “type”: “readwrite”, “id”: “c2”, “devices”: [{“deviceID”: “XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP”}, {“deviceID”: “XUDDRUB-5A42OSA-24SDZY7-OTIBJRJ-MLBO3JY-ZG3ORHU-JU3KLMW-EWZXCA2”}], “label”: “c2”}, {“path”: “/var/www/cswapi_ticketing”, “type”: “readwrite”, “id”: “cswapi_ticketing”, “devices”: [{“deviceID”: “XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP”}, {“deviceID”: “XUDDRUB-5A42OSA-24SDZY7-OTIBJRJ-MLBO3JY-ZG3ORHU-JU3KLMW-EWZXCA2”}], “label”: “cswapi_ticketing”}, {“path”: “/var/www/cswapi_c2”, “type”: “readwrite”, “id”: “cswapi_c2”, “devices”: [{“deviceID”: “XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP”}, {“deviceID”: “XUDDRUB-5A42OSA-24SDZY7-OTIBJRJ-MLBO3JY-ZG3ORHU-JU3KLMW-EWZXCA2”}], “label”: “cswapi_c2”}, {“path”: “/var/www/ticketing”, “type”: “readwrite”, “id”: “ticketing”, “devices”: [{“deviceID”: “XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP”}, {“deviceID”: “XUDDRUB-5A42OSA-24SDZY7-OTIBJRJ-MLBO3JY-ZG3ORHU-JU3KLMW-EWZXCA2”}], “label”: “ticketing”}], “gui”: {“password”: “$2b$12$zvBmIfbr715UYSoqRvKIwOWrWV/3wNmoeoKmR4FOIb8yhRqUY2gTG”, “enabled”: true, “user”: “c2-failover”, “address”: “0.0.0.0:8384”}, “options”: {“urSeen”: 3, “urAccepted”: -1, “globalAnnounceEnabled”: false, “localAnnounceEnabled”: false, “relaysEnabled”: false, “listenAddress”: “tcp://127.0.0.1:22000”, “natEnabled”: false}, “devices”: [{“deviceID”: “XQGBYZK-BBQMJEF-3VN56UM-FIGM7RF-2MHLXL6-EKPSGEU-MRZE5CO-5G3V2QP”, “compression”: “metadata”, “name”: “10.10.160.32”, “address”: “tcp://10.10.160.32”}, {“deviceID”: “XUDDRUB-5A42OSA-24SDZY7-OTIBJRJ-MLBO3JY-ZG3ORHU-JU3KLMW-EWZXCA2”, “compression”: “metadata”, “name”: “nocvm”, “address”: “tcp://10.10.160.31”}]}’ https://127.0.0.1:8384/rest/system/config

Thank you.

Ok, I figured it out. It comes down to me being an absolute idiot. I had the wrong key for the address for each device. Instead of using GET to actually see what was being used, I looked at the config (which only has “Address”) forgetting that the API probably just loops over the json array and inserts a separate address for each key->value pair. Could have saved a lot of headaches by simply RTFM.

Apologies for wasting your time. Hopefully, this keeps others from banging their heads.

1 Like

Again, that’s why I suggested mutating the value you get back from the API

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.