boringproxy

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 34 Imported by: 0

README

boringproxy development is sponsored by TakingNames.io. boringproxy offers full integration with TakingNames.io, providing the simplest way to get up and running with your own domain. More information here, and a demo video of boringproxy working with TakingNames.io here.

Getting Help

If you run into problems running boringproxy, the best place to ask for help is over at the IndieBits community, where we have a dedicated section for boringproxy support. If you think you've found a bug, or want to discuss development, please open an issue.

What is boringproxy?

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

Make the logo image file. It gets baked into the executable so it needs to be available at build time. Note that you don't have to use the official logo for the build. Any PNG will do. It's currently just used for the favicon.

./scripts/generate_logo.sh
cd cmd/boringproxy
go build

To build with version information:

go build -ldflags "-X main.Version=$(git describe --tags)"

Give the executable permission to bind low ports (ie 80/443):

sudo setcap cap_net_bind_service=+ep boringproxy

Running

Server

./boringproxy server

Client

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBFolderPath string

Functions

func IsIPv4 added in v0.9.0

func IsIPv4(address string) bool

Taken from https://stackoverflow.com/a/48519490/943814

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

func ProxyTcp added in v0.10.0

func ProxyTcp(conn net.Conn, addr string, port int, useTls bool, certConfig *certmagic.Config) error

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) 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) GetTokens added in v0.10.0

func (a *Api) GetTokens(tokenData TokenData, params url.Values) map[string]TokenData

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) GetUsers added in v0.10.0

func (a *Api) GetUsers(tokenData TokenData, params url.Values) map[string]User

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"`
	AcmeUseStaging bool   `json:"acmeUseStaging,omitempty"`
	AcmeCa         string `json:"acmeCa,omitempty"`
	DnsServer      string `json:"dnsServer,omitempty"`
	BehindProxy    bool   `json:"behindProxy,omitempty"`
	PollInterval   int    `json:"pollInterval,omitempty"`
}

type Config

type Config struct {
	SshServerPort int    `json:"ssh_server_port"`
	PublicIp      string `json:"public_ip"`
	// contains filtered or unexported fields
}

type ConfirmData

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

type DNSRecord added in v0.8.0

type DNSRecord struct {
	Type     string `json:"type"`
	Value    string `json:"value"`
	TTL      int    `json:"ttl"`
	Priority int    `json:"priority"`
}

type Database

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

func NewDatabase

func NewDatabase(path string) (*Database, error)

func (*Database) AddToken

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

func (*Database) AddUser

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

func (*Database) DeleteDNSRequest added in v0.8.0

func (d *Database) DeleteDNSRequest(requestId 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) GetAdminDomain added in v0.8.0

func (d *Database) GetAdminDomain() string

func (*Database) GetDNSRequest added in v0.8.0

func (d *Database) GetDNSRequest(requestId string) (namedrop.DNSRequest, error)

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) SetAdminDomain added in v0.8.0

func (d *Database) SetAdminDomain(adminDomain string)

func (*Database) SetDNSRequest added in v0.8.0

func (d *Database) SetDNSRequest(requestId string, request namedrop.DNSRequest)

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 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 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. This is necessary because by calling peekClientHello, part of the reader is read, so we need to create a new reader with the already read data inserted back in the front. 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 TokenData

type TokenData struct {
	Owner  string `json:"owner"`
	Client string `json:"client,omitempty"`
}

type Tunnel

type Tunnel struct {
	Domain           string `json:"domain"`
	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"`
	ClientAddress    string `json:"client_address"`
	ClientPort       int    `json:"client_port"`
	AllowExternalTcp bool   `json:"allow_external_tcp"`
	TlsTermination   string `json:"tls_termination"`

	// TODO: These are not used by clients and possibly shouldn't be
	// returned in API calls.
	Owner        string `json:"owner"`
	ClientName   string `json:"client_name"`
	AuthUsername string `json:"auth_username"`
	AuthPassword string `json:"auth_password"`
}

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 User

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

type WebUiHandler

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

func NewWebUiHandler

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

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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