Skip to content

Instantly share code, notes, and snippets.

View qdm12's full-sized avatar

Quentin McGaw qdm12

View GitHub Profile

Keybase proof

I hereby claim:

  • I am qdm12 on github.
  • I am quentinmcgaw (https://keybase.io/quentinmcgaw) on keybase.
  • I have a public key ASBlAMEoY0Klst0SL3OKjRWJoHypVzpY9eEfyFvwxZWvGAo

To claim this, I am signing this object:

@qdm12
qdm12 / readme.md
Last active April 8, 2024 08:45
Wireguard setup for Ubuntu server with LAN access

Wireguard setup for LAN access

Assumptions

  • The network 192.168.1.0/24 is your LAN
  • Your Ubuntu server is on your LAN at 192.168.1.10, through the network interface eth0
  • The network 192.168.5.0/24 is non existent
  • Your LAN DNS is at 192.168.1.1
@qdm12
qdm12 / Dockerfile
Last active September 16, 2019 17:23
Go Dev Dockerfile
ARG GO_VERSION=1.13
ARG ALPINE_VERSION=3.10
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION}
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=1000
# Setup user
RUN adduser $USERNAME -s /bin/sh -D -u $USER_UID $USER_GID && \
@qdm12
qdm12 / devcontainer.json
Last active September 13, 2019 00:52
Go Dev devcontainer.json
{
"name": "Your project Dev",
"dockerFile": "Dockerfile",
// "appPort": 8000,
"extensions": [
"ms-vscode.go",
"davidanson.vscode-markdownlint",
"shardulm94.trailing-spaces",
"IBM.output-colorizer"
],
@qdm12
qdm12 / .travis.yml
Last active November 25, 2019 00:52
Travis configuration for multi arch builds
dist: xenial
sudo: required
env:
global:
- DOCKER_REPO=<DOCKER_USER/DOCKER_IMAGE>
before_install:
- curl -fsSL https://get.docker.com | sh
- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json
- mkdir -p $HOME/.docker
- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json
@qdm12
qdm12 / ci.sh
Last active December 1, 2019 01:18
Travis CI script for multi arch builds
#!/bin/bash
if [ "$TRAVIS_PULL_REQUEST" = "true" ] || [ "$TRAVIS_BRANCH" != "master" ]; then
docker buildx build \
--progress plain \
--platform=linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x \
.
exit $?
fi
echo $DOCKER_PASSWORD | docker login -u qmcgaw --password-stdin &> /dev/null
@qdm12
qdm12 / firewall.go
Last active February 9, 2020 22:14
package params
import (
"fmt"
"net"
"strings"
)
// GetExtraSubnets obtains the CIDR subnets from the comma separated list of the
// environment variable EXTRA_SUBNETS
func buildBlockedIPs(client network.Client, blockMalicious, blockAds, blockSurveillance bool,
privateAddresses []string) (lines []string, errs []error) {
chResults := make(chan []string)
chError := make(chan error)
listsLeftToFetch := 0
if blockMalicious {
listsLeftToFetch++
go func() {
results, err := getList(client, string(constants.MaliciousBlockListIPsURL))
chResults <- results
package pia
import (
"fmt"
"net"
"github.com/qdm12/golibs/files"
"github.com/qdm12/private-internet-access-docker/internal/constants"
"github.com/qdm12/private-internet-access-docker/internal/models"
)
func (c *configurator) runIptablesInstruction(instruction string) error {
flags := strings.Fields(instruction)
if output, err := c.commander.Run("iptables", flags...); err != nil {
return fmt.Errorf("failed executing %q: %s: %w", instruction, output, err)
}
return nil
}
func (c *configurator) Clear() error {
c.logger.Info("%s: clearing all rules", logPrefix)