core

package module
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: GPL-3.0 Imports: 42 Imported by: 0

README

test

Go Reference

Documentation

Index

Constants

View Source
const (
	Version                string = "v0.1.x"
	CoreEnvironmentRoot    string = ".env"
	CoreTemporaryCacheRoot string = CoreEnvironmentRoot + "/.tmp"
	CoreLogRoot            string = CoreEnvironmentRoot + "/logs"
	CoreFsRoot             string = CoreEnvironmentRoot + "/corefs"
	CoreMockTestDataRoot   string = CoreEnvironmentRoot + "/mock/input"
	CoreFsCompressedRoot   string = CoreEnvironmentRoot + "/corefs.tax.xz"
	CoreFullChain          string = CoreEnvironmentRoot + "/etc/ssl/core.pem"
	CoreCert               string = CoreEnvironmentRoot + "/etc/ssl/core.cert"
	CoreChildCertPath      string = CoreEnvironmentRoot + "/etc/ssl/core-children"
	SESSION_CIPHER_FORMAT  string = "\n-----BEGIN KDB SESSION CIPHER-----\n%s\n-----END KDB SESSION CIPHER-----\n"
	InternalKeyDBDomain    string = "read.core.keydb:9990?reuseport=true"
	InternalKeyDBNetwork   string = "tcp"
	XSRFActionID           string = "CLAIMED"
	CoreWeightsPath        string = CoreEnvironmentRoot + "/static/byte_weights"
)
View Source
const (
	TAR_FILTER  = "*.tar.*"
	ZSTD_FILTER = "*.zst"
	LOG_FILTER  = "*.log"
	CERT_FILTER = "*.cert"
	KEY_FILTER  = "*.pem"
	JSON_FILTER = "*.json"
)
View Source
const (
	IsFile = iota
	IsDirectory
	DoesNotExist
)

Variables

This section is empty.

Functions

func CertWith added in v0.1.7

func CertWith(baseCert *x509.Certificate, domains, ips []string) *x509.Certificate

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)

* Counter Maps bytes to their frequency in the input arr & returns the map, the inverse mapping, and the maximum frequency of appearence in arr

func CreateCoreRootCA added in v0.1.7

func CreateCoreRootCA()
  • CreateSelfSignedCertificates Creates a CA Cert & Key for a given ReverseProxy & writes to disk

func DCAFrom added in v0.1.7

func DCAFrom(parentCert *x509.Certificate, parentKey *ecdsa.PrivateKey) (*x509.Certificate, *ecdsa.PrivateKey)

func DecodeBase64

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

func DecodeHex

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

func EncodeBase64

func EncodeBase64(arr []byte) 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 FormatTCPAddr added in v0.1.8

func FormatTCPAddr(ip, port string, reusePort bool) string

func GenerateLogger

func GenerateLogger(namespace string) *log.Logger

GenerateLogger namespace

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 NewSerialBuffer added in v0.1.7

func NewSerialBuffer() *big.Int

Generates a random serial buffer see rfc5280 section-4.1.2.2 https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.2

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 StartMirrorBus added in v0.1.8

func StartMirrorBus(ctx context.Context, l *log.Logger, addr, port string, numLoops int, tickspeed time.Duration) error

StartMirrorBus

func StartRedisServer added in v0.1.8

func StartRedisServer(ctx context.Context, l *log.Logger, addr, port, unixsocket string, numLoops int, tickspeed time.Duration)

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)

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 {
	RootPath string

	Node *ring.Ring
	// contains filtered or unexported fields
}

func NewDirectoryGraph

func NewDirectoryGraph(root string) DirectoryGraph

func (DirectoryGraph) InvertByExt added in v0.1.8

func (e DirectoryGraph) InvertByExt() ExtToFileNode

Inverts a directory graph creating a constant time lookup from map[FileExtension][]FileNode This includes the SysInfo last acquired from serialize() Acquires a lock on the result & e.DirectoryGraph while populating the index

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) CompressedFiles

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

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 ExtToFileNode added in v0.1.8

type ExtToFileNode map[FileExtension][]FileNode

func (ExtToFileNode) Print added in v0.1.8

func (e ExtToFileNode) Print() string

type FileExtension added in v0.1.8

type FileExtension string

type FileNode

type FileNode struct {
	Path      string
	Dir       fs.DirEntry
	TarHeader *tar.Header
	Sys       SysInfo
}

func (FileNode) Fmt

func (node FileNode) Fmt() string

type FileState added in v0.1.7

type FileState int

func CheckState added in v0.1.7

func CheckState(filepath string) FileState

type InvertedDAG added in v0.1.8

type InvertedDAG map[interface{}][]FileNode

type KeyDB added in v0.1.5

type KeyDB struct {
	Kp          KeyPair
	RefreshRate time.Duration
}

func (KeyDB) StartKeyDB added in v0.1.5

func (k KeyDB) StartKeyDB(ctx context.Context) error

StartKeyDB

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).

func (KeyPair) Cipher added in v0.1.7

func (kp KeyPair) Cipher() []byte

func (KeyPair) Flatten added in v0.1.7

func (kp KeyPair) Flatten() []byte

func (KeyPair) Sign added in v0.1.7

func (kp KeyPair) Sign(message string) ([]byte, []byte)

Signs a message and returns the signature only if the signing was succesful, otherwise empty arrs this method fails silently on purpose

type KeygenErr added in v0.1.4

type KeygenErr error

type Message added in v0.1.8

