boringproxy

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: MIT Imports: 32 Imported by: 0

README

Disclaimer

boringproxy is currently beta-quality software. While I am a big believer in open source, my primary goal at the moment is to build a sustainable business around the code I write. So for the most part I can only afford to spend time fixing problems that arise in my own usage of boringproxy. That said, feel free to create GitHub issues and I'll try to help as I have time.

What is it?

If you have a webserver running on one computer (say your development laptop), and you want to expose it securely (ie HTTPS) via a public URL, boringproxy allows you to easily do that.

NOTE: For information on downloading and running boringproxy, it's best to start on the website, boringproxy.io. The information in this README is just for building from source.

Building

git clone https://github.com/boringproxy/boringproxy
cd boringproxy

If you don't already have golang installed:

./install_go.sh
source $HOME/.bashrc
go build

To embed the web UI into the executable:

go get github.com/GeertJohan/go.rice/rice
rice embed-go
go build

Running

Server

boringproxy server -admin-domain bpdemo.brng.pro

Client

boringproxy client -server bpdemo.brng.pro -token fKFIjefKDFLEFijKDFJKELJF -client-name demo-client -user demo-user

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen()

func MakeSSHKeyPair

func MakeSSHKeyPair() (string, string, error)

Adapted from https://stackoverflow.com/a/34347463/943814 MakeSSHKeyPair make a pair of public and private keys for SSH access. Public key is encoded in the format for inclusion in an OpenSSH authorized_keys file. Private Key generated is PEM encoded

Types

type AlertData

type AlertData struct {
	Head        template.HTML
	Message     string
	RedirectUrl string
}

type Api

type Api struct {
	// contains filtered or unexported fields
}

func NewApi

func NewApi(config *Config, db *Database, auth *Auth, tunMan *TunnelManager) *Api

func (*Api) CreateToken

func (a *Api) CreateToken(tokenData TokenData, params url.Values) (string, error)

func (*Api) CreateTunnel

func (a *Api) CreateTunnel(tokenData TokenData, params url.Values) (*Tunnel, error)

func (*Api) CreateUser

func (a *Api) CreateUser(tokenData TokenData, params url.Values) error

func (*Api) DeleteClient

func (a *Api) DeleteClient(tokenData TokenData, ownerId, clientId string) error

func (*Api) DeleteSshKey

func (a *Api) DeleteSshKey(tokenData TokenData, params url.Values) error

func (*Api) DeleteToken

func (a *Api) DeleteToken(tokenData TokenData, params url.Values) error

func (*Api) DeleteTunnel

func (a *Api) DeleteTunnel(tokenData TokenData, params url.Values) error

func (*Api) DeleteUser

func (a *Api) DeleteUser(tokenData TokenData, params url.Values) error

func (*Api) GetSshKeys

func (a *Api) GetSshKeys(tokenData TokenData) map[string]SshKey

func (*Api) GetTunnel

func (a *Api) GetTunnel(tokenData TokenData, params url.Values) (Tunnel, error)

func (*Api) GetTunnels

func (a *Api) GetTunnels(tokenData TokenData) map[string]Tunnel

func (*Api) ServeHTTP

func (a *Api) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Api) SetClient

func (a *Api) SetClient(tokenData TokenData, params url.Values, ownerId, clientId string) error

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

func NewAuth

func NewAuth(db *Database) *Auth

func (*Auth) Authorized

func (a *Auth) Authorized(token string) bool

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *ClientConfig) (*Client, error)

func (*Client) BoreTunnel

func (c *Client) BoreTunnel(ctx context.Context, tunnel Tunnel) error

func (*Client) PollTunnels

func (c *Client) PollTunnels(ctx context.Context) error

func (*Client) Run added in v0.6.0

func (c *Client) Run(ctx context.Context) error

func (*Client) SyncTunnels

func (c *Client) SyncTunnels(ctx context.Context, serverTunnels map[string]Tunnel)

type ClientConfig

