upload

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package upload sends a file to the place a CSMS names in GetDiagnostics.

Index

Constants

This section is empty.

Variables

View Source
var Schemes = []string{"http", "https", "ftp", "ftps", "sftp"}

Schemes lists the kinds of location Send can upload to.

Functions

func Redact

func Redact(location string) string

Redact returns a location without the password it may carry, for logs.

func Send

func Send(ctx context.Context, policy Policy, location, name string, data []byte) error

Send uploads data as a file called name to the directory at location: with PUT for http and https, with STOR for ftp and ftps, and over SSH for sftp. A user name and a password in the location are used to log in. The policy says which machines may be connected to; an upload it stops fails with a *RefusedError.

Types

type Policy added in v0.1.4

type Policy struct {
	// CSMS is the address the charger reaches its CSMS at. The zero value
	// means it is not known, and then only allowed hosts can be reached.
	CSMS netip.Addr
	// Allow lists further hosts, by name or by address, as they are
	// written in a location.
	Allow []string
	// InsecureSkipVerify turns off the check of the certificate an https
	// or ftps server shows, for servers with a self-signed one.
	InsecureSkipVerify bool
	// Notice, if set, is told what is worth a line in the charger's log
	// about an upload that goes ahead.
	Notice func(text string)
}

Policy says where a charger may upload to. The CSMS chooses the location of an upload, so without a limit a hostile or compromised CSMS could make the machine plugyard runs on connect to any address that machine can reach, such as the internal services of a network.

A charger may always upload to the machine its CSMS is on, which gives the CSMS no reach it did not have. Any other host has to be allowed.

type RefusedError added in v0.1.4

type RefusedError struct {
	// Host is the host as the location names it, and Addr the address it
	// stands for.
	Host string
	Addr netip.Addr
	// Never is set for an address no setting can allow.
	Never bool
}

RefusedError says an upload was not made because of where it would go.

func (*RefusedError) Error added in v0.1.4

func (e *RefusedError) Error() string

Jump to

Keyboard shortcuts

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