migration

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: AGPL-3.0 Imports: 27 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 migration reads third-party session exports without modifying them.

Index

Constants

View Source
const MaxBytes int64 = 32 << 20
View Source
const MaxEntries = 10000
View Source
const MaxFiles = 1024
View Source
const MaxIssues = 10000

Variables

View Source
var (
	ErrFormat    = errors.New("unsupported or malformed migration format")
	ErrTooLarge  = errors.New("migration input exceeds limit")
	ErrNoEntries = errors.New("no SSH entries found")
	ErrRead      = errors.New("cannot read migration input")
	ErrEncrypted = errors.New("encrypted migration input is not supported")
	// ErrNoSessions is an ErrFormat for a file without the sections a
	// source keeps its sessions in.
	ErrNoSessions = fmt.Errorf("%w: no session section", ErrFormat)
)

Functions

This section is empty.

Types

type Encoding added in v1.1.2

type Encoding string

Encoding is a legacy code page an export that is neither UTF-8 nor UTF-16 with a byte order mark may be in: Windows clients write their INI files in the system's ANSI code page.

const (
	GB18030     Encoding = "GB18030"
	Big5        Encoding = "Big5"
	ShiftJIS    Encoding = "Shift_JIS"
	EUCKR       Encoding = "EUC-KR"
	Windows1252 Encoding = "Windows-1252"
)

func Encodings added in v1.1.2

func Encodings() []Encoding

Encodings are the legacy code pages, in the order detection tries them after the preferred ones; Windows-1252 decodes nearly any bytes, so it comes last.

func LanguageEncoding added in v1.1.2

func LanguageEncoding(locale string) Encoding

LanguageEncoding is the code page Windows writes legacy files in for a user of the language (a BCP 47 tag such as zh-Hans or ja).

type Entry

type Entry struct {
	ID, Name, Address, User, Group   string
	Port                             int
	Password, PrivateKey, Passphrase []byte `json:"-" yaml:"-"`
	KeyPath                          string
	Jumps                            []Hop
	Issues                           []Issue
}

Secrets are transient bytes and must never be serialized to application metadata.

type FormatError added in v1.1.2

type FormatError struct {
	File string
	Line int
}

FormatError is an ErrFormat at a line of a file: File is its base name, empty when the input was not a file.

func (*FormatError) Error added in v1.1.2

func (e *FormatError) Error() string

func (*FormatError) Unwrap added in v1.1.2

func (e *FormatError) Unwrap() error

type Hop

type Hop struct {
	Ref, Name, Address, User string
	Port                     int
}

type Issue

type Issue struct {
	Code, Name, Field string
	Line              int
}

Issue is a diagnostic; Line is the source line it is about, 0 when none.

type Options added in v1.1.2

type Options struct {
	// Encoding is the code page such files are in; empty detects it.
	Encoding Encoding
	// Prefer is tried first when detecting, after the system's code page.
	Prefer Encoding
}

Options says how Read decodes an export of an INI-style source that is neither UTF-8 nor UTF-16 with a byte order mark.

type Result

type Result struct {
	Entries []Entry
	Issues  []Issue
	// Encoding is the legacy code page files were decoded in, empty when
	// every file was UTF-8 or UTF-16.
	Encoding Encoding
}

func ParseText added in v0.0.10

func ParseText(text string) (Result, error)

ParseText reads a host list typed or pasted for a text import, within the bounds Read keeps.

func Read

func Read(source Source, paths []string, o Options) (Result, error)

Read accepts selected files or directories; symbolic links are never followed. o says how an INI-style source's legacy files are decoded.

type Source

type Source string
const (
	Xshell    Source = "Xshell"
	MobaXterm Source = "MobaXterm"
	PuTTY     Source = "PuTTY"
	WindTerm  Source = "WindTerm"
	Electerm  Source = "Electerm"
	Tabby     Source = "Tabby"
	Netcatty  Source = "Netcatty"
	Remmina   Source = "Remmina"
	MRemoteNG Source = "mRemoteNG"
	WinSCP    Source = "WinSCP"
	// Text is a host list of key=value lines, typed, pasted or read
	// from a file; it is not one of the clients Sources lists.
	Text Source = "Text"
	// CSV is a host table whose header names the columns with the keys
	// of a Text host list; it is not one of the clients Sources lists.
	CSV Source = "CSV"
)

func Sources

func Sources() []Source

Jump to

Keyboard shortcuts

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