type Message struct {
	Request              string   `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"`
	Response             string   `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"`
	To                   string   `protobuf:"bytes,3,opt,name=to,proto3" json:"to,omitempty"`
	From                 string   `protobuf:"bytes,4,opt,name=from,proto3" json:"from,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

[START messages]

func (*Message) Descriptor added in v0.1.8

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetFrom added in v0.1.8

func (m *Message) GetFrom() string

func (*Message) GetRequest added in v0.1.8

func (m *Message) GetRequest() string

func (*Message) GetResponse added in v0.1.8

func (m *Message) GetResponse() string

func (*Message) GetTo added in v0.1.8

func (m *Message) GetTo() string

func (*Message) ProtoMessage added in v0.1.8

func (*Message) ProtoMessage()

func (*Message) Reset added in v0.1.8

func (m *Message) Reset()

func (*Message) String added in v0.1.8

func (m *Message) String() string

func (*Message) XXX_DiscardUnknown added in v0.1.10

func (m *Message) XXX_DiscardUnknown()

func (*Message) XXX_Marshal added in v0.1.10

func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Message) XXX_Merge added in v0.1.10

func (m *Message) XXX_Merge(src proto.Message)

func (*Message) XXX_Size added in v0.1.10

func (m *Message) XXX_Size() int

func (*Message) XXX_Unmarshal added in v0.1.10

func (m *Message) XXX_Unmarshal(b []byte) error

type NetStats added in v0.1.8

type NetStats struct {
	ByFlags     map[net.Flags][]net.Interface
	ByAddrToNet map[string]string
	ByNetToAddr map[string][]string
}

func SnapShot added in v0.1.8

func SnapShot() NetStats

func UnMarshal added in v0.1.8

func UnMarshal(marshaled []byte) NetStats

func (NetStats) Marshal added in v0.1.8

func (s NetStats) Marshal() []byte

type Pool added in v0.1.5

type Pool struct {
	Token                []*Token `protobuf:"bytes,1,rep,name=token,proto3" json:"token,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Pool) Descriptor added in v0.1.5

func (*Pool) Descriptor() ([]byte, []int)

func (*Pool) GetToken added in v0.1.5

func (m *Pool) GetToken() []*Token

func (*Pool) ProtoMessage added in v0.1.5

func (*Pool) ProtoMessage()

func (*Pool) Reset added in v0.1.5

func (m *Pool) Reset()

func (*Pool) String added in v0.1.5

func (m *Pool) String() string

func (*Pool) XXX_DiscardUnknown added in v0.1.10

func (m *Pool) XXX_DiscardUnknown()

func (*Pool) XXX_Marshal added in v0.1.10

func (m *Pool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Pool) XXX_Merge added in v0.1.10

func (m *Pool) XXX_Merge(src proto.Message)

func (*Pool) XXX_Size added in v0.1.10

func (m *Pool) XXX_Size() int

func (*Pool) XXX_Unmarshal added in v0.1.10

func (m *Pool) XXX_Unmarshal(b []byte) error

type PrivateKey

type PrivateKey []byte

type ProxyManager

type ProxyManager struct {
	Proxys []*ReverseProxy
}

type PublicKey

type PublicKey []byte

type ReverseProxy

type ReverseProxy struct {
	Cfg    ReverseProxyConfig
	Server *http.Server
	Dialer net.Dialer
}

func NewProxy added in v0.1.7

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

type ReverseProxyConfig

type ReverseProxyConfig struct {
	Domains        []string `yaml:"domain"`
	ServiceAddress string   `yaml:"service"`
}

type SignatureAlgorithm added in v0.1.7

type SignatureAlgorithm int
const (
	UnknownSignatureAlgorithm SignatureAlgorithm = iota
	MD2WithRSA
	MD5WithRSA
	SHA1WithRSA
	SHA256WithRSA
	SHA384WithRSA
	SHA512WithRSA
	DSAWithSHA1
	DSAWithSHA256
	ECDSAWithSHA1
	ECDSAWithSHA256
	ECDSAWithSHA384
	ECDSAWithSHA512
	SHA256WithRSAPSS
	SHA384WithRSAPSS
	SHA512WithRSAPSS
	PureEd25519
)

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 SysInfoToFn added in v0.1.8

type SysInfoToFn map[int][]FileNode

type Token added in v0.1.5

type Token struct {
	Name                 string               `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Id                   int32                `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"`
	Token                string               `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"`
	LastUpdated          *timestamp.Timestamp `protobuf:"bytes,4,opt,name=last_updated,json=lastUpdated,proto3" json:"last_updated,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

[START messages]

func (*Token) Descriptor added in v0.1.5

func (*Token) Descriptor() ([]byte, []int)

func (*Token) GetId added in v0.1.5

func (m *Token) GetId() int32

func (*Token) GetLastUpdated added in v0.1.5

func (m *Token) GetLastUpdated() *timestamp.Timestamp

func (*Token) GetName added in v0.1.5

func (m *Token) GetName() string

func (*Token) GetToken added in v0.1.5

func (m *Token) GetToken() string

func (*Token) ProtoMessage added in v0.1.5

func (*Token) ProtoMessage()

func (*Token) Reset added in v0.1.5

func (m *Token) Reset()

func (*Token) String added in v0.1.5

func (m *Token) String() string

func (*Token) XXX_DiscardUnknown added in v0.1.10

func (m *Token) XXX_DiscardUnknown()

func (*Token) XXX_Marshal added in v0.1.10

func (m *Token) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Token) XXX_Merge added in v0.1.10

func (m *Token) XXX_Merge(src proto.Message)

func (*Token) XXX_Size added in v0.1.10

func (m *Token) XXX_Size() int

func (*Token) XXX_Unmarshal added in v0.1.10

func (m *Token) XXX_Unmarshal(b []byte) error

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