Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ All notable changes to this project are documented here, following
## [Unreleased]

### Added
- **Peer Aliases and Ergonomic Control Resolution (`bin/yipd`, #197).**
- Added optional `alias: Option<String>` to `PeerConfig`, configuration file parser (`alias = "..."` within `[peer]` blocks), `ControlCmd::AddPeer` RPC, and `PeerStats`.
- Added case-insensitive peer resolution by human-readable alias in `PeerManager` (`find_peer_by_alias`, `peer_pubkey`, and fallback in `find_peer_index_by_id`), allowing CLI commands (`peer remove`, `peer set-transport`, `ping`, `trace`, `crypto`) to accept friendly peer aliases as drop-in alternatives to full 64-hex public keys or IPv6 node addresses.
- Updated `yipctl peers` and `yipctl top` dashboard displays to render peer aliases alongside node overlay addresses when configured.
- **Network Invitation Tickets and Terminal QR Code Rendering (`bin/yipd`, #198).**
- Implemented `NetworkTicket` schema in `bin/yipd/src/ticket.rs` compatible with cross-platform desktop/mobile clients (`yip-client`), supporting Base64 serialization, JSON payloads, and `yip://join?ticket={b64}` invitation URIs.
- Added compact terminal Unicode QR code generation using `qrcode` crate with `Dense1x2` half-block glyph rendering.
- Added `ControlCmd::CreateTicket` RPC command and responses (`ControlResponse::Ticket`) over the UNIX domain control socket `/run/yipd/yip.sock`.
- Added CLI subcommands `yip ticket create [--name <NAME>] [--route-mode <MODE>] [--endpoint <ADDR>] [--no-qr] [--json]` and `yip ticket show <TICKET_OR_URI> [--no-qr] [--json]`.
- **Control Socket Status RPC Metadata Exposure (`bin/yipd`, #194).**
- Exposed local node public key (`public_key`), active UDP listen port (`listen_port`), and mesh network ID (`network_id`) in `ControlResponse::Status`.
- Added CLI status printout formatting and JSON serialization for node public keys, listen ports, and network IDs, enabling unprivileged desktop clients and orchestration tools to query local node identity without reading secret configuration files.
Expand Down
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions bin/yipd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
yip-ca = { workspace = true }
ed25519-dalek = { version = "3" }
qrcode = { version = "0.14", default-features = false }
base64 = "0.22"

[dev-dependencies]
ed25519-dalek = { version = "3", default-features = false }
Expand Down
76 changes: 72 additions & 4 deletions bin/yipd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,28 @@ pub struct PeerConfig {
/// only by public key (reachable only via rendezvous/relay once Task 6
/// wires that path in).
pub endpoint: Option<SocketAddr>,
/// Optional human-readable nickname or alias for this peer.
pub alias: Option<String>,
}

impl PeerConfig {
/// Create a peer configuration without an alias.
pub fn new(public_key: [u8; 32], endpoint: Option<SocketAddr>) -> Self {
Self {
public_key,
endpoint,
alias: None,
}
}

/// Attach a human-readable alias to this peer configuration.
pub fn with_alias(mut self, alias: impl Into<String>) -> Self {
let a = alias.into().trim().to_string();
if !a.is_empty() {
self.alias = Some(a);
}
self
}
}

/// Configuration for packet length quantization (DAITA) and cover traffic defenses.
Expand Down Expand Up @@ -503,6 +525,7 @@ fn missing(key: &str) -> io::Error {
fn flush_peer_block(
cur_pk: Option<[u8; 32]>,
cur_ep: Option<SocketAddr>,
cur_alias: Option<String>,
peers: &mut Vec<PeerConfig>,
) -> io::Result<()> {
match cur_pk {
Expand All @@ -512,11 +535,12 @@ fn flush_peer_block(
Some(pk) => peers.push(PeerConfig {
public_key: pk,
endpoint: cur_ep,
alias: cur_alias,
}),
None if cur_ep.is_some() => {
None if cur_ep.is_some() || cur_alias.is_some() => {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
"peer block has an endpoint but no public_key".to_string(),
"peer block has an endpoint or alias but no public_key".to_string(),
));
}
None => {}
Expand All @@ -539,6 +563,7 @@ impl Config {
let mut peers: Vec<PeerConfig> = Vec::new();
let mut cur_pk: Option<[u8; 32]> = None;
let mut cur_ep: Option<SocketAddr> = None;
let mut cur_alias: Option<String> = None;
let mut legacy_peer_public: Option<[u8; 32]> = None;
let mut legacy_peer_endpoint: Option<SocketAddr> = None;
let mut listen: Option<SocketAddr> = None;
Expand Down Expand Up @@ -577,9 +602,10 @@ impl Config {

// Check for [peer] block header
if line == "[peer]" {
flush_peer_block(cur_pk, cur_ep, &mut peers)?;
flush_peer_block(cur_pk, cur_ep, cur_alias, &mut peers)?;
cur_pk = None;
cur_ep = None;
cur_alias = None;
continue;
}

Expand All @@ -595,6 +621,12 @@ impl Config {
"local_private" => local_private = Some(hex_to_32(val)?),
"local_public" => local_public = Some(hex_to_32(val)?),
"public_key" => cur_pk = Some(hex_to_32(val)?),
"alias" => {
let clean = val.trim_matches('"').trim();
if !clean.is_empty() {
cur_alias = Some(clean.to_string());
}
}
"endpoint" => {
cur_ep =
Some(val.parse::<SocketAddr>().map_err(|e| {
Expand Down Expand Up @@ -823,14 +855,15 @@ impl Config {
}

// Flush any trailing peer block
flush_peer_block(cur_pk, cur_ep, &mut peers)?;
flush_peer_block(cur_pk, cur_ep, cur_alias, &mut peers)?;

// If no [peer] blocks, try legacy single-peer format
if peers.is_empty() {
if let (Some(pk), Some(ep)) = (legacy_peer_public, legacy_peer_endpoint) {
peers.push(PeerConfig {
public_key: pk,
endpoint: Some(ep),
alias: None,
});
}
}
Expand Down Expand Up @@ -1361,6 +1394,41 @@ peer_public=0000000000000000000000000000000000000000000000000000000000000003
assert_eq!(cfg.peers[1].public_key[31], 0xb2);
}

#[test]
fn parses_peers_with_optional_aliases() {
let text = "local_private=00000000000000000000000000000000000000000000000000000000000000ff\n\
local_public=000000000000000000000000000000000000000000000000000000000000aa01\n\
listen=0.0.0.0:443\ndevice=yip0\n\
[peer]\npublic_key=00000000000000000000000000000000000000000000000000000000000000b1\nendpoint=10.0.0.2:443\nalias=home-gateway\n\
[peer]\npublic_key=00000000000000000000000000000000000000000000000000000000000000b2\nalias=\"alice-laptop\"\n\
[peer]\npublic_key=00000000000000000000000000000000000000000000000000000000000000b3\n";
let cfg = Config::parse(text).expect("parses");
assert_eq!(cfg.peers.len(), 3);
assert_eq!(cfg.peers[0].alias.as_deref(), Some("home-gateway"));
assert_eq!(cfg.peers[1].alias.as_deref(), Some("alice-laptop"));
assert_eq!(cfg.peers[2].alias, None);
}

#[test]
fn test_peer_config_constructors_and_alias() {
let p = PeerConfig::new([1u8; 32], None);
assert_eq!(p.alias, None);
let p2 = p.with_alias(" ");
assert_eq!(p2.alias, None);
let p3 = PeerConfig::new([1u8; 32], None).with_alias("gateway");
assert_eq!(p3.alias.as_deref(), Some("gateway"));
}

#[test]
fn test_peer_block_with_alias_no_public_key_is_error() {
let text =
"local_private=00000000000000000000000000000000000000000000000000000000000000ff\n\
local_public=000000000000000000000000000000000000000000000000000000000000aa01\n\
listen=0.0.0.0:443\ndevice=yip0\n\
[peer]\nalias=no-pubkey-peer\n";
assert!(Config::parse(text).is_err());
}

#[test]
fn legacy_single_peer_becomes_one_entry() {
let text = "device=yip0\nlisten=0.0.0.0:443\npeer_endpoint=10.0.0.2:443\n\
Expand Down
Loading
Loading