index

package
v0.0.0-...-94e7ec6 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2019 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HWIDCache string = ""

Functions

func Build

func Build(tos, tarch string) error

func HWID

func HWID() string

func Tar

func Tar(src, dest string) error

func Untar

func Untar(src, dest string) error

func Unzip

func Unzip(src, dest string) error

func UserAgent

func UserAgent(userAgent string) (string, string)

func Zip

func Zip(src, dest string) error

Types

type Connection

type Connection struct {
	ID    ID
	Nodes []*Node
}

func NewConnection

func NewConnection(n []*Node) Connection

type File

type File struct {
	Path   string
	Size   int64
	Chunks []int
}

type FileSystem

type FileSystem struct {
	Files map[string]File
	// contains filtered or unexported fields
}

func NewFileSystem

func NewFileSystem(i *Index) FileSystem

func (*FileSystem) Add

func (f *FileSystem) Add(p string, c io.Reader) error

func (*FileSystem) Get

func (f *FileSystem) Get(p string, c io.Writer) error

func (*FileSystem) List

func (f *FileSystem) List() map[string]File

type ID

type ID string

func NewID

func NewID(newID string) ID

func NewIDConnection

func NewIDConnection(n []*Node) ID

func NewIDHash

func NewIDHash(newID string) ID

func NewIDRoute

func NewIDRoute(id []ID) ID

func ParseByte

func ParseByte(b []byte) ID

func ParseHWID

func ParseHWID() ID

type Index

type Index struct {
	Type        Type
	Status      Status
	Connections map[ID]*Connection
	Nodes       map[ID]*Node
	Physical    StatLoad
	// contains filtered or unexported fields
}

TODO: aggregate whole network into nodes TODO: allow for redirect indexing nodes

func (*Index) Add

func (i *Index) Add(c *Node)

func (*Index) AddCon

func (i *Index) AddCon(c *Connection)

func (*Index) Call

func (i *Index) Call(path Route, act string) (*http.Response, error)

func (*Index) Collect

func (i *Index) Collect(n *Network)

func (*Index) Download

func (i *Index) Download(p string, c io.Writer) error

func (*Index) Init

func (i *Index) Init()

func (*Index) Join

func (i *Index) Join(ip net.IP, port int)

func (*Index) JoinNode

func (i *Index) JoinNode(newNode *Node)

func (*Index) Merge

func (i *Index) Merge(n *Index) bool

func (*Index) Scan

func (i *Index) Scan()

func (*Index) Update

func (i *Index) Update()

func (*Index) Upload

func (i *Index) Upload(p string, c io.Reader) error

func (*Index) Usage

func (i *Index) Usage()

type Network

type Network struct {
	Indexs map[ID]*Index
	Paths  map[ID]map[ID]map[int][]*Route
}

func (*Network) Add

func (n *Network) Add(i *Index, id ID)

func (*Network) AddIndex

func (n *Network) AddIndex(i *Index, id ID, hit map[ID]bool)

func (*Network) AddRoute

func (n *Network) AddRoute(i ID, r *Route)

func (*Network) Has

func (n *Network) Has(id ID) bool

func (*Network) Merge

func (n *Network) Merge(a *Network) bool

func (*Network) Path

func (n *Network) Path(s, t ID) (error, map[int][]*Route)

type Node

type Node struct {
	IP   net.IP
	ID   ID
	Type Type
	Port int
}

TODO: alive check

func ThisNode

func ThisNode(i *Index, face net.IP) Node

type Route

type Route struct {
	Nodes []ID
	ID    ID
}

func ExtendRoute

func ExtendRoute(s ID, r *Route) Route

func NewRoute

func NewRoute(n []ID) Route

func (*Route) Equal

func (r *Route) Equal(t *Route) bool

func (*Route) Has

func (r *Route) Has(id ID) bool

func (*Route) Len

func (r *Route) Len() int

func (*Route) Next

func (r *Route) Next() Route

func (*Route) String

func (r *Route) String() string

type Scan

type Scan struct {
	Running bool
	// contains filtered or unexported fields
}

func NewScan

func NewScan(p *Index) Scan

func (*Scan) Scan

func (i *Scan) Scan()

type Stat

type Stat struct {
	Cores   int
	Memory  uint64
	Storage uint64
	Usage   StatUsage
}

func GetStat

func GetStat() (Stat, error)

func (*Stat) GetUsage

func (s *Stat) GetUsage() (StatUsage, error)

type StatLoad

type StatLoad struct {
	Short StatUsage
	Mid   StatUsage
	Long  StatUsage
	// contains filtered or unexported fields
}

func GetLoad

func GetLoad() StatLoad

type StatUsage

type StatUsage struct {
	Cores   float64
	Memory  float64
	Storage float64
	Time    time.Time
}

type Status

type Status int
const (
	Idle     Status = -1
	Scanning Status = 1
	Indexing Status = 2
	Indexed  Status = 3
)

func (Status) String

func (s Status) String() string

type Type

type Type int
const (
	Unknown  Type = -1
	Local    Type = 0
	Redirect Type = 1
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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