feat: 完成 M2 mosh(LAN + tsnet 端到端验证)

- mosh(blinksh/ios C++)+protobuf-lite 交叉编译为 MoshCore.xcframework
  (CommonCrypto 后端、含 arm64 模拟器 slice;绕 autotools 用 CMake 直编 + 手写 config.h)
- tsnet 桥新增 UDP relay(StartMoshRelay:loopback↔tsnet.Dial 逐包搬运)
- MoshSession(pipe↔FILE*/pthread/SIGWINCH)+ MoshConnectScanner(TXCore,+4 单测=39)
- SSHTerminalModel 编排:SSH 引导 mosh-server→解析 MOSH CONNECT→relay→mosh 接管
- LAN 直连 + mosh-over-tsnet 均端到端验证通过,R1(tsnet UDP 数据报语义) 证伪

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
kid
2026-07-24 16:14:40 +08:00
parent aa92d0e676
commit 32520f09e0
1232 changed files with 728138 additions and 37 deletions

9
vendor/mosh/man/Makefile.am vendored Normal file
View File

@@ -0,0 +1,9 @@
dist_man_MANS =
if BUILD_CLIENT
dist_man_MANS += mosh.1 mosh-client.1
endif
if BUILD_SERVER
dist_man_MANS += mosh-server.1
endif

96
vendor/mosh/man/mosh-client.1 vendored Normal file
View File

@@ -0,0 +1,96 @@
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH MOSH 1 "February 2012"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
mosh-client \- client-side helper for mosh
.SH SYNOPSIS
MOSH_KEY=KEY
.B mosh-client
IP PORT
.br
.B mosh-client
\-c
.br
.SH DESCRIPTION
\fBmosh-client\fP is a helper program for the
.BR mosh (1)
remote terminal application.
\fBmosh\fP itself is a setup script that establishes an SSH
connection, runs the server-side helper \fBmosh-server\fP,
and collects the server's port number and session key.
\fBmosh\fP then executes \fBmosh-client\fP with the server's IP
address, port, and session key. \fBmosh-client\fP runs for
the lifetime of the connection.
The 22-byte base64 session key given by \fBmosh-server\fP is supplied
in the MOSH_KEY environment variable. This represents a 128-bit AES
key that protects the integrity and confidentiality of the session.
For constructing new setup wrappers for remote execution facilities
other than SSH, it may be necessary to invoke \fBmosh-client\fP
directly.
With the \-c option, \fBmosh-client\fP instead prints the number of colors
of the terminal given by the TERM environment variable.
.SH ENVIRONMENT VARIABLES
.TP
.B MOSH_KEY
This variable must be set, and must contain a Base64-encoded cryptographic key from
.BR mosh-server (1).
.TP
.B MOSH_ESCAPE_KEY
See
.BR mosh (1).
.TP
.B MOSH_PREDICTION_DISPLAY
Controls local echo as described in
.BR mosh (1).
.TP
.B MOSH_TITLE_NOPREFIX
See
.BR mosh (1).
.SH SEE ALSO
.BR mosh (1),
.BR mosh-server (1).
Project home page:
.I http://mosh.mit.edu
.br
.SH AUTHOR
mosh was written by Keith Winstein <mosh-devel@mit.edu>.
.SH BUGS
Please report bugs to \fImosh-devel@mit.edu\fP. Users may also subscribe
to the
.nh
.I mosh-users@mit.edu
.hy
mailing list, at
.br
.nh
.I http://mailman.mit.edu/mailman/listinfo/mosh-users
.hy
.

156
vendor/mosh/man/mosh-server.1 vendored Normal file
View File

