Documentation
¶
Overview ¶
Package sharing is what Remote Work and the Sharing status item (extensions/hosting) have in common (SPEC §10.29): the state of hosting a workspace as the item shows it, the interface a hosting extension implements for it, and the addresses of this computer that another computer connects to.
Index ¶
Constants ¶
const DevInterfacesEnv = "EMETOS_DEV_INTERFACES"
DevInterfacesEnv is the environment variable that replaces the interfaces of this computer by a list in debug builds and builds with the emetos_dev tag (SPEC §15.2): the proofs and the real-input tests set it, so that the addresses on their screenshots are the documentation addresses of RFC 5737 and never those of the machine they ran on. A release build never reads it. It holds a JSON array such as
[{"name":"eth0","up":true,"defaultRoute":true,"addrs":["192.0.2.10/24"]},{"name":"docker0","up":true,"addrs":["203.0.113.9/24"]}]
where "loopback": true marks a loopback interface.
Variables ¶
This section is empty.
Functions ¶
func Addresses ¶
func Addresses(list Interfaces, port int) []string
Addresses lists the addresses another computer can connect to, each with the port ("192.168.1.5:47123"), in this order:
- the addresses of the interface the default route goes out through, IPv4 first;
- then the addresses of the other interfaces that are up, not loopback and not the bridge of a container engine or a virtual machine manager (IsBridge), IPv4 first;
- when no such address exists, every address of an interface that is up and not loopback, in the same order, so the list is never empty on a computer that has a network.
Link-local, multicast and unspecified addresses are never listed, an address once, and each group is sorted. A list that cannot be read gives none.
func Computers ¶
Computers counts the computers of a state in words: "nobody connected", "1 computer connected (laptop)", "2 computers connected (laptop, desktop)".
Types ¶
type Computer ¶
type Computer struct {
// Name is the comment of the key it logged in with (its fingerprint when the key has none).
Name string
// Disconnect ends its session. It may be called from any goroutine.
Disconnect func()
}
Computer is a computer connected to a hosted workspace.
type Host ¶
type Host interface {
// Name is how the item calls it: "Remote Work".
Name() string
// Description is the line under its Host entry in the pick of the item.
Description() string
// HostCommand and StopCommand are the ids of the commands that start and stop hosting the workspace of the window, and
// SettingsCommand the one that opens its page or tab.
HostCommand() string
StopCommand() string
SettingsCommand() string
// State reads how the workspace with the folder is hosted. A folder that is empty (a workspace with none) is never hosted.
State(folder string) State
// OnChange calls fn, from any goroutine, after the state changed; the function it returns stops the calls.
OnChange(fn func()) (stop func())
}
Host is an extension that hosts workspaces, as the Sharing item sees it. The implementation is made by the hub of Remote Work (Hub.Hosting).
type Interface ¶
type Interface struct {
// Name is its name ("eth0").
Name string
// Up says that it is up, and Loopback that it is a loopback interface.
Up, Loopback bool
// DefaultRoute says that the default route of the computer goes out through it.
DefaultRoute bool
// Addrs are its addresses, as net.Interface.Addrs gives them (*net.IPNet or *net.IPAddr).
Addrs []net.Addr
}
Interface is a network interface of this computer, reduced to what the addresses need.
func NetInterfaces ¶
NetInterfaces reads the interfaces from the operating system, and marks the ones the default route goes out through.
type Interfaces ¶
Interfaces lists the network interfaces of this computer; NetInterfaces is the real one and a test passes a fake.
func DefaultInterfaces ¶
func DefaultInterfaces() Interfaces
DefaultInterfaces is the Interfaces the real hubs use: the list of DevInterfacesEnv in a debug or emetos_dev build that sets it, else NetInterfaces.
type State ¶
type State struct {
// On says that the extension hosts the workspace.
On bool
// Port is the port the extension listens on while it listens, 0 when it does not.
Port int
// Problem says why the extension cannot host although it is on (it cannot listen); empty when all is well.
Problem string
// Computers are the computers connected to the workspace through the extension.
Computers []Computer
}
State is how one extension hosts one workspace now.