presence

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDb added in v0.0.4

func NewDb() *db

NewDb constructor...

func NewService added in v0.0.4

func NewService(db IDb) *service

NewService constructor

Types

type CocoHostSanitizer added in v0.0.4

type CocoHostSanitizer interface {
	Sanitize(models.CocoHostInfo) models.CocoHostInfo
}

CocoHostSanitizer cleans untrusted input fields

type CoconodeSanitizer added in v0.0.4

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

CoconodeSanitizer kills untrusted input in CocoHostInfo structs

func NewCoconodeSanitizer added in v0.0.4

func NewCoconodeSanitizer(p *bluemonday.Policy) CoconodeSanitizer

NewCoconodeSanitizer constructor...

func (*CoconodeSanitizer) Sanitize added in v0.0.4

Sanitize CocoHostInfo input

type Config added in v0.0.4

type Config struct {
	CocoHostSanitizer        CocoHostSanitizer
	MixHostSanitizer         MixHostSanitizer
	MixNodeIDSanitizer       IMixNodeIDSanitizer
	MixProviderHostSanitizer MixProviderHostSanitizer
	GatewayHostSanitizer     GatewayHostSanitizer
	Service                  IService
}

Config for this controller

type Controller

type Controller interface {
	AddCocoNodePresence(c *gin.Context)
	AddMixNodePresence(c *gin.Context)
	Topology(c *gin.Context)
	RegisterRoutes(router *gin.Engine)
}

Controller is the presence controller interface

func New

func New(cfg Config) Controller

New constructor

type GatewayHostSanitizer added in v0.7.0

type GatewayHostSanitizer interface {
	Sanitize(models.GatewayHostInfo) models.GatewayHostInfo
}

GatewayHostSanitizer cleans untrusted input fields

type GatewaySanitizer added in v0.7.0

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

GatewaySanitizer kills untrusted input in GatewayHostInfo structs

func NewGatewaySanitizer added in v0.7.0

func NewGatewaySanitizer(p *bluemonday.Policy) GatewaySanitizer

NewGatewaySanitizer constructor...

func (*GatewaySanitizer) Sanitize added in v0.7.0

Sanitize GatewayHostInfo input

type IDb added in v0.0.4

type IDb interface {
	AddCoco(models.CocoPresence)
	AddMix(models.MixNodePresence)
	AddMixProvider(models.MixProviderPresence)
	AddGateway(models.GatewayPresence)
	Allow(string)
	Disallow(string)
	ListDisallowed() []string
	Topology() models.Topology
}

IDb holds presence information

type IMixNodeIDSanitizer added in v0.7.0

type IMixNodeIDSanitizer interface {
	Sanitize(models.MixNodeID) models.MixNodeID
}

IMixNodeIDSanitizer cleans untrusted input fields

type IPAssigner added in v0.0.4

type IPAssigner interface {
	AssignIP(serverReportedIP string, selfReportedHost string) (string, error)
}

IPAssigner compares the realIP (taken from the incoming request to the controller) and the self-reported presence IP (taken from the presence report data), and tries to report a reasonable IP. Much like the trouble with SUVs detailed by Paul Graham (http://www.paulgraham.com/hundred.html), this is a gross solution to a gross problem.

In our case, the cause of hassle is that AWS servers: (a) don't allow applications hosted on them to determine what address they're binding to easily, because there are no "real" public IPs assigned, and (b) cause the application to explode if you attempt to bind to the public IP at all (private IPs do exist and can be bound to).

If we could, we'd always read from the incoming request - but this has another problem: incoming requests don't tell us which port the remote node is listening on. So we need to combine self-reported and real IP.

type IService added in v0.0.4

type IService interface {
	AddCocoNodePresence(info models.CocoHostInfo, ip string)
	AddMixNodePresence(info models.MixHostInfo)
	AddMixProviderPresence(info models.MixProviderHostInfo)
	AddGatewayPresence(info models.GatewayHostInfo)
	Allow(hostKey models.MixNodeID)
	Disallow(hostKey models.MixNodeID)
	ListDisallowed() []models.MixNodePresence
	Topology() models.Topology
}

IService defines the REST service interface for presence.

type MixHostSanitizer added in v0.0.4

type MixHostSanitizer interface {
	Sanitize(models.MixHostInfo) models.MixHostInfo
}

MixHostSanitizer cleans untrusted input fields

type MixNodeIDSanitizer added in v0.7.0

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

MixNodeIDSanitizer kills untrusted input in CocoHostInfo structs

func NewMixnodeIDSanitizer added in v0.7.0

func NewMixnodeIDSanitizer(p *bluemonday.Policy) MixNodeIDSanitizer

NewMixnodeIDSanitizer ...

func (*MixNodeIDSanitizer) Sanitize added in v0.7.0

func (s *MixNodeIDSanitizer) Sanitize(input models.MixNodeID) models.MixNodeID

Sanitize MixNodeID input

type MixProviderHostSanitizer added in v0.0.4

type MixProviderHostSanitizer interface {
	Sanitize(models.MixProviderHostInfo) models.MixProviderHostInfo
}

MixProviderHostSanitizer cleans untrusted input fields

type MixnodeSanitizer added in v0.0.4

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

MixnodeSanitizer kills untrusted input in MixHostInfo structs

func NewMixnodeSanitizer added in v0.0.4

func NewMixnodeSanitizer(p *bluemonday.Policy) MixnodeSanitizer

NewMixnodeSanitizer constructor...

func (*MixnodeSanitizer) Sanitize added in v0.0.4

Sanitize MixHostInfo input

type MixproviderSanitizer added in v0.0.4

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

MixproviderSanitizer kills untrusted input in MixProviderHostInfo structs

func NewMixproviderSanitizer added in v0.0.4

func NewMixproviderSanitizer(p *bluemonday.Policy) MixproviderSanitizer

NewMixproviderSanitizer constructor...

func (*MixproviderSanitizer) Sanitize added in v0.0.4

Sanitize MixProviderHostInfo input

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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