@@ -0,0 +1,156 @@
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH MOSH 1 "October 2012"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
mosh-server \- server-side helper for mosh
.SH SYNOPSIS
.B mosh-server
new
[\-s]
[\-v]
[\-i \fIIP\fP]
[\-p \fIPORT\fP[:\fIPORT2\fP]]
[\-c \fICOLORS\fP]
[\-\- command...]
.br
.SH DESCRIPTION
\fBmosh-server\fP is a helper program for the
.BR mosh(1)
remote terminal application.
\fBmosh-server\fP binds to a high UDP port and chooses an encryption
key to protect the session. It prints both on standard output,
detaches from the terminal, and waits for the \fBmosh-client\fP to
establish a connection. It will exit if no client has contacted
it within 60 seconds.
By default, \fBmosh-server\fP binds to a port between 60000 and
61000 and executes the user's login shell.
On platforms with \fButempter\fP, \fBmosh-server\fP maintains an entry
in the
.BR utmp(5)
file to indicate its process ID, whether the session is connected,
and the client's current IP address.
\fBmosh-server\fP exits when the client terminates the connection.
.SH OPTIONS
The argument "new" must be first on the command line to use
command-line options.
.TP
.B \-s
bind to the local interface used for an incoming SSH connection, given
in the \fBSSH_CONNECTION\fP environment variable (for multihomed
hosts)
.TP
.B \-v
Print some debugging information even after detaching.
.TP
.B \-i \fIIP\fP
IP address of the local interface to bind (for multihomed hosts)
.TP
.B \-p \fIPORT\fP[:\fIPORT2\fP]
UDP port number or port-range to bind
.TP
.B \-c \fICOLORS\fP
Number of colors to advertise to applications through TERM (e.g. 8, 256)
.TP
.B \-l \fINAME=VALUE\fP
Locale-related environment variable to try as part of a fallback
environment, if the startup environment does not specify a character
set of UTF-8.
.SH ENVIRONMENT VARIABLES
These variables allow server-side configuration of Mosh's behavior.
They may be set by administrators in system login/rc files,
/etc/login.conf, or similar mechanisms, or users in their shell's
login/rc files. \fBmosh-server\fP passes these variables to the login
session and shell that it starts, but changing them there will have no
effect.
.TP
.B MOSH_SERVER_NETWORK_TMOUT
If this variable is set to a positive integer number, it specifies how
long (in seconds) \fBmosh-server\fP will wait to receive an update from the
client before exiting. Since \fPmosh\fP is very useful for mobile
clients with intermittent operation and connectivity, we suggest
setting this variable to a high value, such as 604800 (one week) or
2592000 (30 days). Otherwise, \fBmosh-server\fP will wait
indefinitely for a client to reappear. This variable is somewhat
similar to the \fBTMOUT\fP variable found in many Bourne shells.
However, it is not a login-session inactivity timeout; it only applies
to network connectivity.
.TP
.B MOSH_SERVER_SIGNAL_TMOUT
If this variable is set to a positive integer number, it specifies how
long (in seconds) \fBmosh-server\fP will ignore SIGUSR1 while waiting
to receive an update from the client. Otherwise, \fBSIGUSR1\fP will
always terminate \fBmosh-server\fP. Users and administrators may
implement scripts to clean up disconnected Mosh sessions. With this
variable set, a user or administrator can issue
.nf
$ pkill -SIGUSR1 mosh-server
.fi
to kill disconnected sessions without killing connected login
sessions.
.SH EXAMPLE
.nf
$ mosh-server
MOSH CONNECT 60001 UAkFedSsVJs2LfMeKyQB5g
mosh-server (mosh 1.1)
[...] (copyright notice omitted)
[mosh-server detached, pid = 20443]
.fi
.SH SEE ALSO
.BR mosh (1),
.BR mosh-client (1).
Project home page:
.I http://mosh.mit.edu
.br
.SH AUTHOR
mosh was written by Keith Winstein <mosh-devel@mit.edu>.
.SH BUGS
Please report bugs to \fImosh-devel@mit.edu\fP. Users may also subscribe
to the
.nh
.I mosh-users@mit.edu
.hy
mailing list, at
.br
.nh
.I http://mailman.mit.edu/mailman/listinfo/mosh-users
.hy
.

254
vendor/mosh/man/mosh.1 vendored Normal file
View File

