1 unstable release

0.1.0 Jul 6, 2024

#1204 in Network programming

MIT/Apache

28KB
526 lines

SSDP

This is an implementation of the RFC draft from SSDP. However, it should be mostly compatible with the newer UPnP

Feel free to contribute at any point.

Planned features

  • Send M-SEARCH request
  • Answer M-SEARCH request
  • Store a list of all services answering M-SEARCH
  • Send ALIVE when service comes up
  • Send BYEBYE when service goes down
  • Accept header in any order (right now only headers in a pre-defined order are working)

Examples

Service

To launch a Service that listens and answers to M-SEARCH requests do:

let desc = ServiceDescription {
    usn_uri: "uuid:83760048-2d32-4e48-854f-f63a8fa9fd09".to_string(), // TODO get from db
    service_type_uri: "AccessTime:Multicast".to_string(),
    expiration: 100,
    location: "https://127.0.0.1/api/v1/adopt".to_string(), // TODO get a servername from conf
};

let service = Service::new(desc);
service.listen(MulticastAddr::Loopback).await;

Client

A client sends a M-SEARCH request and stores a list of all answering services.

let log = LogConfig{
    syslog_server: None,
    syslog_port: None,
    syslog_protocol: None,
    log_level: Some("trace".to_string()),
};

log.initialize_logger();

let client = Client::default();

client
    .discover("uuid:83760048-2d32-4e48-854f-f63a8fa9fd09".to_string(), MulticastAddr::Loopback, "AccessTime:Multicast".to_string())
    .await?;

Now you can fetch a Vec<ServiceDescription> with all answering services using client.get_services()

License

To be fair this is just a setup I need for another project so feel free to do whatever you like with this. So feel free to choose between:

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~3–11MB
~110K SLoC