Skip to content

nicholas-fedor/eui64-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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.

πŸŽ‰ A static version of this project is now available at https://eui64-calculator.nickfedor.com πŸŽ‰

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

.
β”œβ”€β”€ .github
β”‚   β”œβ”€β”€ workflows
β”‚   β”‚   β”œβ”€β”€ create-manifests.yaml
β”‚   β”‚   β”œβ”€β”€ lint-go.yaml
β”‚   β”‚   β”œβ”€β”€ build.yaml
β”‚   β”‚   β”œβ”€β”€ clean-cache.yaml
β”‚   β”‚   β”œβ”€β”€ pull-request.yaml
β”‚   β”‚   β”œβ”€β”€ release.yaml
β”‚   β”‚   β”œβ”€β”€ security.yaml
β”‚   β”‚   └── test.yaml
β”‚   β”œβ”€β”€ ISSUE_TEMPLATE
β”‚   β”‚   β”œβ”€β”€ bug_report.yaml
β”‚   β”‚   β”œβ”€β”€ config.yaml
β”‚   β”‚   └── feature_request.yaml
β”‚   β”œβ”€β”€ assets
β”‚   β”‚   β”œβ”€β”€ eui64-calculator_screenshot.png
β”‚   β”‚   └── eui64-calculator_social-preview_1280x640.png
β”‚   └── renovate.json
β”œβ”€β”€ build
β”‚   β”œβ”€β”€ docker
β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   └── .dockerignore
β”‚   β”œβ”€β”€ golangci-lint
β”‚   β”‚   └── golangci.yaml
β”‚   └── goreleaser
β”‚       └── goreleaser.yaml
β”œβ”€β”€ cmd
β”‚   └── server
β”‚       β”œβ”€β”€ static
β”‚       β”‚   β”œβ”€β”€ favicon.ico
β”‚       β”‚   └── styles.css
β”‚       β”œβ”€β”€ main.go
β”‚       └── main_test.go
β”œβ”€β”€ internal
β”‚   β”œβ”€β”€ ui
β”‚   β”‚   β”œβ”€β”€ doc.go
β”‚   β”‚   β”œβ”€β”€ generate.go
β”‚   β”‚   β”œβ”€β”€ home.templ
β”‚   β”‚   β”œβ”€β”€ layout.templ
β”‚   β”‚   β”œβ”€β”€ result.templ
β”‚   β”‚   └── ui_test.go
β”‚   β”œβ”€β”€ 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
β”œβ”€β”€ .all-contributorsrc
β”œβ”€β”€ .circleci
β”‚   └── config.yml
β”œβ”€β”€ .codacy.yml
β”œβ”€β”€ .gitattributes
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ examples
β”‚   β”œβ”€β”€ Traefik
β”‚   β”‚   β”œβ”€β”€ .env
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   β”œβ”€β”€ docker-compose.yaml
β”‚   β”‚   └── traefik.yaml
β”‚   └── docker-compose.yaml
β”œβ”€β”€ go.mod
└── go.sum

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

 
 
 

Contributors 3

  •  
  •  
  •