core

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: GPL-3.0 Imports: 34 Imported by: 0

README

test

Go Reference

Documentation

Overview

Copyright (C) 2021 light-river, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	DEFAULT_flip_TMP_ROOT         string = ".data/tmp"
	DEFAULT_TEMP_EXECUTION_PARENT string = "run-*"
	DEFAULT_COMPRESSION_FORMAT    string = "%v.zst"
	DEFAULT_METADATA_FORMAT       string = "%v.meta"
)

We create the following EnvFile for each execution

OS_TEMP/ 1. Operating system temporary directory

	|
	- TEMP_PARENT/									 2. The parent sub-directory for all flip executions
   |
   - TEMP_PREFIX-$RANDOM/						 3. A per-execution sub-directory
   	|
		$CONCURRENT_ORDERED_FILENAME.TEMP_EXTENSION/ 4. Chunks that are written with a reconstructable order despite concurrent creation

Variables

This section is empty.

Functions

func Changes

func Changes(stat1, stat2 fs.FileInfo) (Change, Change)

func ChunkBytesVariablely

func ChunkBytesVariablely(byteArr []byte, chunks int) [][]byte

func ChunkedRandomPrime

func ChunkedRandomPrime(bits, chunks int) [][]byte

func Counter

func Counter(arr []byte) (map[byte]int, map[int]byte, int)

func CreateSelfSignedCertificates

func CreateSelfSignedCertificates(proxy ReverseProxy)

CreateSelfSignedCertificates

Creates a CA Cert & Key for a given ReverseProxy & writes to disk

func DecodeBase64

func DecodeBase64(arr []byte, c chan []byte)

func DecodeHex

func DecodeHex(src []byte) chan []byte

func EncodeBase64

func EncodeBase64(arr []byte, c chan []byte)

func EncodeHex

func EncodeHex(src []byte) chan []byte

func EncodeRune

func EncodeRune(arr []byte, c chan []rune)

func FixedXOR

func FixedXOR(src []byte, res chan []byte)

FixedXOR

The resulting channel will get a hex encoded []byte
created from the XOR of each byte i where
	src[i] XOR [i+len(src)/2]
while any []byte can be the src the general use-case is to pre-encode src to hex

func GenerateLogger

func GenerateLogger(logFileName string) *log.Logger

func MostFrequentIn

func MostFrequentIn(arr []byte) byte

func NewNetworkGraph

func NewNetworkGraph(args Edge) *ring.Ring

Graph Builds a two-dimensional, rectangular graph, Wraps *ring.Ring

func OpenTempFile

func OpenTempFile() *os.File

func PrettyPrint

func PrettyPrint(v interface{}) string

func PrintAll

func PrintAll(r *ring.Ring)

PrintAll Prints all nodes in a subgraph Passing root will print the entire graph

Take note of `r.Do`, this basic example shows how to:

  1. cast to our type `Edge`
  2. Print, however, this can be any transformation `f(e)`

func RandomPrime

func RandomPrime(bits int) []byte

func RootCTX

func RootCTX() context.Context

func StartServer

func StartServer(ctx context.Context, proxy *ReverseProxy)

Starts http server & defers closing of it as a default/backup

func Sum

func Sum(nums ...byte) int

func Tar

func Tar(src string, writers ...io.Writer) error

Tar takes a source and variable writers and walks 'source' writing each file found to the tar writer; the purpose for accepting multiple writers is to allow for multiple outputs (for example a file, or md5 hash)

func Version

func Version() string

func WithContext

func WithContext(parentContext context.Context) net.Dialer

Create connection paramaters default dialer is the go _struct_ of options we create to establish a new connection

Types

type Change

type Change struct {
	IsDir  bool   `diff:"IsDir"` // The type of change detected; can be one of create, update or delete
	Size   int64  `diff:"Size"`
	Mode   uint32 `diff:"Mode"`
	System interface{}
}

type ContextHandler

type ContextHandler interface {
	Key()
	Value()
}

type DirectoryGraph

type DirectoryGraph struct {
	Node *ring.Ring
	// contains filtered or unexported fields
}

func NewDirectoryGraph

func NewDirectoryGraph(root string) DirectoryGraph

* Initilization Functions for initilizing a new graph

func (*DirectoryGraph) PrintPaths

func (g *DirectoryGraph) PrintPaths()

* Printing

func (DirectoryGraph) Size

func (g DirectoryGraph) Size() int

type Edge

type Edge struct {
	Depth, Breadth int
}

Edge

Represents either the bounds of or a single point within a two-dimensional matrix/graph.
You can create new, traverse & route requests to individual containers starting from any `Edge`
Here is what `Graph(Edge{2, 4})` generates

*

                             ┌────────┐
               ┌─────────────┤e[-1,-1]├────────────────┐
               │             └────────┘                │
               │                                       │
          ┌────┴───┐                              ┌────▼───┐
          │ e[0,0] │                              │ e[1,0] │
