Decoding an AmneziaVPN link, such as `vpn://AAAH2Xjan...`, requires specific tools because the encoding scheme is custom and not standard Base64. This response details how to decode these links using Linux command-line tools and Python, how to determine the VPN protocol, and what documentation is available.

### Understanding the `vpn://` Link Format

AmneziaVPN uses a custom encoding scheme for its `vpn://` links. These links are not always standard Base64-encoded strings and may include additional metadata or proprietary encoding. The `vpn://` prefix indicates a custom URI scheme, and the subsequent string is encoded using a method specific to AmneziaVPN. The encoded data typically includes VPN server details, protocol information (e.g., WireGuard, OpenVPN), and authentication keys or other configuration data.

### Decoding with the Amnezia Config Decoder Script

The most reliable method to decode these links is by using the [Amnezia Config Decoder & Encoder](https://github.com/andr13/amnezia-config-decoder) script, a Python tool designed for this purpose. Here’s how to use it:

1. **Clone the Repository:**
    
    ```bash
    git clone https://github.com/andr13/amnezia-config-decoder.git
    cd amnezia-config-decoder
    ```

2. **Ensure Python is Installed:**  
    Make sure you have Python 3.12 or higher installed. You can check your version with:
    
    ```bash
    python3 --version
    ```

3. **Run the Decoding Script:**  
    To decode the link and save the output to a JSON file, use:
    
    ```bash
    python3 amnezia-config-decoder.py vpn://AAAH2Xjan... -o output.json
    ```
    Replace `vpn://AAAH2Xjan...` with your actual link. The `-o output.json` flag saves the decoded configuration to a file named `output.json`. If you omit the `-o` option, the decoded JSON will be printed to the console.
    
    ```bash
    python3 amnezia-config-decoder.py vpn://AAAH2Xjan...
    ```

### Decoding with Linux Command-Line Tools

If the Amnezia Config Decoder script is unavailable, you can attempt to decode the `vpn://` link using standard Linux tools. However, keep in mind that the link may not be a pure Base64 string, and this method may only partially work.

1. **Remove the `vpn://` Prefix:**
    
    ```bash
    echo "vpn://AAAH2Xjan..." | sed 's/vpn:\/\///' > encoded.txt
    ```

2. **Attempt Base64 Decoding:**
    
    ```bash
    base64 -d encoded.txt > decoded.txt
    ```

3. **Inspect the Decoded Output:**
    
    ```bash
    cat decoded.txt
    ```
    If the output is not readable, the string likely uses a custom encoding, and the Amnezia Config Decoder script is the recommended approach.

### Determining the VPN Protocol

Once you have decoded the `vpn://` link, the output (typically in JSON format) will include details about the VPN configuration, including the protocol. Look for keywords such as:

- `"protocol": "WireGuard"`
- `"protocol": "OpenVPN"`
- `"protocol": "Shadowsocks"`
- `"protocol": "IKEv2"`
- `"protocol": "AmneziaWG"`
- `"protocol": "XRay"`

If the protocol is not explicitly mentioned, analyze the server configuration or consult the [AmneziaVPN documentation](https://docs.amnezia.org/). For example, WireGuard configurations often include fields like `public_key`, `private_key`, and `dns`, while OpenVPN configurations may include `ca`, `cert`, and `key`.

### Official and Community Documentation

While the official AmneziaVPN documentation does not explicitly detail the `vpn://` link format, the following resources can be helpful:

- [Amnezia Config Decoder & Encoder GitHub Repository](https://github.com/andr13/amnezia-config-decoder)
- [AmneziaVPN Supported Configuration Formats](https://docs.amnezia.org/documentation/supported-configuration-formats/)
- [Setting Up a VPN on Your Own Server](https://docs.amnezia.org/documentation/instructions/install-vpn-on-server/)
- [AmneziaVPN GitHub Repository](https://github.com/amnezia-vpn/amnezia-client)
- [AmneziaVPN Community Forum](https://community.amnezia.org/)
- [Reddit: r/AmneziaVPN](https://www.reddit.com/r/AmneziaVPN)
- [Telegram (English)](https://t.me/amnezia_vpn_en)

### Troubleshooting

If decoding fails:

1. Verify that the `vpn://` link is correctly formatted.
2. Ensure the Amnezia Config Decoder script is up-to-date.
3. Check the [AmneziaVPN GitHub issues page](https://github.com/andr13/amnezia-config-decoder/issues) for known problems.
4. Contact the AmneziaVPN community for support.

### Example Decoded Output

After decoding, you might see output like this:

```json
{
    "protocol": "WireGuard",
    "server": "vpn.example.com",
    "port": 51820,
    "public_key": "ABC123...",
    "private_key": "XYZ789...",
    "allowed_ips": "0.0.0.0/0"
}
```

This indicates the VPN uses the WireGuard protocol.

### Conclusion

The `vpn://` links used by AmneziaVPN are encoded using a custom scheme. The most reliable way to decode them is by using the [Amnezia Config Decoder & Encoder](https://github.com/andr13/amnezia-config-decoder) Python script. Once decoded, the JSON output will reveal the VPN protocol and other configuration details. While the official documentation does not detail the `vpn://` link format, community resources and the provided script are valuable for decoding and understanding these links.
