nivenly

package
v0.0.0-...-03597bf Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProxyFor    = "NovaProxy-For"
	ProxyClient = "NovaProxy-Client"
)

NovaProxy:

proxy_set_header NovaProxy-For $proxy_add_x_forwarded_for; proxy_set_header NovaProxy-Host $host; proxy_set_header NovaProxy-Client $remote_addr; proxy_set_header NovaProxy-Proto $scheme; proxy_set_header NovaProxy-Port "30000";

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap()

Bootstrap will start the application with its very specific configuration, and then begin serving content.

func ClientAddr

func ClientAddr(r *http.Request) string

ClientAddr is the logic that will respect the NovaProxy headers and pull the true client addr from the proxy (if it exists)

Types

type Analytics

type Analytics struct {
	anchovies.EmbedRecord

	// Client hostname total visits
	ClientVisits map[string]int

	// PageVisits total visits by page
	PageVisits map[string]int

	ThisPageVisits   string
	ThisClientVisits string
}

Analytics is a site level analytics structure.

Have fun hacking this shit up!

Everything here is exposed to the website's frontend.

func GetAnalytics

func GetAnalytics(r *http.Request, client Client) Analytics

type Client

type Client struct {

	// Addr is your name
	Addr string

	// NMAP is the raw NMAP results
	PortScan *lib.ScanResults

	// ClientString is the handy string we can print out
	// that contains client information
	ClientString string

	// GeoString is the handy string we can print out that
	// contains GeoIP information
	GeoString string
}

Client is you

type ClientHandler

type ClientHandler struct {
	Clients map[string]Client
}

func (*ClientHandler) GetClient

func (v *ClientHandler) GetClient(r *http.Request) Client

GetClient will hit the cache and return a client if it exists Otherwise it will create a new client in memory.

TODO we should cap the buffer and implement a timeout. DoS is real.

func (ClientHandler) ServeHTTP

func (v ClientHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Crypto

type Crypto struct {
	Status       string
	Addr         string
	SyncProgress *ethereum.SyncProgress
	BalanceWei   int64
}

func GetCrypto

func GetCrypto(r *http.Request, client Client) Crypto

type Empty

type Empty struct {
}

type EmptyHandler

type EmptyHandler struct {
}

func (*EmptyHandler) ServeHTTP

func (h *EmptyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Message

type Message struct {
	Value string
	Code  int
}

Message is an HTTP message we can pass around.

type Nivenly

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

Nivenly is a container for the Application as an in-memory state machine.

This is relatively simple and should not change very often.

We get a new instance of this during every bootstrap.

func DefaultValues

func DefaultValues() *Nivenly

DefaultValues is just sample text to interpolate.

It's wise to return sane defaults in the event of an error. so we don't break the underlying website.

func (*Nivenly) GetAPI

func (v *Nivenly) GetAPI(r *http.Request) *NivenlyAPI

GetAPI is the method that is called for every HTTP request to the website.

Break out by client here.

func (*Nivenly) Lock

func (v *Nivenly) Lock()

func (*Nivenly) Refresh

func (v *Nivenly) Refresh()

Refresh is how we Refresh any "long" or "medium" data The server calls this before .Values() (usually).

func (*Nivenly) Unlock

func (v *Nivenly) Unlock()

func (*Nivenly) Values

func (v *Nivenly) Values(r *http.Request) interface{}

Values is what we interpolate.

Every request to the server (that needs to be interpolated) will pass in the request for consideration.

type NivenlyAPI

type NivenlyAPI struct {

	// Crypto is all crypto (Not ethereum specific, although we start there)
	Crypto Crypto

	// Analytics will be page analytics for each page
	Analytics Analytics

	// ClientAddr
	// 1 if by proxy
	// 2 if by request
	//
	// Here is where we define exactly "who" our friendly visitor is.
	//
	// This is the most critical string as it also serves as the "key"
	// in our cache in memory.
	ClientAddr string

	// Client is the nested *Client which is the same data structure
	// that can be found at the /client endpoint.
	Client Client

	// R is the *http.Request for EACH request to the server.
	R *http.Request
}

NivenlyAPI is a request specific API for the website.

All user input that comes into the website comes in the form of an HTTP request, therefor regardless of the state of the backend, we can get everything we need via an HTTP request.

Here is the API.

Add fields carefully!

This is concretely what is referenced in the "params" in the config.toml

If you can get data here - you can interpolate into the website.

Directories

Path Synopsis
lib

Jump to

Keyboard shortcuts

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