announce server hostname in MANIFEST, display in client
Server reads its hostname via gethostname(2) and includes it as a length-prefixed UTF-8 string at the start of the MANIFEST payload. Client displays 'Server: <hostname> — <MAC>' in a label above the upstream list. Both sides updated for the new MANIFEST format: [hostname_len:1][hostname:N][entries...] Protocol version unchanged (still 1); MANIFEST payload layout change is backward-incompatible but both sides ship together.
This commit is contained in:
@@ -12,6 +12,7 @@ sealed class SessionManager : IDisposable
|
||||
readonly ConcurrentDictionary<int, ListenerState> _listeners = new();
|
||||
|
||||
byte[]? _serverMac;
|
||||
string _serverHostname = "";
|
||||
UpstreamEntry[] _upstreams = [];
|
||||
|
||||
// Serialized OPEN: only one outstanding at a time.
|
||||
@@ -20,10 +21,11 @@ sealed class SessionManager : IDisposable
|
||||
readonly Queue<PendingOpen> _openQueue = new();
|
||||
|
||||
public event Action<string>? Log;
|
||||
public event Action<UpstreamEntry[]>? ManifestReceived;
|
||||
public event Action<string, byte[], UpstreamEntry[]>? ManifestReceived;
|
||||
|
||||
public UpstreamEntry[] Upstreams => _upstreams;
|
||||
public byte[]? ServerMac => _serverMac;
|
||||
public string ServerHostname => _serverHostname;
|
||||
public TunnelLink? Link => _link;
|
||||
|
||||
public void AttachLink(TunnelLink link)
|
||||
@@ -51,9 +53,10 @@ sealed class SessionManager : IDisposable
|
||||
{
|
||||
case Frame.Manifest manifest:
|
||||
_serverMac = srcMac;
|
||||
_serverHostname = manifest.Hostname;
|
||||
_upstreams = manifest.Entries;
|
||||
Log?.Invoke($"manifest: {manifest.Entries.Length} upstreams from {BitConverter.ToString(srcMac)}");
|
||||
ManifestReceived?.Invoke(manifest.Entries);
|
||||
Log?.Invoke($"manifest: {manifest.Entries.Length} upstreams from {manifest.Hostname} ({BitConverter.ToString(srcMac)})");
|
||||
ManifestReceived?.Invoke(manifest.Hostname, srcMac, manifest.Entries);
|
||||
break;
|
||||
|
||||
case Frame.OpenAck ack:
|
||||
|
||||
Reference in New Issue
Block a user