amnezia-vpn / amnezia-client

Amnezia VPN Client (Desktop+Mobile)
https://amnezia.org
GNU General Public License v3.0
5.89k stars 373 forks source link

Specification and implementation of api_endpoint /api/v1/request/awg #1017

Open atomlab opened 3 months ago

atomlab commented 3 months ago

AmneziaVPN provides parameters for API requests to obtain configuration in vpn:// format through a Telegram bot. To decode these parameters, you can use the decoder code (https://github.com/andr13/amnezia-config-decoder).

python3 ./amnezia-config-decoder.py vpn://eyJjb25maWd...Y4UEgifQ==

As a result, you will get the following:

{
    "config_version": 1.0,
    "api_endpoint": "https://<server_ip>/api/v1/request/awg/",
    "protocol": "awg",
    "name": "AmneziaFree RU",
    "description": "AmneziaFree for Russia",
    "api_key": "<api_key>"
}

Please indicate where I can find the API specifications and implementation at the endpoint /api/v1/request/awg, so I can set up my own API server.

Note that API support is present in the file amnezia-client/client/core/controllers/apiController.cpp:

https://github.com/amnezia-vpn/amnezia-client/blob/3458ed78d7d3f80a7b0b11f33462b355db93668f/client/core/controllers/apiController.cpp#L23

folez commented 3 weeks ago

@atomlab Didn't find where the API specification is?

atomlab commented 3 weeks ago

folez

Unfortunately, I did not find any open implementation of the Amnezia API. In order to create my own implementation, it is necessary to find out what actions are performed on the server in Docker containers to generate configuration files and send them to the client. While studying the process, I found that the client sends a public key, which is then integrated into the main configuration file wg.conf on the server.

I hope that the developers will soon publish their API implementation. This would be preferable, as the API should evolve with the changes occurring in each new release to ensure compatibility.