proxy

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicAnnouncementType  uint8 = 1
	PrivateAnnouncementType uint8 = 2
)

Variables

View Source
var DirectorySettingsForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "allowed_domains",
			Validators: []forms.Validator{
				forms.IsList{
					Validators: []forms.Validator{
						forms.IsString{},
						forms.MatchesRegex{Regexp: regexp.MustCompile(`^\.`)},
					},
				},
			},
		},
	},
}
View Source
var GetPrivateAnnouncementsForm = forms.Form{
	Fields: []forms.Field{},
}
View Source
var GetPublicAnnouncementsForm = forms.Form{
	Fields: []forms.Field{},
}
View Source
var IncomingConnectionForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "token",
			Validators: []forms.Validator{
				forms.IsBytes{
					Encoding:  "base64",
					MinLength: 32,
					MaxLength: 32,
				},
			},
		},
		{
			Name: "endpoint",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "domain",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "_client",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &hyperForms.ClientInfoForm,
				},
			},
		},
	},
}
View Source
var InternalEndpointForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "address",
			Validators: []forms.Validator{
				forms.IsOptional{Default: "localhost:8888"},
				forms.IsString{},
			},
		},
		{
			Name: "tls",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsStringMap{
					Form: &tls.TLSSettingsForm,
				},
			},
		},
		{
			Name: "jsonrpc_client",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsStringMap{
					Form: &jsonrpc.JSONRPCClientSettingsForm,
				},
			},
		},
		{
			Name: "jsonrpc_path",
			Validators: []forms.Validator{
				forms.IsOptional{Default: "/jsonrpc"},
				forms.IsString{},
			},
		},
		{
			Name: "timeout",
			Validators: []forms.Validator{
				forms.IsOptional{Default: 30.0},
				forms.IsFloat{HasMin: true, Min: 0, HasMax: true, Max: 3000},
			},
		},
	},
}
View Source
var PrivateAnnounceConnectionForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "expires_at",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsString{},
				forms.IsTime{
					Format: "rfc3339",
				},
				IsValidExpiresAtTime{},
			},
		},
		{
			Name: "proxy",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "domain",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "_client",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &hyperForms.ClientInfoForm,
				},
			},
		},
	},
}
View Source
var PrivateSettingsForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "datastore",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &hyperForms.DatastoreForm,
				},
			},
		},
		{
			Name: "name",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "internal_endpoint",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &InternalEndpointForm,
				},
			},
		},
		{
			Name: "jsonrpc_client",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &jsonrpc.JSONRPCClientSettingsForm,
				},
			},
		},
		{
			Name: "jsonrpc_server",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &jsonrpc.JSONRPCServerSettingsForm,
				},
			},
		},
	},
}
View Source
var PublicAnnounceConnectionsForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "_client",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &hyperForms.ClientInfoForm,
				},
			},
		},
		{
			Name: "connections",
			Validators: []forms.Validator{
				forms.IsList{
					Validators: []forms.Validator{
						forms.IsStringMap{
							Form: &PublicConnectionForm,
						},
					},
				},
			},
		},
	},
}
View Source
var PublicConnectionForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "expires_at",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsString{},
				forms.IsTime{
					Format: "rfc3339",
				},
				IsValidExpiresAtTime{},
			},
		},
		{
			Name: "domain",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
	},
}
View Source
var PublicRequestConnectionForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "_client",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &hyperForms.ClientInfoForm,
				},
			},
		},
		{
			Name: "to",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "channel",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
	},
}
View Source
var PublicSettingsForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "datastore",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &hyperForms.DatastoreForm,
				},
			},
		},
		{
			Name: "name",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		net.TCPRateLimitsField,
		{
			Name: "tls_bind_address",
			Validators: []forms.Validator{
				forms.IsOptional{Default: "localhost:443"},
				forms.IsString{},
			},
		},
		{
			Name: "internal_bind_address",
			Validators: []forms.Validator{
				forms.IsOptional{Default: "localhost:9999"},
				forms.IsString{},
			},
		},
		{
			Name: "internal_endpoint",
			Validators: []forms.Validator{
				forms.IsOptional{Default: "localhost:9999"},
				forms.IsString{},
			},
		},
		{
			Name: "jsonrpc_client",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &jsonrpc.JSONRPCClientSettingsForm,
				},
			},
		},
		{
			Name: "jsonrpc_server",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &jsonrpc.JSONRPCServerSettingsForm,
				},
			},
		},
		{
			Name: "accept_timeout",
			Validators: []forms.Validator{
				forms.IsOptional{Default: 10.0},
				forms.IsFloat{HasMin: true, Min: 0, HasMax: true, Max: 3000},
			},
		},
	},
}
View Source
var SettingsForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "metrics",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsStringMap{
					Form: &hyperForms.MetricsSettingsForm,
				},
			},
		},
		{
			Name: "public",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsStringMap{
					Form: &PublicSettingsForm,
				},
			},
		},
		{
			Name: "private",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsStringMap{
					Form: &PrivateSettingsForm,
				},
			},
		},
	},
}

Functions

This section is empty.

Types

type DirectorySettings

type DirectorySettings struct {
	AllowedDomains []string `json:"allowed_domains"`
}

type GetPrivateAnnouncementsParams

type GetPrivateAnnouncementsParams struct{}

type GetPublicAnnouncementsParams

type GetPublicAnnouncementsParams struct{}

type IncomingConnectionParams

