Skip to content

golang proxy which can switch between Direct mode and Cascade mode

License

Notifications You must be signed in to change notification settings

azak-azkaran/cascade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cascade

Build Status Travis Status Quality Gate Status Coverage Coverage Status

Go proxy which can switch between Direct mode and Cascade mode Switch is done according to health check.

Installation

Just download the current release For running as daemon checkout the section in this readme

Install from source

checkout the source code and run

make install

Configuration

Configuration can be done by file or command line arguments

  • password : Password for authentication to a forward proxy
  • host : Address of a forward proxy
  • user : Username for authentication to a forward proxy
  • port : Port on which to run the proxy
  • health : Address which is used for health check if available go to direct mode (default: https://www.google.de )
  • health-time : Duration between health checks (default: 30 Seconds )
  • host-list : Comma Separated List of Host for which Proxy Redirect is used in Cascade Mode
  • config : Path to configuration yaml file. If set all other command line parameters will be ignored
  • version: Just shows the current version
  • vault-addr: address to the hashi corp vault
  • vault-token: token for the hashi corp vault

Health Check

A temporary client tries to connect to a certain address regularly. The Cascade mode is active if health check fails.

Direct Mode

Normal http internet Proxy Mode.

Cascade Mode

Cascade Mode means that this proxy stands between the client and another Proxy. Basic Authentication can be enabled for Cascade Mode

Proxy redirect for Hosts

If in cascade mode, different Proxy redirects can be added by adding a Comma seperated list. These redirects changes HTTPS and HTTP Request according to the setup rules. The Requests can be send to another Proxy or directly.

Direct Configuration:

  • DIRECT Connection: eclipse
  • DIRECT Connection: azure->
  • REDIRECT Connection to other Proxy: google->test:8888

HashiCorp Vault Configuration

Cascade can also get the configuration from a HashiCorp Vault. The secret store has to be version 2 and a vault configuration will overwrite a file configuration. The following secrets have to be saved in store:

  • username
  • password
  • host

The following secrets are optional:

  • port (default: 8888)
  • host-list (default: "")
  • health (default: www.google.de)
  • log (default: WARNING)
  • health-time (default: 5s)
  • disableAutoChangeMode (default: false)

REST Interface

Cascade comes with a REST Interface which can be used to control the application. Currently the following REST Endpoints are available:

  • /config : is used to return the current configuration
  • /getOnlineCheck : is used to get if the check is used to check for up
  • /getAutoMode : is used to get if automatically switching between modes is activated
  • /addRedirect : adds another redirect rule
  • /setOnlineCheck : used to configure check is used to check for a website being online
  • /setAutoMode : used to disable automatically switching between modes
  • /setCascadeMode : used to force a certain mode

Curl Examples

These examples use curl to use the REST Endpoints

Config

To get the current configuration

curl -D- localhost/config

SetCascadeMode

To set the Mode by hand to DirectMode:

curl -D- --request POST \
  --data '{"cascadeMode":false}' \
  localhost/setCascadeMode

To set the Mode by hand to Cascade mode:

curl -D- --request POST \
  --data '{"cascadeMode":true}' \ 
  localhost/setCascadeMode

SetAutoMode

To disable the automatically switch between modes:

curl -D- --request POST \
  --data '{"autoChangeMode":false}' \
  localhost/setAutoMode

To enable the automatically switch between modes:

curl -D- --request POST \
  --data '{"autoChangeMode":true}' \
  localhost/setAutoMode

will overwrite the setting from file,vault or command line

Systemd

If you want to use the provided service configuration, the program has to be moved to

/usr/local/bin

The configuration has to be moved to the following folder for Ubuntu:

/etc/systemd/system/

Afterwards, systemd has to be restarted as follows:

systemctl daemon-reload
systemctl start cascade

The logs can be viewed by using:

journalctl -f -u cascade

About

golang proxy which can switch between Direct mode and Cascade mode

Resources

License

Stars

Watchers

Forks

Packages

No packages published