Feature: transfer a Go-managed host to the MFC master from the web console
A Go-managed host cannot receive the client upgrade that only the MFC master can push. Transfer moves its main link there and brings it back after N days; MFC has no reason to return it. Transfer is not share: ASSIGN writes the target and drops the current connection, so the old master sees the host go offline and the new master gets a normal main link it can remote control and upgrade. While a transfer is live the client refuses a second transfer and any share, so no host is handed to a third master that expiry would orphan. Server: admin-only `transfer_device` WS command, COMMAND_ASSIGN_MASTER + SHARE_TYPE_YAMA_FOREVER as `host:port:days::transport\0`, byte-compatible with the MFC dialog. The transport segment is always present (YAMA_TRANSFER_TRANSPORT, default 0/TCP) because clients keep their current link when it is missing: a WSS-managed host would otherwise retry WSS against the MFC master's raw TCP port and never connect. The empty shine segment keeps the host's header encryption. The button only renders when `device_list.transfer` is present, which MFC never sends, so no MFC change is needed. devicehistory keeps transfer_to/transfer_until for the card badge and drops the marker on expiry or on a fresh login here. Client: KernelManager.cpp writes the registry and disconnects; ClientDll.cpp re-reads the registry at the top of every reconnect, so a mid-session transfer lands on the next round. Expiry is checked before every connect attempt as well as inside the heartbeat loop, so an unreachable target cannot pin the host to an expired address until a restart; restoring rebuilds the link captured on entry (address, header encryption, transport). linux/main.cpp applies the transfer on the main loop and restores the captured endpoint at expiry; Android does the same; macOS has neither share nor transfer.
This commit is contained in:
1 parent
b466f568ab
commit
63c7cdf588
18 files changed
+1024
-177
No files matched your search
@@ -1375,6 +1375,38 @@ func main() {
|
||||
} else {
|
||||
log.Info("SSO disabled (YAMA_SSO_JWT_SECRET not set) — web login only")
|
||||
}
|
||||
// "Transfer host": the web UI hands a host over to another master (the MFC
|
||||
// server) so that master can push a client upgrade to it; the host returns
|
||||
// to this server on its own once the days run out. The target only
|
||||
// pre-fills the dialog — the operator can still type another one, and an
|
||||
// empty value keeps the feature available with an empty field.
|
||||
transferTarget := strings.TrimSpace(os.Getenv("YAMA_TRANSFER_TARGET"))
|
||||
transferDays := 1.0
|
||||
if v := strings.TrimSpace(os.Getenv("YAMA_TRANSFER_DAYS")); v != "" {
|
||||
if d, err := strconv.ParseFloat(v, 64); err == nil && d > 0 {
|
||||
transferDays = d
|
||||
} else {
|
||||
log.Info("Ignoring YAMA_TRANSFER_DAYS=%q (want a positive number)", v)
|
||||
}
|
||||
}
|
||||
// The link the transferred host uses to reach the target. It is always in
|
||||
// the command: clients keep their current link when it is missing, so a
|
||||
// WSS-managed host would try WSS against a plain-TCP master. Default TCP
|
||||
// matches what an MFC master listens on.
|
||||
transferTransport := protocol.TransferTransportTCP
|
||||
if v := strings.TrimSpace(os.Getenv("YAMA_TRANSFER_TRANSPORT")); v != "" {
|
||||
switch v {
|
||||
case "0", "5", "6":
|
||||
transferTransport, _ = strconv.Atoi(v)
|
||||
default:
|
||||
log.Info("Ignoring YAMA_TRANSFER_TRANSPORT=%q (want 0=TCP, 5=WS, 6=WSS)", v)
|
||||
}
|
||||
}
|
||||
if transferTarget != "" {
|
||||
log.Info("Host transfer dialog pre-filled with %s (%.1f days, transport=%d)",
|
||||
transferTarget, transferDays, transferTransport)
|
||||
}
|
||||
|
||||
webCfg := web.Config{
|
||||
AllowedOrigins: allowedOrigins,
|
||||
LoginIPLimit: wsauth.NewRateLimiter(10, time.Minute),
|
||||
@@ -1384,6 +1416,9 @@ func main() {
|
||||
BrandName: brandName,
|
||||
SSO: ssoDetector,
|
||||
DeviceACL: deviceACL,
|
||||
TransferTarget: transferTarget,
|
||||
TransferDays: transferDays,
|
||||
TransferTransport: transferTransport,
|
||||
}
|
||||
|
||||
// Start HTTP server for web UI. Hub gives it read-only access to the
|
||||
|
||||
Reference in new issue
Block a user