Closed freerko closed 2 years ago
Hi @freerko,
The front-end GUI sets the index to 0. Basically in the config.json
you have INSTANCE.IP.GLOBAL.ADDRESS.IPV4
. This is an array of your public IPv4 addresses for your server. You would generally only have one string in the array unless you have multiple.
When calling the API, you would use the index rather than the IP, so if you had ["publicIP1", "publicIP2"] in the config, to use publicIP1
you would set ipIndex as 0. if you wanted publicIP2
, you would use ipIndex set to 1. (ipIndex is an integer btw)
Basically your public IPs are stored in the config.json, not the database. Please let me know if you have any further questions.
curl --request POST \
--url https://server.one:8443/manager/key \
--header 'Content-Type: application/json' \
--data '{
"publicKey": "YE21+UDp3AVrUlga2uzlaqGbdV/sMiY8E0iCgfiDDmE=",
"presharedKey": "AE28+FAp3LVrUiga1uatwaGbsV/sMiY8E0iCdfiDDaE=",
"bwLimit": 1000,
"subExpiry": "2022-Oct-28 12:39:05 PM",
"ipIndex": 0
}'
Ahh, I thought the ipIndex is the local IP you want to use for that client, but it is for selecting a potential other public IP, now it makes sense! Apparently my curl formating was wrong as well, with your example it works, thanks!
Hi,
thanks again for your project, I got the docker-compose running but am unable to add keys:
root@server ~ # curl -X POST -H "Content-Type: application/json" -d '{"publicKey": "0AYPFxOJtFumrUGwERWxPOHN26FvCq1RGwE/loji7no=","presharedKey": "1DKCLcUVEwglPHDUqexY22VLKtq412TwAX/YnLxKg8c=","bwLimit": 0,"subExpiry": "2022-Mar-29 12:39:05 PM","ipIndex": "10.6.1.4"}' https://mydomain.com:8443/manager/keys
returns: 404 page not foundI don't understand what you refer to with "the integer index of the ip address you want to use" to put as "ipIndex". I tried the above example which didn't work and then changed it to "3" but had the same result. I looked into the database with
sqlite3 /opt/wgManagerAPI/wg/wireguardPeers.db
andselect * from ips;
and din't see any form of database index, just the plain IPs. I noticed that in your new GUI there is no such ipIndex form field when adding keys and I would prefer to have the selection of IPs completely automatically.Any idea why this is failing? A simple
curl https://mydomain.com:8443/manager/key
seems to work fine, it returns{"Response":"All key successfully parsed","Keys":[]}
.