proxy

package
v0.0.0-...-324554c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package proxy is an implementation of a proxy server. This package allows you to start a proxy server using a function and then provides API end-points to add and remove independent servers from this proxy server. The servers attached to the proxy must have a function in them to send a HTTP request to the proxy server to register itself in the proxy server. The server will have an option to be visible/not from direct access to it. Once the server sends a request to the proxy server to register itself, the proxy responds with a special hasb that is verified everytime a request goes through. Without this hash matching from the proxy server, the "normal" server rejects requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddServerReq

type AddServerReq struct {
	IP string
}

AddServerReq is the incoming request for adding a server to the proxy

type AddServerRes

type AddServerRes struct {
	Hash string
}

AddServerRes is the response for /addServer request

type Server

type Server struct {
	RouteMap SyncMap     // A custom sync map
	Router   *mux.Router // The proxy router
}

Server holds the data about a proxy server

var ProxyServer Server

ProxyServer is the server datatype

func StartProxy

func StartProxy(r *mux.Router, port string) (Server, error)

StartProxy is used to start a single proxy server. Creates a new router, assigns the port to the proxy, and starts the server. The user cannot handle routing of the proxy server. All routing is handled by special mechanisms as described in adding and removing servers.

type SyncMap

type SyncMap struct {
	Routes map[string]string // Hash of server and IP mapping
	Mutex  sync.Mutex        //Lock
}

SyncMap is a custom sync map

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL