Skip to content

Latest commit

 

History

History
124 lines (86 loc) · 3.99 KB

development.md

File metadata and controls

124 lines (86 loc) · 3.99 KB

Development

Visitors count

Setup

Getting the repository

  1. Sign in or register for an account on Github

  2. Fork Gluetun to your account.

  3. Install Git

  4. Clone the repository either with https or ssh:

    # HTTPS
    git clone https://github.com/yourusername/gluetun.git
    # or SSH
    git clone [email protected]:yourusername/gluetun.git
  5. Go to the newly cloned gluetun directory

Development environment

Since Gluetun is for now tightly coupled with Linux's unix & syscall Go packages, you can develop it using one of the two options below:

Development container

The development Docker container for VSCode is pre-configured for Gluetun and works on OSX, Linux and Windows.

  1. Install the following:
    1. Docker
    2. Docker Compose
    3. VS code
    4. VS code remote containers extension
  2. Make sure the following exist and are accessible by Docker:
    • ~/.ssh directory
    • ~/.gitconfig file (can be empty)
  3. Open the command palette in VS Code (CTRL+SHIFT+P).
  4. Select Remote-Containers: Open Folder in Container... and choose the Gluetun project directory.

More information is available at the development container readme

Linux host setup

  1. Install Go

  2. Download the dependencies

    go mod download
  3. Install golangci-lint

  4. You might want to use an IDE such as VSCode with the Go extension

  5. You might want to install Docker to build and run the image.

Modifying the code

Decide on a branch name for the feature you want to add, and then create that branch:

git checkout -b mybranchname

You can now start modifying the code and git commit your changes incrementally.

Before committing each commit, make sure the following passes:

# Linting
golangci-lint run
# Tests
go test ./...

💁 If you are new to Git and commits, you should read:

To commit changes for example:

# Stage all new and changed files
git add .
# Commit the staged files
git commit -m "description of my changes"

You can also do this through IDE such as VS Code source control.

💡 Want to add a VPN provider? ➡️ Add a provider - this is a detailed step-by-step guide.

💡 Want to understand the project structure? ➡️ Project structure

Testing the Docker container

  1. Build the image with:

    docker build -t qmcgaw/gluetun .
  2. Run it with:

    docker run -it --rm --cap-add=NET_ADMIN \
      -e VPN_SERVICE_PROVIDER=someprovider \
      -e VPN_TYPE=openvpn \
      -e OPENVPN_USER=test -e OPENVPN_PASSWORD=test \
      -p 8000:8000/tcp \
      qmcgaw/gluetun

Final steps

  1. Push your new branch to your forked repository:

    git push -u origin mybranchname
  2. Open a pull request on the qdm12/gluetun repository

  3. I will most likely leave feedback as comments on the pull request, which you would have to address in order to get your work merged in the base repository. And also feel free to ask any question there!