@@ -0,0 +1,254 @@
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH MOSH 1 "April 2013"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
mosh \- mobile shell with roaming and intelligent local echo
.SH SYNOPSIS
.B mosh
.RI [ options ]
[--]
[user@]host
[command...]
.br
.SH DESCRIPTION
\fBmosh\fP (mobile shell) is a remote terminal application that
supports intermittent connectivity, allows roaming, and provides
speculative local echo and line editing of user keystrokes.
Compared with \fBssh\fP, \fBmosh\fP is more robust \(em its
connections stay up across sleeps and changes in the client's IP
address \(em and more responsive, because the protocol is tolerant of
packet loss and the client can echo most keystrokes immediately,
without waiting for a network round-trip.
\fBmosh\fP uses \fBssh\fP to establish a connection to the remote host
and authenticate with existing means (e.g., public-key authentication
or a password). \fBmosh\fP executes the unprivileged \fBmosh-server\fP
helper program on the server, then closes the SSH connection and
starts the \fBmosh-client\fP, which establishes a long-lived datagram
connection over UDP.
To improve responsiveness, \fBmosh\fP runs a predictive model of the
server's behavior in the background, trying to guess the effect of
each keystroke on the screen. It makes predictions for normal typing,
backspace, and the left- and right-arrow keys. When it is confident,
\fBmosh\fP displays the predictions without waiting for the
server. The predictive model must prove itself anew on each row of the
terminal and after each control character, so \fBmosh\fP avoids
echoing passwords or non-echoing editor commands.
By default, \fBmosh\fP shows its predictions only on high-latency
connections and to smooth out network glitches. (On longer-latency
links, the predicted cells are underlined until confirmed by the
server.) Occasional echo mistakes are corrected within a network
round-trip and do not cause lasting effect.
\fBmosh\fP does not support X forwarding or the non-interactive uses
of SSH, including port forwarding or sshfs. \fBmosh\fP works through
typical client-side network address translators but requires UDP to
pass between client and server. By default, \fBmosh\fP uses the ports
between 60000 and 61000, but allows the user to request a particular
UDP port instead.
\fBmosh\fP will do its best to arrange a UTF-8 character set locale on
the client and server. The client must have locale-related environment
variables that specify UTF-8. \fBmosh\fP will pass these client
variables to the \fBmosh-server\fP on its command line, but in most
cases they will not need to be used. \fBmosh-server\fP first attempts
to use its own locale-related environment variables, which come from
the system default configuration (sometimes /etc/default/locale) or
from having been passed over the SSH connection. But if these
variables don't call for the use of UTF-8, \fBmosh-server\fP will
apply the locale-related environment variables from the client and try
again.
.SH OPTIONS
.TP
.B \fIcommand\fP
Command to run on remote host. By default, \fBmosh\fP executes a login shell.
.TP
.B \-\-client=\fIPATH\fP
path to client helper on local machine (default: "mosh-client")
.TP
.B \-\-server=\fICOMMAND\fP
command to run server helper on remote machine (default: "mosh-server")
The server helper is unprivileged and can be installed in the user's
home directory.
This option can be used to set environment variables for the server by
using the
.BR env (1)
command to wrap the actual server command. See
.BR mosh-server (1)
for available environment variables.
.TP
.B \-\-ssh=\fICOMMAND\fP
OpenSSH command to remotely execute mosh-server on remote machine (default: "ssh")
An alternate ssh port can be specified with, \fIe.g.\fP, \-\-ssh="ssh \-p 2222".
.TP
.B \-\-predict=\fIWHEN\fP
Controls use of speculative local echo. WHEN defaults to `adaptive'
(show predictions on slower links and to smooth out network glitches)
and can also be `always` or `never'.
The MOSH_PREDICTION_DISPLAY environment variable controls this setting
permanently and can adopt the same three values.
Even on `always', \fBmosh\fP will only show predictions when it is
confident. This generally means a previous prediction on the same row
of the terminal has been confirmed by the server, without any
intervening control character keystrokes.
.TP
.B \-a
Synonym for \-\-predict=always
.TP
.B \-n
Synonym for \-\-predict=never
.TP
.B --family=\fIFAMILY\fP
Force the use of a particular address family, which defaults to `inet'
(IPv4), and can also be `inet6' (IPv6; requires IO::Socket::IP or
IO::Socket::INET6).
.TP
.B -4
Synonym for \-\-family=inet
.TP
.B -6
Synonym for \-\-family=inet6
.TP
.B \-p \fIPORT\fP[:\fIPORT2\fP], \-\-port=\fIPORT\fP[:\fIPORT2\fP]
Use a particular server-side UDP port or port range,
for example, if this is the
only port that is forwarded through a firewall to the
server. Otherwise, \fBmosh\fP will choose a port between 60000 and
61000.
.TP
.B \-\-bind\-server={ssh|any|\fIIP\fP}
Control the IP address that the \fBmosh-server\fP binds to.
The default is `ssh', in which case the server will reply from the IP
address that the SSH connection came from (as found in the
\fBSSH_CONNECTION\fP environment variable). This is useful for
multihomed servers.
With \-\-bind\-server=any, the server will reply on the default interface
and will not bind to a particular IP address. This can be useful if
the connection is made through \fBsslh\fP or another tool that makes
the SSH connection appear to come from localhost.
With \-\-bind\-server=\fIIP\fP, the server will attempt to bind to the
specified IP address.
.TP
.B \-\-no\-init
Do not send the \fBsmcup\fP initialization string and \fBrmcup\fP
deinitialization string to the client's terminal. On many terminals
this disables alternate screen mode.
.TP
.B \-\-local
Invoke \fBmosh-server\fP locally, without using \fBssh\fP. This
option requires the \fBhost\fP argument to be a local, numeric
IPv4/IPv6 address. This option is useful for testing.
.SH ESCAPE SEQUENCES
The default escape character used by Mosh is ASCII RS (decimal 30).
This is typically typed as \fBCtrl-^\fP or \fBCtrl-Shift-6\fP, on US
English keyboards. Users of non-English keyboards may find it
difficult or impossible to type the default escape character, and may
need to change the escape character. See the description of
MOSH_ESCAPE_KEY, below. In this description, the configured escape
character is represented as \fBEsc\fP.
There are two slightly different modes for escape sequences, depending
whether the escape character is printable or not.
If the escape character is a printable character, it must be prefixed
with a newline, similar to \fBOpenSSH\fP. To send the escape character
itself, type it twice. If the escape character is set to \fB~\fP,
\fBmosh\fP will behave much like \fBOpenSSH\fP.
If the escape character is a non-printable control character, no
prefix is used and the escape character is recognized at any time. To
send the escape character itself, type the escape character, then its
corresponding ASCII character (for \fBCtrl-^\fP you would type \fB^\fP,
for \fBCtrl-B\fP you would type \fBB\fP).
The escape sequence to shut down the connection is
\fBEsc .\fP. The sequence \fBEsc Ctrl-Z\fP suspends the client.
Any other sequence passes both characters through to the server.
.SH ENVIRONMENT VARIABLES
These variables are not actually interpreted by
.BR mosh (1)
itself, but are passed through to
.BR mosh-server (1).
They are described here for ease of use.
.TP
.B MOSH_ESCAPE_KEY
When set, this configures the escape character used for local
commands. The escape character may be set to any ASCII character in
the range 1-127. The variable must be set with a single literal ASCII
character. Control characters are set with the actual ASCII
control character, not with a printable representation such as "^B".
.TP
.B MOSH_PREDICTION_DISPLAY
Controls local echo as described above. The command-line flag
overrides this variable.
.TP
.B MOSH_TITLE_NOPREFIX
When set, inhibits prepending "[mosh]" to window title.
.SH SEE ALSO
.BR mosh-client (1),
.BR mosh-server (1).
Project home page:
.I http://mosh.mit.edu
.br
.SH AUTHOR
mosh was written by Keith Winstein <mosh-devel@mit.edu>.
.SH BUGS
Please report bugs to \fImosh-devel@mit.edu\fP. Users may also subscribe
to the
.nh
.I mosh-users@mit.edu
.hy
mailing list, at
.br
.nh
.I http://mailman.mit.edu/mailman/listinfo/mosh-users
.hy
.