Skip to content

A EUI-64 address calculator implemented in Go, HTMX, and Templ.

License

Notifications You must be signed in to change notification settings

nicholas-fedor/eui64-calculator

Repository files navigation

EUI-64 Calculator

A EUI-64 address calculator implemented in Go, HTMX, and Templ.

This project was inspired by ThePrincelle's EUI64-Calculator

EUI-64 Calculator Screenshot

CircleCI codecov GoDoc Go Report Card latest version GPLv3 License Codacy Badge All Contributors Pulls from DockerHub

Overview

This project provides a simple tool for calculating an EUI-64 IPv6 address using a MAC addresses and IPv6 Prefix.

Features

  • EUI-64 Calculation: Convert a 48-bit MAC address into a 64-bit EUI-64 format.
  • IPv6 Address Generation: Combine the EUI-64 with a user-provided IPv6 prefix.
  • Web Interface: User-friendly interface for input and result display using HTMX for dynamic content loading.
  • Docker Support: Containerized deployment for easy setup and scalability.

Usage

  1. Enter a MAC Address in the format xx-xx-xx-xx-xx-xx.
  2. Enter an IPv6 Prefix.
  3. Click Calculate to see the results.

Getting Started

Docker Deployment

Quick Start

docker run -d --name eui64-calculator nickfedor/eui64-calculator:latest

Docker Compose

  • Running the Basic Template:

    docker compose -f ./Docker/compose.yaml up -d
  • Traefik Reverse Proxy example

Running Locally

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/nicholas-fedor/eui64-calculator.git
  2. Enter the repository:

    cd eui64-calculator
  3. Install Dependencies:

    go mod download
  4. Generate Templates:

    templ generate
  5. Run the Server:

    go run ./cmd/server/main.go
  6. The application will be accessible at http://localhost:8080/

Development

Project Structure

.
├── .dockerignore
├── .gitignore
├── Dockerfile
├── go.mod
├── go.sum
├── LICENSE
├── README.md
├── cmd
│   └── server
│       ├── main.go
│       └── main_test.go
├── docker
│   ├── docker-compose.yaml
│   ├── Dockerfile-dev
│   └── Examples
│       └── Traefik
├── internal
│   ├── eui64
│   │   ├── eui64.go
│   │   └── eui64_test.go
│   ├── handlers
│   │   ├── handlers.go
│   │   └── handlers_test.go
│   └── validators
│       ├── ipv6_prefix_validator.go
│       ├── ipv6_prefix_validator_test.go
│       ├── mac_validator.go
│       └── mac_validator_test.go
├── static
│   ├── favicon.ico
│   └── styles.css
└── ui
    ├── home.templ
    ├── home_templ.go
    ├── layout.templ
    ├── layout_templ.go
    ├── result.templ
    ├── result_templ.go
    └── ui_test.go

Dependencies

IDE Support

If you're using VSCode, I've included an extensions.json file with recommended extensions.

Managing Templ files

  • Installing the Templ CLI

    go install github.com/a-h/templ/cmd/templ@latest
  • Rebuilding .templ.go files after updates to .templ files (run from the project's root directory)

    Linux:

    rm ./ui/*_templ.go && templ generate

    Windows:

    del ui\*_templ.go && templ generate

Testing

  • Unit Tests:

    go test ./...
  • Docker Test Stage:

    The Dockerfile includes a test stage to ensure all tests pass before building the production image.

Docker

  • Rebuilding the Docker image:

    docker build -f docker/Dockerfile-dev -t eui64-calculator-dev .
  • Running the image locally:

    docker run -it -p 8080:8080 eui64-calculator-dev

Notes

  • The Dockerfile uses gcr.io/distroless/static-debian12 as the final runtime image for the application. This results in a minimal container image without a shell or other features typical of other container images.

  • I opted to hardcode Gin's release mode to avoid redundant environment variables. This can be easily commented out in the cmd/server/main.go file.

Contributors

Nicholas Fedor
Nicholas Fedor

💻 📖 🚧 👀

Contributing

This was a weekend project and there's plenty of opportunity for improvement.

If you feel like contributing, please:

  • Fork the repo
  • Create your feature branch: git checkout -b feature/AmazingFeature
  • Commit your changes: git commit -m "Add some AmazingFeature"
  • Push to the branch: git push origin feature/AmazingFeature
  • Open a pull request

License

This project is licensed under the GNU GPLv3 license - see the LICENSE file for details.

About

A EUI-64 address calculator implemented in Go, HTMX, and Templ.

Resources

License

Stars

Watchers

Forks

Packages

No packages published