Coder Social home page Coder Social logo

proxyguy's Introduction

proxyguy

Codacy Code Quality Codacy Coverage

Dynamic proxy generator for corporate environments.

Primarily interesting for WSL users unable to use the forced proxy setting.

Usage

Important

I only support Linux/WSL systems. There is no guarantee that this will work on Windows too.

Download the binary from the latest release and place it in the PATH, e.g. in /usr/local/bin.

Help is available using

proxyguy --help

Modules

The program supports several built-in "modules", extending functionality for certain other programs or services.

Each module must be enabled separately.

Maven

Will set the MAVEN_OPTS variable with the determined proxy endpoint.

Example:

-Dhttp.proxyHost=10.11.12.13 -Dhttp.proxyPort=8080 -Dhttps.proxyHost=10.11.12.13 -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts=localhost|127.0.0.1|example.org|*.example.org

Gradle

Will modify the global properties file at $HOME/.gradle/gradle.properties and set the system properties analogous to the MAVEN_OPTS variable.

Why not set the GRADLE_OPTS variable?. Because that doesn't work when using IntelliJ IDEA. I didn't figure out why, but I guess IntelliJ executes the Gradle process with a limited set of environment variables. Setting the properties via the gradle.properties file does work.

Docker

Will modify the config file at $HOME/.docker/config.json and set or unset the proxies.default values as stated in the documentation.

Beware that this config only applies to the Docker Client and thus containers started using it.

To make the Docker Server use the proxy, use the following configuration:

  1. Create the file /etc/systemd/system/docker.service.d
[Service]
ExecStart=
ExecStart=/usr/local/bin/docker-wrapper.sh
  1. Create the file /usr/local/bin/docker-wrapper.sh:
eval $( proxyguy )
  1. Reload systemd
systemctl daemon-reload
  1. Restart the Docker service
systemctl restart docker.service

If you're not using Systemd, just make sure the Docker process sources the output of step 2.

Configuration

Configuration can be done by either using a YAML file or environment variables.

You should use the YAML file for local installations and environment variables for the Docker image.

Key Environment Variable Default Description
pac PAC The URL to the .pac file.
timeout TIMEOUT 1000 A timeout after which proxy resolving will fail.
proxy.override PROXY_OVERRIDE Defines a static proxy endpoint. Will disable the PAC resolution.
proxy.ignore PROXY_IGNORE localhost,127.0.0.1 Defines the value for the NO_PROXY variable, urls and hosts to directly connect to.
proxy.determine-url PROXY_DETERMINE https://ubuntu.com An url used to find the proxy endpoint to use. Should be a publicly available address.
modules.main MODULES_MAIN true Enable the Main module.
modules.maven MODULES_MAVEN false Enable the Maven module.
modules.gradle MODULES_GRADLE false Enable the Gradle module.
modules.docker MODULES_DOCKER false Enable the Docker module.
server.address SERVER_ADDRESS 0.0.0.0 On which address the server should bind.
server.port SERVER_PORT 1337 The port to listen on.

Bash Integration

Place the following line somewhere in your .bashrc file:

eval $( proxyguy )

The following environment variables will be automatically configured in every shell session if the Main module is enabled:

  • http_proxy
  • https_proxy
  • no_proxy
  • HTTP_PROXY
  • HTTPS_PROXY
  • NO_PROXY

Server Mode (WIP)

I'm working on a custom proxy server implementation which decides based on the connectivity to the corporate network whether to forward requests to another proxy or directly to the internet.

Start the server using

proxyguy -server

Todos

  • Documentation
  • Tests

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.