A EUI-64 address calculator implemented in Go, HTMX, and Templ.
This project was inspired by ThePrincelle's EUI64-Calculator
This project provides a simple tool for calculating an EUI-64 IPv6 address using a MAC addresses and IPv6 Prefix.
- 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.
- Enter a MAC Address in the format
xx-xx-xx-xx-xx-xx
. - Enter an IPv6 Prefix.
- Click
Calculate
to see the results.
docker run -d --name eui64-calculator nickfedor/eui64-calculator:latest
-
Running the Basic Template:
docker compose -f ./Docker/compose.yaml up -d
-
Traefik Reverse Proxy example
- Go: https://go.dev/doc/install
- Templ:
go install github.com/a-h/templ/cmd/templ@latest
-
Clone the repository:
git clone https://github.com/nicholas-fedor/eui64-calculator.git
-
Enter the repository:
cd eui64-calculator
-
Install Dependencies:
go mod download
-
Generate Templates:
templ generate
-
Run the Server:
go run ./cmd/server/main.go
-
The application will be accessible at http://localhost:8080/
.
├── .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
- Golang: https://go.dev/doc
- gin-gonic/gin: https://github.com/gin-gonic/gin
- Templ: https://github.com/a-h/templ
- HTMX: https://htmx.org/docs
If you're using VSCode, I've included an extensions.json
file with recommended extensions.
-
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
-
Unit Tests:
go test ./...
-
Docker Test Stage:
The Dockerfile includes a test stage to ensure all tests pass before building the production image.
-
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
-
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.
Nicholas Fedor 💻 📖 🚧 👀 |
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
This project is licensed under the GNU GPLv3 license - see the LICENSE file for details.