diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
index 6912e2d..a0f5ea3 100644
--- a/.github/workflows/check.yml
+++ b/.github/workflows/check.yml
@@ -38,10 +38,8 @@ jobs:
run: cargo fmt --all -- --check
- name: Clippy test
run: cargo clippy --profile test -- -D warnings -D clippy::dbg_macro
- - name: Pull and Build Server
- env:
- GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no"
- run: bash pull-and-build-server.sh
+ - name: Download Server
+ run: bash download-server.sh
working-directory: tests
- name: Run tests
run: cargo test
diff --git a/Cargo.toml b/Cargo.toml
index 9b052c5..523fc01 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "colink"
-version = "0.1.22"
+version = "0.2.0"
edition = "2021"
description = "CoLink Rust SDK"
license = "MIT"
diff --git a/README.md b/README.md
index 354fbec..6248088 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ CoLink SDK helps both application adnd protocol developers access the functional
Add this to your Cargo.toml:
```toml
[dependencies]
-colink = "0.1.22"
+colink = "0.2.0"
```
## Getting Started
@@ -71,7 +71,7 @@ cargo run --example auto_confirm
cargo run --example get_next_greeting_message # is optional
```
```
-cargo run --example mtls_request_core_info
+cargo run --example mtls_request_info
```
```
cargo run --example user_lock
diff --git a/examples/host_import_user.rs b/examples/host_import_user.rs
index 1e34092..4cedb1b 100644
--- a/examples/host_import_user.rs
+++ b/examples/host_import_user.rs
@@ -15,7 +15,7 @@ async fn main() -> Result<(), Box
let cl = CoLink::new(addr, jwt);
let (pk, sk) = generate_user();
- let (_, core_pub_key) = cl.request_core_info().await?;
+ let (_, core_pub_key, _) = cl.request_info().await?;
let (signature_timestamp, sig) =
prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
println!(
diff --git a/examples/host_import_users.rs b/examples/host_import_users.rs
index e20910f..4635390 100644
--- a/examples/host_import_users.rs
+++ b/examples/host_import_users.rs
@@ -19,7 +19,7 @@ async fn main() -> Result<(), Box
let mut users = vec![];
for _ in 0..num {
let (pk, sk) = generate_user();
- let (_, core_pub_key) = cl.request_core_info().await?;
+ let (_, core_pub_key, _) = cl.request_info().await?;
let (signature_timestamp, sig) =
prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
users.push(
diff --git a/examples/host_import_users_and_exchange_guest_jwts.rs b/examples/host_import_users_and_exchange_guest_jwts.rs
index 87a143e..55dcd43 100644
--- a/examples/host_import_users_and_exchange_guest_jwts.rs
+++ b/examples/host_import_users_and_exchange_guest_jwts.rs
@@ -20,7 +20,7 @@ async fn main() -> Result<(), Box
let mut guest_jwts = vec![];
for i in 0..num {
let (pk, sk) = generate_user();
- let (_, core_pub_key) = cl.request_core_info().await?;
+ let (_, core_pub_key, _) = cl.request_info().await?;
let (signature_timestamp, sig) =
prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
users.push(
diff --git a/examples/host_import_users_and_set_registry.rs b/examples/host_import_users_and_set_registry.rs
index 6b41dd9..f7bbafe 100644
--- a/examples/host_import_users_and_set_registry.rs
+++ b/examples/host_import_users_and_set_registry.rs
@@ -19,7 +19,7 @@ async fn main() -> Result<(), Box
let cl = CoLink::new(addr, jwt);
let mut users = vec![];
let (pk, sk) = generate_user();
- let (_, core_pub_key) = cl.request_core_info().await?;
+ let (_, core_pub_key, _) = cl.request_info().await?;
let (signature_timestamp, sig) =
prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
let registry_user = cl
@@ -42,7 +42,7 @@ async fn main() -> Result<(), Box
clt.update_registries(®istries).await?;
for i in 0..num {
let (pk, sk) = generate_user();
- let (_, core_pub_key) = cl.request_core_info().await?;
+ let (_, core_pub_key, _) = cl.request_info().await?;
let (signature_timestamp, sig) =
prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
users.push(
diff --git a/examples/mtls_request_core_info.rs b/examples/mtls_request_info.rs
similarity index 88%
rename from examples/mtls_request_core_info.rs
rename to examples/mtls_request_info.rs
index b60d218..626bd7c 100644
--- a/examples/mtls_request_core_info.rs
+++ b/examples/mtls_request_info.rs
@@ -12,7 +12,7 @@ async fn main() -> Result<(), Box
let cl = CoLink::new(addr, "")
.ca_certificate(ca_certificate)
.identity(client_cert, client_key);
- let (_, core_pub_key) = cl.request_core_info().await?;
+ let (_, core_pub_key, _) = cl.request_info().await?;
println!("{}", core_pub_key);
Ok(())
diff --git a/proto b/proto
index a322f83..12b4f5b 160000
--- a/proto
+++ b/proto
@@ -1 +1 @@
-Subproject commit a322f83c2fa0f74127531728394a1ea24acbe8ab
+Subproject commit 12b4f5b0f098d3889f5e8ac4f6bd869a24c3f7b6
diff --git a/src/application.rs b/src/application.rs
index 470005e..69c898f 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -354,12 +354,13 @@ impl CoLink {
Ok(())
}
- pub async fn request_core_info(&self) -> Result<(String, secp256k1::PublicKey), Error> {
+ pub async fn request_info(&self) -> Result<(String, secp256k1::PublicKey, String), Error> {
let mut client = self._grpc_connect(&self.core_addr).await?;
let request = generate_request(&self.jwt, Empty::default());
- let response = client.request_core_info(request).await?;
+ let response = client.request_info(request).await?;
debug!("RESPONSE={:?}", response);
let mq_uri = response.get_ref().mq_uri.clone();
+ let requestor_ip = response.get_ref().requestor_ip.clone();
let core_public_key_vec: Vec = response.get_ref().core_public_key.clone();
let core_public_key: secp256k1::PublicKey =
match secp256k1::PublicKey::from_slice(&core_public_key_vec) {
@@ -371,7 +372,7 @@ impl CoLink {
))))
}
};
- Ok((mq_uri, core_public_key))
+ Ok((mq_uri, core_public_key, requestor_ip))
}
pub async fn subscribe(
@@ -410,7 +411,7 @@ impl CoLink {
}
pub async fn new_subscriber(&self, queue_name: &str) -> Result {
- let (mq_uri, _) = self.request_core_info().await?;
+ let (mq_uri, _, _) = self.request_info().await?;
let subscriber = CoLinkSubscriber::new(&mq_uri, queue_name).await?;
Ok(subscriber)
}
diff --git a/src/protocol.rs b/src/protocol.rs
index 4324908..2660ca7 100644
--- a/src/protocol.rs
+++ b/src/protocol.rs
@@ -98,7 +98,7 @@ impl CoLinkProtocol {
};
self.cl.unlock(lock).await?;
- let (mq_addr, _) = self.cl.request_core_info().await?;
+ let (mq_addr, _, _) = self.cl.request_info().await?;
let mq = Connection::connect(&mq_addr, ConnectionProperties::default()).await?;
let channel = mq.create_channel().await?;
channel.basic_qos(1, BasicQosOptions::default()).await?;
diff --git a/tests/download-server.sh b/tests/download-server.sh
new file mode 100755
index 0000000..080c9e6
--- /dev/null
+++ b/tests/download-server.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+set -e
+rm -rf colink-server
+mkdir colink-server && cd colink-server
+wget https://github.com/CoLearn-Dev/colink-server-dev/releases/download/v0.2.0/colink-server-linux-x86_64.tar.gz
+tar -xzf colink-server-linux-x86_64.tar.gz
+touch user_init_config.toml # create an empty user init config to prevent automatically starting protocols when importing users.
+cd ..
diff --git a/tests/pull-and-build-server.sh b/tests/pull-and-build-server.sh
deleted file mode 100755
index d945a29..0000000
--- a/tests/pull-and-build-server.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-set -e
-rm -rf colink-server
-git clone --recursive git@github.com:CoLearn-Dev/colink-server-dev.git -b v0.1.7 colink-server
-cd colink-server
-cargo build
-cd ..
diff --git a/tests/test_example_protocol_greetings.rs b/tests/test_example_protocol_greetings.rs
index 283e15d..839d6e7 100644
--- a/tests/test_example_protocol_greetings.rs
+++ b/tests/test_example_protocol_greetings.rs
@@ -125,10 +125,8 @@ fn test_greetings(port: u16, user_num: usize) -> Result<(), Box Child {
- Command::new("cargo")
+ Command::new("./colink-server")
.args([
- "run",
- "--",
"--address",
CORE_ADDR,
"--port",
@@ -140,6 +138,15 @@ fn start_core(port: u16) -> Child {
"--mq-prefix",
MQ_PREFIX,
])
+ .env(
+ "COLINK_HOME",
+ std::env::current_dir()
+ .unwrap()
+ .join("tests")
+ .join("colink-server")
+ .to_str()
+ .unwrap(),
+ )
.current_dir("./tests/colink-server")
.stdout(Stdio::null())
.stderr(Stdio::null())
@@ -148,13 +155,6 @@ fn start_core(port: u16) -> Child {
}
fn build() {
- let mut core = Command::new("cargo")
- .args(["build"])
- .current_dir("./tests/colink-server")
- .stdout(Stdio::null())
- .stderr(Stdio::null())
- .spawn()
- .unwrap();
let mut sdk = Command::new("cargo")
.args(["build", "--all-targets"])
.current_dir("./")
@@ -162,7 +162,6 @@ fn build() {
.stderr(Stdio::null())
.spawn()
.unwrap();
- core.wait().unwrap();
sdk.wait().unwrap();
}