Coder Social home page Coder Social logo

springlie / smart_switcher Goto Github PK

View Code? Open in Web Editor NEW
37.0 4.0 10.0 94 KB

[TERMINAL ONLY] Auto-detect proxy switcher for http, https, ftp, rsync, git protocols. It supports many tools such as wget, yum, portage, brew ...

Shell 100.00%
proxy proxy-settings https-proxy protocol shell proxy-gateway auto-proxy git-proxy

smart_switcher's Introduction

smart_switcher

Auto-detect proxy switcher in terminal. It supports many protocols and tools.


Overview

A smart proxy switcher wrapper, supports http, https, ftp, rsync, ssh(connect depended), git(connect depended) protocols.

It can automatically detect your network environment (in preset set) and fit proxy for you.

It supports multi-proxies.

If you usually switch the network environment (maybe home with no-proxy, workplace1 with proxy1, workplace2 with proxy2), it may help you a lot.

Tested in Zsh and Bash on Linux and Mac.

screenshot

Protocols supported

  • http

  • https

  • ftp

  • rsync

  • ssh

  • git

Tools supported

  • wget

  • ftp

  • rsync

  • yum

  • brew

  • emerge

  • npm

  • pip

  • gopkg

  • git

  • hg

  • svn

  • cvs

Installation

  • Download script (temply set your https proxy if necessary for installation)

export https_proxy={YOUR_PROXY_GATEWARY_IP}:{YOUR_PROXY_GATEWAY_PORT}

git clone https://github.com/springlie/smart_switcher.git /path/to/smart_switcher

  • Set proxies host/port in $SMART_SWITCHER_DIR/gateway.ini.

    [optional] Follow gateway.ini format and customize your multiple proxies.

    [optional] Note: the most common proxies should be set first in the value of "gateways"

  • Source it in your .zshrc (or any shell script resource file like .bashrc):

export SMART_SWITCHER_DIR=/path/to/smart_switcher; source $SMART_SWITCHER_DIR/smart_switcher.sh

Usage

Execute antomatically when user login.

Use command sm_toggle to toggle proxy status when you want.

What's more

cecho

smart_switcher supports cecho, who will bring you some colors.

connect

connect is required to support ssh and git protocols.

Ensure proxy be set temply for installation ...

export http_proxy={YOUR_PROXY_GATEWARY_IP}:{YOUR_PROXY_GATEWAY_PORT}

  • [for Mac]

brew install connect

  • [for Gentoo]

emerge net-misc/connect

  • [for other]

    download the source, make and install it easily in system path

Known issues

  1. When $SHLVL > 1 (means in multi-layers sub-shell), the proxy setting is invalid

  2. ssh can't distinguishes the destination sites before or behind proxy gateway

TODO

  • add protocol header before proxy gateway
  • add username & password
  • add proxy for npm
  • add toggle function
  • specified ssh rule for sites
  • add proxy for svn
  • add automatical setup for connect package

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.