url_gen/README.md
2025-06-10 21:13:00 -05:00

2.8 KiB

Random URL Generator

A simple, cross-platform command-line utility for generating cryptographically secure, random URLs. This project is a C# port of an original Python script, designed to provide unique, non-guessable hostnames for development and testing environments.

Features

  • Interactive Menu: Simple menu to select the desired server type.
  • Secure by Default: Uses System.Security.Cryptography.RandomNumberGenerator for cryptographically strong randomness, equivalent to Python's secrets module.
  • Customizable Prefixes: Easily generates URLs for different services (PostgreSQL, Redis, RabbitMQ, etc.).
  • Modern C#: Written using modern C# features like top-level statements and switch expressions for clean, concise code.
  • Cross-Platform: Runs anywhere the .NET SDK is installed (Windows, macOS, Linux).

Purpose

In development and cloud environments, there is often a need to create temporary resources with unique hostnames. This tool solves that problem by generating random, hard-to-guess URLs, which helps:

  1. Prevent Naming Collisions: The random string ensures each generated URL is unique.
  2. Enhance Security through Obscurity: While not a replacement for proper authentication, a non-guessable hostname makes it harder for unauthorized users to discover or access temporary services.

Prerequisites

To run this project, you will need the .NET 6 SDK or later installed on your system.

How to Run

  1. Clone or Download the Code Clone this repository to your local machine or simply download the Program.cs file.

    git clone https://github.com/rideaware/url_gen.git
    cd url_gen
    
  2. Run from the Command Line Navigate to the project's root directory in your terminal and use the dotnet run command. The .NET SDK will automatically compile and execute the application.

    dotnet run
    
  3. Follow the Prompts The application will present you with a menu. Enter the number corresponding to your choice and press Enter.

Example Session

Select a server type:
1. PostgreSQL (psql)
2. Redis (redis)
3. RabbitMQ (rabbitmq)
4. Sandbox Web Server (sandbox)
5. Staging Web Server (staging)

Enter a number (1-5) to select a server type, or 'q' to quit: 1
Generated URL: psql-4t9wz1qj.rideaware.org

Generate another URL? (y/n): y

Select a server type:
1. PostgreSQL (psql)
2. Redis (redis)
3. RabbitMQ (rabbitmq)
4. Sandbox Web Server (sandbox)
5. Staging Web Server (staging)

Enter a number (1-5) to select a server type, or 'q' to quit: 4
Generated URL: sandbox-k8m3v7b2.rideaware.org

Generate another URL? (y/n): n

License

This project is licensed under the MIT License. See the LICENSE file for details.