┌─────────┼────────┼──────────┐         ┌─────────┼────────┼──────────┐
│         │        │          │         │         │        │          │

┌────▼───┬┬────▼───┬┬───▼────┬┬────▼───||────▼───┬┬────▼───┬┬───▼────┬┬────▼───┐ │ e[0,1] ││ e[0,2] ││ e[0,3] ││ e[0,4] || e[1,1] ││ e[1,2] ││ e[1,3] ││ e[1,4] │ └────────┴┴────────┴┴────────┴┴────────||────────┴┴────────┴┴────────┴┴────────┘

func (*Edge) AreValid

func (args *Edge) AreValid() bool

func (*Edge) Fmt

func (args *Edge) Fmt() string

func (*Edge) Index

func (args *Edge) Index() int

func (*Edge) Ip

func (args *Edge) Ip() string

func (*Edge) Size

func (args *Edge) Size() int

func (*Edge) Socket

func (args *Edge) Socket() string

type Environment

type Environment struct {
	Files []string
	// contains filtered or unexported fields
}

func NewEnvironment

func NewEnvironment() Environment

func (Environment) AddFile

func (e Environment) AddFile(filename string)

func (Environment) AddFiles

func (e Environment) AddFiles(files ...string) Environment

func (Environment) Compress

func (e Environment) Compress()

func (Environment) CompressedFiles

func (e Environment) CompressedFiles() []fs.FileInfo

func (Environment) Decompress

func (e Environment) Decompress()

func (Environment) DecompressedFiles

func (e Environment) DecompressedFiles() []fs.FileInfo

type EphemeralId

type EphemeralId int

type EphemeralUser

type EphemeralUser struct {
	Id  EphemeralId
	GId EphemeralId
	// contains filtered or unexported fields
}

type FileNode

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

func (FileNode) Fmt

func (node FileNode) Fmt() string

type KeyPair

type KeyPair struct {
	Pb PublicKey
	Pk PrivateKey
	// contains filtered or unexported fields
}

func GenerateKeyPair

func GenerateKeyPair(ctx context.Context) KeyPair

GenerateKeyPair Creates a random pb, pk that sit along the P224 ellipitic curve which implements P-224 (see FIPS 186-3, section D.2.2). Additonally, a fixed XOR cipher is generated from the public key

type PrivateKey

type PrivateKey []byte

type ProxyManager

type ProxyManager struct {
	Proxys []*ReverseProxy
}

type PublicKey

type PublicKey []byte

type ReverseProxy

type ReverseProxy struct {
	Cfg ReverseProxyConfig
	// contains filtered or unexported fields
}

func (*ReverseProxy) CreateMockListeningService

func (r *ReverseProxy) CreateMockListeningService()

CreateMockListeningService is called if the Service specific in ReverseProxyConfig was unreachable. It spins up a http server on the Service you intended to proxy to

func (*ReverseProxy) Launch

func (r *ReverseProxy) Launch(ctx context.Context, withMockService bool) net.Conn

Creates connection to backend resource

func (*ReverseProxy) ListenForClose

func (r *ReverseProxy) ListenForClose()

Listens on a channel for a kill sig (any byte)

type ReverseProxyConfig

type ReverseProxyConfig struct {
	Domain      string `yaml:"domain"`
	Service     string `yaml:"service"`
	CertPath    string `yaml:"cert"`
	KeyPath     string `yaml:"key"`
	LetsEncrypt bool   `yaml:"letsencrypt"`
	Term        chan byte
	Dialer      net.Dialer
}

func (ReverseProxyConfig) NewProxy

func (cfg ReverseProxyConfig) NewProxy(parentCtx context.Context) (ReverseProxy, context.Context)

type RootContext

type RootContext context.Context

type SessionPool

type SessionPool struct {
	Pool        *redis.Pool
	Root        []byte
	ApiKey      []byte
	Address     string
	RefreshRate time.Duration
}

func NewPool

func NewPool(address string, apiKey []byte, refreshRate time.Duration) SessionPool

type StartContext

type StartContext struct {
	Key       string
	StartTime time.Time
}

func (*StartContext) GetKey

func (t *StartContext) GetKey() string

func (*StartContext) GetTime

func (t *StartContext) GetTime() time.Time

type SysInfo

type SysInfo struct {
	Dev     int
	Ino     int
	Nlink   int
	Mode    int
	Uid     int
	Gid     int
	X__pad0 int
	Rdev    int
	Size    int
	Blksize int
	Blocks  int
	Atim    struct {
		Sec  int
		Nsec int
	}
	Mtim struct {
		Sec  int
		Nsec int
	}
	Ctim struct {
		Sec  int
		Nsec int
	}
	X__unused [3]int
}

type Weights

type Weights map[uint8]uint8

func GetWeights

func GetWeights() Weights

func ParseWeights

func ParseWeights(absPath string) Weights

func (Weights) Get

func (w Weights) Get(b byte) int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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