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:
@@ -7,6 +7,7 @@ public partial class MainForm : Form
|
||||
readonly SessionManager _sessions = new();
|
||||
readonly ComboBox _deviceBox = new();
|
||||
readonly Button _discoverBtn = new();
|
||||
readonly Label _serverLabel = new();
|
||||
readonly ListView _listView = new();
|
||||
readonly Label _statusLabel = new();
|
||||
TunnelLink? _link;
|
||||
@@ -23,7 +24,8 @@ public partial class MainForm : Form
|
||||
InitializeComponents();
|
||||
|
||||
_sessions.Log += msg => this.Invoke(() => _statusLabel.Text = msg);
|
||||
_sessions.ManifestReceived += entries => this.Invoke(() => PopulateList(entries));
|
||||
_sessions.ManifestReceived += (hostname, mac, entries) =>
|
||||
this.Invoke(() => PopulateList(hostname, mac, entries));
|
||||
|
||||
foreach (var d in TunnelLink.ListDevices())
|
||||
{
|
||||
@@ -54,9 +56,15 @@ public partial class MainForm : Form
|
||||
_discoverBtn.Click += OnDiscover;
|
||||
Controls.Add(_discoverBtn);
|
||||
|
||||
_listView.Left = pad; _listView.Top = _discoverBtn.Bottom + 8;
|
||||
_serverLabel.Left = pad; _serverLabel.Top = _discoverBtn.Bottom + 8;
|
||||
_serverLabel.Width = ClientSize.Width - pad * 2;
|
||||
_serverLabel.AutoEllipsis = true;
|
||||
_serverLabel.Text = "Server: not connected";
|
||||
Controls.Add(_serverLabel);
|
||||
|
||||
_listView.Left = pad; _listView.Top = _serverLabel.Bottom + 8;
|
||||
_listView.Width = ClientSize.Width - pad * 2;
|
||||
_listView.Height = 220;
|
||||
_listView.Height = 200;
|
||||
_listView.View = View.Details;
|
||||
_listView.FullRowSelect = true;
|
||||
_listView.CheckBoxes = true;
|
||||
@@ -96,11 +104,15 @@ public partial class MainForm : Form
|
||||
_sessions.AttachLink(_link);
|
||||
_link.Open();
|
||||
_sessions.Discover();
|
||||
_serverLabel.Text = "Server: discovering...";
|
||||
_statusLabel.Text = "discovering...";
|
||||
}
|
||||
|
||||
void PopulateList(UpstreamEntry[] entries)
|
||||
void PopulateList(string hostname, byte[] mac, UpstreamEntry[] entries)
|
||||
{
|
||||
var macStr = string.Join(":", mac.Select(b => b.ToString("X2")));
|
||||
_serverLabel.Text = $"Server: {hostname} — {macStr}";
|
||||
|
||||
_listView.BeginUpdate();
|
||||
_listView.Items.Clear();
|
||||
foreach (var up in entries)
|
||||
|
||||
Reference in New Issue
Block a user