Skip to content

nastyagrifon/amnezia-config-decoder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AmneziaVPN Config Decoder & Encoder (Rust Rewrite)

This project is a Rust rewrite of the original Python script for converting AmneziaVPN configurations between Base64-encoded strings and JSON format.

Please note: The core logic of the Rust code in this repository was entirely generated by an AI coding assistant based on the original Python implementation.

Original Project and Creator

This Rust program is based on the original Python project by andr13:

We are grateful to andr13 for the original work which served as the foundation for this Rust version.

Requirements

To build and run this Rust program, you need:

  • Rust and Cargo installed. You can install them by following the instructions on https://rustup.rs/.

Building

To build the project, navigate to the project directory in your terminal and run:

cargo build

This will compile the project and create an executable in the target/debug/ directory (or target/release/ if you build with cargo build --release).

Usage

The compiled executable (./target/debug/amnezia-config-decoder) automatically detects whether to decode an encoded string or encode a JSON configuration based on the input format. The program takes one primary input source, which can be either a direct string or a path to a file. It also supports an optional output file.

Autodetection Logic:

The program inspects the provided input:

  • If the input starts with vpn://, it is treated as an encoded string and will be decoded to JSON.
  • If the input is a path to an existing file, the program reads the file content. If the content starts with vpn://, it decodes the content. If the content is valid JSON, it encodes the content to a vpn:// string.
  • If the input does not start with vpn:// and is not a valid JSON string (either directly or from a file), the program will report an error.

Basic Syntax:

amnezia-config-decoder <input_source> [-o output.file]
  • <input_source>: This can be either:

    • A direct vpn:// encoded string.
    • A path to a file containing a vpn:// encoded string (e.g., config.vpn).
    • A path to a file containing a JSON configuration (e.g., config.json).
  • -o output.file: (Optional) Path to the output file. If the input was decoded (from a vpn:// string or .vpn file), the output file should typically have a .json extension. If the input was encoded (from a .json file), the output file would typically have a .vpn extension. If not specified, the output is printed to the console.

Examples

Decode a vpn:// string provided directly on the command line:

amnezia-config-decoder "vpn://AAAGX.."

(Note: Using quotes for the string might be necessary depending on your shell to prevent special characters from being interpreted.)

Decode a vpn:// string from a file (amnezia_config.vpn) and print JSON to console:

amnezia-config-decoder amnezia_config.vpn

Decode a vpn:// string from a file (amnezia_config.vpn) and save JSON to decoded_config.json:

amnezia-config-decoder amnezia_config.vpn -o decoded_config.json

Encode a JSON configuration from a file (my_config.json) and print vpn:// string to console:

amnezia-config-decoder my_config.json

Encode a JSON configuration from a file (my_config.json) and save vpn:// string to encoded_config.vpn:

amnezia-config-decoder my_config.json -o encoded_config.vpn

Background

AmneziaVPN uses a custom string encoding scheme to represent configurations. This Rust program replicates the encoding and decoding logic, allowing you to work with configs in a much more readable JSON format.

Contributing

Contributions are welcome! Please open an issue or pull request if you have any suggestions or bug reports.

License

This project is licensed under the GPL-3.0 license, inherited from the original Python project.

About

AmneziaVPN config decoder & encoder

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%