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
503 changes: 466 additions & 37 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ base64 = "0.22.1"
bon = "3.8.0"
chrono = { version = "0.4.42", features = ["serde"] }
futures-util = "0.3.31"
generic-array = { version = "=0.14.7", features = ["serde"] }
hmac = "0.12.1"
http = "1.4.0"
hyper = "1.8.1"
Expand Down Expand Up @@ -39,10 +40,12 @@ schemars = "0.8.22"
syn = { version = "2.0.106", features = ["fold"] }
typify = "0.5.0"

# Development
# Development and examples
axum-server = { version = "0.8.0", features = ["tls-rustls"] }
clap = { version = "4.6.0", features = ["derive"] }
eyre = "0.6.12"
http-body-util = "0.1.3"
iocraft = "0.8.0"
tower = "0.5.3"
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }

Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,22 @@ These crates require the avahi client libraries on linux. On debian or debian-li
sudo apt install libavahi-client-dev
```

## Running full client and server examples

The full-client and full-server examples provide complete examples of an s2-connect client and server. Both examples assume local running, which means that the server example needs certificates for the hostname of the machine it is being run on. To generate this, run
```sh
cd s2energy-connection/testdata
./gen_cert <hostname>.local
```

After generating the certificates, the server can be run with
```sh
cargo run --example full-server -- <hostname>
```
and the client with
```sh
cargo run --example full-client
```

## Documentation
You can find the crate documentation at [docs.rs](https://docs.rs/s2energy). The crate documentation assumes that you are familiar with S2; if this is not the case, it may be useful to refer to [the S2 documentation website](https://docs.s2standard.org/docs/welcome/). That documentation explains S2 concepts in more detail, and contains a reference of all messages and types in the S2 specification.
3 changes: 3 additions & 0 deletions s2energy-connection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ axum.workspace = true
axum-extra.workspace = true
base64.workspace = true
futures-util.workspace = true
generic-array.workspace = true
hmac.workspace = true
http.workspace = true
hyper.workspace = true
Expand All @@ -32,7 +33,9 @@ zeroconf-tokio.workspace = true

[dev-dependencies]
axum-server.workspace = true
clap.workspace = true
http-body-util.workspace = true
iocraft.workspace = true
tokio = { workspace = true, features = ["signal", "macros", "rt", "test-util"] }
tower.workspace = true
tracing-subscriber.workspace = true
4 changes: 4 additions & 0 deletions s2energy-connection/examples/communication-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ impl ClientPairing for &mut MemoryPairing {
&self.communication_url
}

fn certificate_hash(&self) -> Option<s2energy_connection::CertificateHash> {
None
}

async fn set_access_tokens(&mut self, tokens: Vec<AccessToken>) -> Result<(), Self::Error> {
self.tokens = tokens;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion s2energy-connection/examples/communication-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async fn main() {
.with(EnvFilter::from_default_env())
.init();

let mut server = Server::new(
let server = Server::new(
ServerConfig {
base_url: "localhost:8005".into(),
endpoint_description: None,
Expand Down
Loading
Loading