Coder Social home page Coder Social logo

kproxy's Introduction

kproxy

A script for enabling or disabling proxy settings for your shell when you are behind a proxy.

You probably don't want to use this on a multi-user machine, because it stores credentials on disk. It's intended to be safer than the methods I've seen in use, which store user:password in the http_proxy environment variable, and in the .bash_profile to set it on login. These can be urlencoded, but are typically plain text. If you are in a pair programming session on your machine, you might accidentally display your environment variables, and you don't want your password readable at a glance.

Note: Obfuscating a password is not security against an attacker. You're still storing credentials on disk, so use at your own risk.

Usage

You need to source the script to make the functions available in your shell.

$ . kproxy

Add these lines to your ~/.bashrc to make it source this script when you open a terminal (I have symlinked it in ~/bin, so set the path to whatever you want):

if [ -f ~/bin/kproxy ]; then
	. ~/bin/kproxy
fi

Once you have sourced this script, call makeproxypass to set your password for the proxy server. It will use the user name of your currently logged in user.

$ makeproxypass
Enter password:

Now you can enable or disable your proxy environment variables with a shell command:

proxy_on

or

proxy_off

There is also an automatic detection function for turning on the proxy settings after attempting an HTTP request. If the request succeeds without the proxy, then leave the proxy disabled. If it fails, then enable the proxy.

detectsetproxy

Installing

  1. Clone this repo somewhere.
  2. To be able to use it in all terminals, add a call out in your ~/.bashrc
path-to-your-clone/kproxy

If you reuse your same .bashrc on multiple machines, you might want to wrap the callout to kproxy in an if block to test if the file exists.

Pull Requests Welcome

I have tested this on MacOS, with the default bash/sh. I wrote it to use sh instead of bash for portability. Open an issue on this project if it doesn't work for you. Send me a PR and I'll merge it.

kproxy's People

Contributors

mnebuerquo avatar

Watchers

 avatar  avatar

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.