type ClientConfig struct {
	ServerAddr string `json:"serverAddr,omitempty"`
	Token      string `json:"token,omitempty"`
	ClientName string `json:"clientName,omitempty"`
	User       string `json:"user,omitempty"`
	CertDir    string `json:"certDir,omitempty"`
	AcmeEmail  string `json:"acmeEmail,omitempty"`
	DnsServer  string `json:"dnsServer,omitempty"`
}

type Config

type Config struct {
	WebUiDomain   string `json:"webui_domain"`
	SshServerPort int    `json:"ssh_server_port"`
}

type ConfirmData

type ConfirmData struct {
	Head       template.HTML
	Message    string
	ConfirmUrl string
	CancelUrl  string
}

type Database

type Database struct {
	Tokens  map[string]TokenData `json:"tokens"`
	Tunnels map[string]Tunnel    `json:"tunnels"`
	Users   map[string]User      `json:"users"`
	SshKeys map[string]SshKey    `json:"ssh_keys"`
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase() (*Database, error)

func (*Database) AddSshKey

func (d *Database) AddSshKey(id string, key SshKey) error

func (*Database) AddToken

func (d *Database) AddToken(owner string) (string, error)

func (*Database) AddUser

func (d *Database) AddUser(username string, isAdmin bool) error

func (*Database) DeleteSshKey

func (d *Database) DeleteSshKey(id string)

func (*Database) DeleteTokenData

func (d *Database) DeleteTokenData(token string)

func (*Database) DeleteTunnel

func (d *Database) DeleteTunnel(domain string)

func (*Database) DeleteUser

func (d *Database) DeleteUser(username string)

func (*Database) GetSshKey

func (d *Database) GetSshKey(id string) (SshKey, bool)

func (*Database) GetSshKeys

func (d *Database) GetSshKeys() map[string]SshKey

func (*Database) GetTokenData

func (d *Database) GetTokenData(token string) (TokenData, bool)

func (*Database) GetTokens

func (d *Database) GetTokens() map[string]TokenData

func (*Database) GetTunnel

func (d *Database) GetTunnel(domain string) (Tunnel, bool)

func (*Database) GetTunnels

func (d *Database) GetTunnels() map[string]Tunnel

func (*Database) GetUser

func (d *Database) GetUser(username string) (User, bool)

func (*Database) GetUsers

func (d *Database) GetUsers() map[string]User

func (*Database) SetTokenData

func (d *Database) SetTokenData(token string, tokenData TokenData)

func (*Database) SetTunnel

func (d *Database) SetTunnel(domain string, tun Tunnel)

func (*Database) SetUser

func (d *Database) SetUser(username string, user User) error

type DbClient

type DbClient struct {
}

type HeadData

type HeadData struct {
	Styles template.CSS
}

type IndexData

type IndexData struct {
	Head    template.HTML
	Tunnels map[string]Tunnel
	Tokens  map[string]TokenData
	SshKeys map[string]SshKey
	Users   map[string]User
	UserId  string
	IsAdmin bool
	QrCodes map[string]template.URL
}

type LoadingData

type LoadingData struct {
	Head      template.HTML
	TargetUrl string
}

type LoginData

type LoginData struct {
	Head template.HTML
}

type LoginRequest

type LoginRequest struct {
	Email string
}
type MenuData struct {
	IsAdmin bool
}

type PassthroughListener

type PassthroughListener struct {
	// contains filtered or unexported fields
}

func NewPassthroughListener

func NewPassthroughListener() *PassthroughListener

func (*PassthroughListener) Accept

func (f *PassthroughListener) Accept() (net.Conn, error)

func (*PassthroughListener) Addr

func (f *PassthroughListener) Addr() net.Addr

func (*PassthroughListener) Close

func (f *PassthroughListener) Close() error

func (*PassthroughListener) PassConn

func (f *PassthroughListener) PassConn(conn net.Conn)

type ProxyConn

type ProxyConn struct {
	// contains filtered or unexported fields
}

This type creates a new net.Conn that's the same as an old one, except a new reader is provided. So it proxies every method except Read. I'm sure there's a cleaner way to do this...

func NewProxyConn

func NewProxyConn(conn net.Conn, reader io.Reader) *ProxyConn

func (ProxyConn) Close

func (c ProxyConn) Close() error

TODO: is this safe? Will it actually close properly, or does it need to be connected to the reader somehow?

func (ProxyConn) CloseWrite

func (c ProxyConn) CloseWrite() error

func (ProxyConn) LocalAddr

func (c ProxyConn) LocalAddr() net.Addr

func (ProxyConn) Read

func (c ProxyConn) Read(p []byte) (int, error)

func (ProxyConn) RemoteAddr

func (c ProxyConn) RemoteAddr() net.Addr

func (ProxyConn) SetDeadline

func (c ProxyConn) SetDeadline(t time.Time) error

func (ProxyConn) SetReadDeadline

func (c ProxyConn) SetReadDeadline(t time.Time) error

func (ProxyConn) SetWriteDeadline

func (c ProxyConn) SetWriteDeadline(t time.Time) error

func (ProxyConn) Write

func (c ProxyConn) Write(p []byte) (int, error)

type ReqResult

type ReqResult struct {
	// contains filtered or unexported fields
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

type SmtpConfig

type SmtpConfig struct {
	Server   string
	Port     int
	Username string
	Password string
}

type SshKey

type SshKey struct {
	Owner string `json:"owner"`
	Key   string `json:"key"`
}

type TokenData

type TokenData struct {
	Owner string `json:"owner"`
}

type TokensData

type TokensData struct {
	Head   template.HTML
	Tokens map[string]TokenData
	Users  map[string]User
}

type Tunnel

type Tunnel struct {
	Owner            string `json:"owner"`
	Domain           string `json:"domain"`
	SshKey           string `json:"ssh_key"`
	ServerAddress    string `json:"server_address"`
	ServerPort       int    `json:"server_port"`
	ServerPublicKey  string `json:"server_public_key"`
	Username         string `json:"username"`
	TunnelPort       int    `json:"tunnel_port"`
	TunnelPrivateKey string `json:"tunnel_private_key"`
	ClientName       string `json:"client_name"`
	ClientAddress    string `json:"client_address"`
	ClientPort       int    `json:"client_port"`
	AllowExternalTcp bool   `json:"allow_external_tcp"`
	AuthUsername     string `json:"auth_username"`
	AuthPassword     string `json:"auth_password"`
	CssId            string `json:"css_id"`
	TlsTermination   string `json:"tls_termination"`
}

type TunnelManager

type TunnelManager struct {
	// contains filtered or unexported fields
}

func NewTunnelManager

func NewTunnelManager(config *Config, db *Database, certConfig *certmagic.Config) *TunnelManager

func (*TunnelManager) DeleteTunnel

func (m *TunnelManager) DeleteTunnel(domain string) error

func (*TunnelManager) GetPort

func (m *TunnelManager) GetPort(domain string) (int, error)

func (*TunnelManager) GetTunnels

func (m *TunnelManager) GetTunnels() map[string]Tunnel

func (*TunnelManager) RequestCreateTunnel

func (m *TunnelManager) RequestCreateTunnel(tunReq Tunnel) (Tunnel, error)

type TunnelsData

type TunnelsData struct {
	Head    template.HTML
	Tunnels map[string]Tunnel
}

type User

type User struct {
	IsAdmin bool                `json:"is_admin"`
	Clients map[string]DbClient `json:"clients"`
}

type UsersData

type UsersData struct {
	Head  template.HTML
	Users map[string]User
}

type WebUiHandler

type WebUiHandler struct {
	// contains filtered or unexported fields
}

func NewWebUiHandler

func NewWebUiHandler(config *Config, db *Database, api *Api, auth *Auth, tunMan *TunnelManager) *WebUiHandler

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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