system

package
v0.0.0-...-23397e3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 9 Imported by: 0

README

System

This submodule defines how files and plugins are managed and updated.

Package Files

Package files are ZIP files containing a file info.ini that describes which actions to take. They provide updates and installation of individual files, plugins, or entire clients.

Actions may specify target files or folders. Such paths may use virtual paths that will be automatically resolved.

%plugin% = Plugin folder
%data%   = Data folder

Sample Package File

A sample package file TextViewer.zip looks like this:

│   info.ini
│
└───TextViewer
        Microsoft.Extensions.DependencyInjection.Abstractions.dll
        Peernet.Browser.Plugins.TextViewer.deps.json
        Peernet.Browser.Plugins.TextViewer.dll
        Peernet.SDK.dll

The info.ini file:

[main]
name = "Text Viewer Plugin"
organization = "Peernet s.r.o."
architecture = "windows/amd64"

[action1]
action = extract
source = TextViewer
target = "%plugin%"

Security Implications

The actions currently only allow to extract any arbitrary file to the local disk. Later, the destination directory will be limited to the Peernet installation directory.

Signatures for packages are not implemented yet. They will be added in a subsequent version.

Target OS

It is up to the client to select and download the appropriate packages.

Documentation

Index

Constants

View Source
const IniFilename = "info.ini"

Variables

This section is empty.

Functions

This section is empty.

Types

type IniAction

type IniAction struct {
	Action string `ini:"action"` // Action: extract, delete
	Source string `ini:"source"` // Folder or file in the ZIP file
	Target string `ini:"target"` // Target folder or file. Certain virtual folders such as "%plugins%" are supported.
}

type IniFile

type IniFile struct {
	Name         string      // Name of the package
	Organization string      // Organization that created this package
	Architecture string      // Target architecture. For example "windows/amd64".
	Actions      []IniAction // Actions to take
}

IniFile contains the parsed data from the info.ini file

func ParseIniFile

func ParseIniFile(data []byte) (header *IniFile, err error)

type UpdatePackage

type UpdatePackage struct {
	Filename string          // Filename of the update package
	Err      error           // Parsing error if any
	Header   *IniFile        // Header info
	Reader   *zip.ReadCloser // Access to files in the ZIP file
}

func ParseUpdateFiles

func ParseUpdateFiles(Directory string) (files []UpdatePackage, err error)

ParseUpdateFiles returns a list of parsed update packages. It will check each file in the directory if a ZIP file containing a valid info.ini file. The caller must close all returned readers.

func (*UpdatePackage) Delete

func (update *UpdatePackage) Delete() (err error)

Deletes the update package file

func (*UpdatePackage) Execute

func (update *UpdatePackage) Execute(DataFolder, PluginFolder string) (err error)

Execute the actions described in the info header

Jump to

Keyboard shortcuts

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