type IncomingConnectionParams struct {
	Domain   string            `json:"domain"`
	Endpoint string            `json:"endpoint"`
	Token    []byte            `json:"token"`
	Client   *hyper.ClientInfo `json:"_client"`
}

type InternalEndpointSettings

type InternalEndpointSettings struct {
	Address       string                         `json:"address"`
	TLS           *tls.TLSSettings               `json:"tls"`
	JSONRPCClient *jsonrpc.JSONRPCClientSettings `json:"jsonrpc_client"`
	JSONRPCPath   string                         `json:"jsonrpc_path"`
	Timeout       float64                        `json:"timeout"`
}

type IsValidExpiresAtTime

type IsValidExpiresAtTime struct{}

func (IsValidExpiresAtTime) Validate

func (i IsValidExpiresAtTime) Validate(value interface{}, values map[string]interface{}) (interface{}, error)

type PrivateAnnounceConnectionParams

type PrivateAnnounceConnectionParams struct {
	ClientInfo *hyper.ClientInfo `json:"_client"`
	ExpiresAt  *time.Time        `json:"expires_at"`
	Domain     string            `json:"domain"`
	Proxy      string            `json:"proxy"`
}

type PrivateAnnouncement

type PrivateAnnouncement struct {
	// When the announcement expires
	ExpiresAt *time.Time `json:"expires_at"`
	// the name of the public proxy to announce this to
	Proxy string `json:"proxy"`
	// the pattern to announce, as a regexp
	Domain string `json:"domain"`
}

type PrivateServer

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

func MakePrivateServer

func MakePrivateServer(settings *PrivateServerSettings, definitions *hyper.Definitions) (*PrivateServer, error)

func (*PrivateServer) Start

func (s *PrivateServer) Start() error

func (*PrivateServer) Stop

func (s *PrivateServer) Stop() error

type PrivateServerSettings

type PrivateServerSettings struct {
	Datastore        *hyper.DatastoreSettings       `json:"datastore"`
	Name             string                         `json:"name"`
	Announcements    []*PrivateAnnouncement         `json:"announcements"`
	InternalEndpoint *InternalEndpointSettings      `json:"internal_endpoint"`
	JSONRPCClient    *jsonrpc.JSONRPCClientSettings `json:"jsonrpc_client"`
	JSONRPCServer    *jsonrpc.JSONRPCServerSettings `json:"jsonrpc_server`
}

type ProxyConnection

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

func MakeProxyConnection

func MakeProxyConnection(proxyEndpoint string, token []byte, settings *InternalEndpointSettings, tlsConfig *tls.Config) *ProxyConnection

func (*ProxyConnection) ForwardTLS

func (p *ProxyConnection) ForwardTLS(proxyConnection net.Conn) error

func (*ProxyConnection) Run

func (p *ProxyConnection) Run() error

func (*ProxyConnection) TerminateTLS

func (p *ProxyConnection) TerminateTLS(proxyConnection net.Conn) error

type ProxyListener

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

func (*ProxyListener) Accept

func (p *ProxyListener) Accept() (net.Conn, error)

func (*ProxyListener) Addr

func (p *ProxyListener) Addr() net.Addr

we don't implement Addr

func (*ProxyListener) Close

func (p *ProxyListener) Close() error

type PublicAnnounceConnectionsParams

type PublicAnnounceConnectionsParams struct {
	Connections []*PublicProxyConnection
	ClientInfo  *hyper.ClientInfo `json:"_client"`
}

type PublicAnnouncement

type PublicAnnouncement struct {
	// When the announcement expires
	ExpiresAt *time.Time `json:"expires_at"`
	// the name of the operator to forward the connection to
	Operator string `json:"operator"`
	// the name of the domain to forward
	Domain string `json:"domain"`
}

type PublicProxyConnection

type PublicProxyConnection struct {
	Domain    string     `json:"domain"`
	ExpiresAt *time.Time `json:"expires_at"`
}

type PublicRequestConnectionParams

type PublicRequestConnectionParams struct {
	To         string            `json:"to"`
	Channel    string            `json:"channel"`
	ClientInfo *hyper.ClientInfo `json:"_client"`
}

type PublicServer

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

func MakePublicServer

func MakePublicServer(settings *PublicServerSettings, definitions *hyper.Definitions) (*PublicServer, error)

func (*PublicServer) Start

func (s *PublicServer) Start() error

func (*PublicServer) Stop

func (s *PublicServer) Stop() error

type PublicServerSettings

type PublicServerSettings struct {
	Datastore           *hyper.DatastoreSettings       `json:"datastore"`
	Name                string                         `json:"name"`
	TLSBindAddress      string                         `json:"tls_bind_address"`
	InternalBindAddress string                         `json:"internal_bind_address"`
	InternalEndpoint    string                         `json:"internal_endpoint"`
	JSONRPCClient       *jsonrpc.JSONRPCClientSettings `json:"jsonrpc_client"`
	JSONRPCServer       *jsonrpc.JSONRPCServerSettings `json:"jsonrpc_server`
	TCPRateLimits       []*net.RateLimit               `json:"tcp_rate_limits"`
	AcceptTimeout       float64                        `json:"accept_timeout"`
}

type Server

type Server interface {
	Start() error
	Stop() error
}

type Settings

type Settings struct {
	Definitions *hyper.Definitions     `json:"definitions"`
	Metrics     *hyper.MetricsSettings `json:"metrics"`
	Private     *PrivateServerSettings `json:"private"`
	Public      *PublicServerSettings  `json:"public"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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