3.1 KiB
Developer Guide
This guide provides essential information for developers working on the Gerbil project, which is a Go application for managing WireGuard tunnels. It includes setup instructions, an overview of the project structure, development workflow, testing approach, and common troubleshooting steps.
1. Setup Instructions
To get started with the Gerbil project, follow these setup instructions:
Prerequisites
- Go: Ensure that you have Go installed on your system. The project uses Go version 1.23.1 or later. You can download it from golang.org.
- Docker: Install Docker to build and run the application in a containerized environment.
- Git: Make sure Git is installed to clone the repository.
Installation Steps
-
Clone the Repository:
git clone https://github.com/fosrl/gerbil.git cd gerbil
-
Install Dependencies: Run the following command to download all required Go dependencies:
go mod download
-
Build the Application: You can build the application using Docker or directly using Go:
- Using Docker:
docker build -t gerbil .
- Using Go:
go build -o gerbil main.go
- Using Docker:
-
Run the Application: To run the application, execute:
./gerbil \ --reachableAt=http://gerbil:3003 \ --generateAndSaveKeyTo=/var/config/key \ --remoteConfig=http://pangolin:3001/api/v1/gerbil/get-config \ --reportBandwidthTo=http://pangolin:3001/api/v1/gerbil/receive-bandwidth
2. Project Structure Overview
The project structure of Gerbil is organized as follows:
gerbil/
├── logger/
│ ├── level.go
│ └── logger.go
├── config_example.json
├── Dockerfile
├── entrypoint.sh
├── go.mod
├── main.go
├── Makefile
Key Components
logger/
: Contains logging functionality for the application.main.go
: The entry point of the application.Dockerfile
: Instructions for building a Docker image of the application.config_example.json
: Example configuration file for setting up WireGuard tunnels.Makefile
: Contains commands for building and managing the project.
3. Development Workflow
The development workflow for contributing to Gerbil involves several key steps:
-
Branching: Create a new branch for your feature or bug fix.
git checkout -b feature/my-feature-name
-
Coding: Implement your changes in the codebase.
-
Testing Locally: Run tests locally to ensure your changes do not break existing functionality.
-
Committing Changes: Commit your changes with a descriptive message.
git commit -m "Add feature X"
-
Pushing Changes: Push your branch to the remote repository.
git push origin feature/my-feature-name
-
Creating a Pull Request: Open a pull request against the main branch of the repository.
-
Code Review: Participate in code reviews and address any feedback received.