Skip to content

Commit e55f753

Browse files
authored
Merge pull request #25 from CoLearn-Dev/request_info
- request_core_info -> request_info
2 parents 06d2c28 + 8627047 commit e55f753

14 files changed

+36
-37
lines changed

.github/workflows/check.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ jobs:
3838
run: cargo fmt --all -- --check
3939
- name: Clippy test
4040
run: cargo clippy --profile test -- -D warnings -D clippy::dbg_macro
41-
- name: Pull and Build Server
42-
env:
43-
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no"
44-
run: bash pull-and-build-server.sh
41+
- name: Download Server
42+
run: bash download-server.sh
4543
working-directory: tests
4644
- name: Run tests
4745
run: cargo test

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "colink"
3-
version = "0.1.22"
3+
version = "0.2.0"
44
edition = "2021"
55
description = "CoLink Rust SDK"
66
license = "MIT"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CoLink SDK helps both application adnd protocol developers access the functional
99
Add this to your Cargo.toml:
1010
```toml
1111
[dependencies]
12-
colink = "0.1.22"
12+
colink = "0.2.0"
1313
```
1414

1515
## Getting Started
@@ -71,7 +71,7 @@ cargo run --example auto_confirm <address> <user_jwt> <protocol_name>
7171
cargo run --example get_next_greeting_message <address> <user_jwt> <start_timestamp> # <start_timestamp> is optional
7272
```
7373
```
74-
cargo run --example mtls_request_core_info <address> <ca_certificate> <client_cert> <client_key>
74+
cargo run --example mtls_request_info <address> <ca_certificate> <client_cert> <client_key>
7575
```
7676
```
7777
cargo run --example user_lock <address> <user_jwt>

examples/host_import_user.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>
1515

1616
let cl = CoLink::new(addr, jwt);
1717
let (pk, sk) = generate_user();
18-
let (_, core_pub_key) = cl.request_core_info().await?;
18+
let (_, core_pub_key, _) = cl.request_info().await?;
1919
let (signature_timestamp, sig) =
2020
prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
2121
println!(

examples/host_import_users.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>
1919
let mut users = vec![];
2020
for _ in 0..num {
2121
let (pk, sk) = generate_user();
22-
let (_, core_pub_key) = cl.request_core_info().await?;
22+
let (_, core_pub_key, _) = cl.request_info().await?;
2323
let (signature_timestamp, sig) =
2424
prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
2525
users.push(

examples/host_import_users_and_exchange_guest_jwts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>
2020
let mut guest_jwts = vec![];
2121
for i in 0..num {
2222
let (pk, sk) = generate_user();
23-
let (_, core_pub_key) = cl.request_core_info().await?;
23+
let (_, core_pub_key, _) = cl.request_info().await?;
2424
let (signature_timestamp, sig) =
2525
prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
2626
users.push(

examples/host_import_users_and_set_registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>
1919
let cl = CoLink::new(addr, jwt);
2020
let mut users = vec![];
2121
let (pk, sk) = generate_user();
22-
let (_, core_pub_key) = cl.request_core_info().await?;
22+
let (_, core_pub_key, _) = cl.request_info().await?;
2323
let (signature_timestamp, sig) =
2424
prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
2525
let registry_user = cl
@@ -42,7 +42,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>
4242
clt.update_registries(&registries).await?;
4343
for i in 0..num {
4444
let (pk, sk) = generate_user();
45-
let (_, core_pub_key) = cl.request_core_info().await?;
45+
let (_, core_pub_key, _) = cl.request_info().await?;
4646
let (signature_timestamp, sig) =
4747
prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
4848
users.push(

examples/mtls_request_core_info.rs renamed to examples/mtls_request_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>
1212
let cl = CoLink::new(addr, "")
1313
.ca_certificate(ca_certificate)
1414
.identity(client_cert, client_key);
15-
let (_, core_pub_key) = cl.request_core_info().await?;
15+
let (_, core_pub_key, _) = cl.request_info().await?;
1616
println!("{}", core_pub_key);
1717

1818
Ok(())

proto

Submodule proto updated 1 file

src/application.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,13 @@ impl CoLink {
354354
Ok(())
355355
}
356356

357-
pub async fn request_core_info(&self) -> Result<(String, secp256k1::PublicKey), Error> {
357+
pub async fn request_info(&self) -> Result<(String, secp256k1::PublicKey, String), Error> {
358358
let mut client = self._grpc_connect(&self.core_addr).await?;
359359
let request = generate_request(&self.jwt, Empty::default());
360-
let response = client.request_core_info(request).await?;
360+
let response = client.request_info(request).await?;
361361
debug!("RESPONSE={:?}", response);
362362
let mq_uri = response.get_ref().mq_uri.clone();
363+
let requestor_ip = response.get_ref().requestor_ip.clone();
363364
let core_public_key_vec: Vec<u8> = response.get_ref().core_public_key.clone();
364365
let core_public_key: secp256k1::PublicKey =
365366
match secp256k1::PublicKey::from_slice(&core_public_key_vec) {
@@ -371,7 +372,7 @@ impl CoLink {
371372
))))
372373
}
373374
};
374-
Ok((mq_uri, core_public_key))
375+
Ok((mq_uri, core_public_key, requestor_ip))
375376
}
376377

377378
pub async fn subscribe(
@@ -410,7 +411,7 @@ impl CoLink {
410411
}
411412

412413
pub async fn new_subscriber(&self, queue_name: &str) -> Result<CoLinkSubscriber, Error> {
413-
let (mq_uri, _) = self.request_core_info().await?;
414+
let (mq_uri, _, _) = self.request_info().await?;
414415
let subscriber = CoLinkSubscriber::new(&mq_uri, queue_name).await?;
415416
Ok(subscriber)
416417
}

0 commit comments

Comments
 (0)