simple-ssdp

Crates.iosimple-ssdp
lib.rssimple-ssdp
version0.1.0
sourcesrc
created_at2024-07-06 10:43:35.239337
updated_at2024-07-06 10:43:35.239337
descriptionA SSDP implementation
homepage
repositoryhttps://github.com/MrFastDie/simple-ssdp
max_upload_size
id1293974
size41,241
Daniel (MrFastDie)

documentation

README

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.

Commit count: 2

cargo fmt