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:
yuanyuanxiang committed 2026-11-20 12:23:08 +01:00
1 parent b466f568ab
commit 63c7cdf588
18 files changed
+1024 -177

No files matched your search

+22 -1
View File
@@ -40,6 +40,9 @@ type Server struct {
trustForwardedFor bool // honor X-Forwarded-For (behind trusted proxy only)
basePath string // web UI mount prefix (e.g. "/remoter"); "" = domain root
brandName string // white-label title; "" = "SimpleRemoter" (official branding)
transferTarget string // pre-filled "transfer host" target, "host:port"
transferDays float64 // pre-filled "transfer host" days
transferTransport int // link to the target: protocol.TransferTransport*
sso SSODetector // nil = SSO disabled
mcp mcpEndpoint // nil = no /mcp route
sweepDone chan struct{} // closes to stop the login-limiter sweeper
@@ -93,6 +96,20 @@ type Config struct {
// behaviour: every authenticated session sees every device). The shipped
// server always wires one; tests may omit it.
DeviceACL *DeviceACL
// TransferTarget ("host:port") and TransferDays pre-fill the web UI's
// "transfer host" dialog. Reporting them is also what tells the shared
// page that this backend implements COMMAND_ASSIGN_MASTER — the MFC server
// serves the same page but never reports it, so no transfer button appears
// where the command would be dropped. Empty target = the operator types
// the address; days <= 0 falls back to 1.
//
// TransferTransport is the link the transferred host must use to reach the
// target (protocol.TransferTransportTCP/WS/WSS; zero value = TCP, what an
// MFC master listens on). It is always sent to the client: leaving it out
// would make a host that currently talks WSS keep WSS against the target.
TransferTarget string
TransferDays float64
TransferTransport int
}
// New creates an HTTP server bound to the given port. port=0 disables the server.
@@ -121,6 +138,9 @@ func (s *Server) WithConfig(cfg Config) *Server {
s.brandName = resolveBrandName(cfg.BrandName, s.basePath)
s.sso = cfg.SSO
s.deviceACL = cfg.DeviceACL
s.transferTarget = cfg.TransferTarget
s.transferDays = cfg.TransferDays
s.transferTransport = cfg.TransferTransport
return s
}
@@ -145,7 +165,8 @@ func (s *Server) Start() error {
withOriginAllowlist(s.allowedOrigins).
withLoginRateLimiters(s.loginIPLimit, s.loginUserLimit).
withTrustForwardedFor(s.trustForwardedFor).
withDeviceACL(s.deviceACL)
withDeviceACL(s.deviceACL).
withTransferDefaults(s.transferTarget, s.transferDays, s.transferTransport)
mux := http.NewServeMux()
mux.HandleFunc("/", s.handleIndex)