This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (c *commander) Start(name string, arg ...string) (stdoutPipe, stderrPipe io.ReadCloser, waitFn func() error, err error) { | |
| cmd := c.execCommand(name, arg...) | |
| stdout, err := cmd.StdoutPipe() | |
| if err != nil { | |
| return nil, nil, nil, err | |
| } | |
| stderr, err := cmd.StderrPipe() | |
| if err != nil { | |
| return nil, nil, nil, err | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package command | |
| import ( | |
| "bufio" | |
| "context" | |
| "fmt" | |
| "io" | |
| ) | |
| type StreamMerger interface { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (c *configurator) CreateTUN() error { | |
| c.logger.Info("%s: creating %s", logPrefix, constants.TunnelDevice) | |
| if err := c.fileManager.CreateDir("/dev/net"); err != nil { | |
| return err | |
| } | |
| dev := c.mkDev(10, 200) | |
| if err := c.mkNod(string(constants.TunnelDevice), unix.S_IFCHR, int(dev)); err != nil { | |
| return err | |
| } | |
| if err := c.fileManager.SetUserPermissions(string(constants.TunnelDevice), 666); err != nil { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // CheckTUN checks the tunnel device is present and accessible | |
| func (c *configurator) CheckTUN() error { | |
| c.logger.Info("%s: checking for device %s", logPrefix, constants.TunnelDevice) | |
| f, err := c.openFile(string(constants.TunnelDevice), os.O_RDWR, 0) | |
| if err != nil { | |
| return fmt.Errorf("TUN device is not available: %w", err) | |
| } | |
| if err := f.Close(); err != nil { | |
| c.logger.Warn("Could not close TUN device file: %s", err) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package params | |
| import ( | |
| "fmt" | |
| "net" | |
| "strings" | |
| ) | |
| // GetExtraSubnets obtains the CIDR subnets from the comma separated list of the | |
| // environment variable EXTRA_SUBNETS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |