mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-11-28 22:51:04 +03:00
uqbar->nectar
This commit is contained in:
parent
3638f9a0bd
commit
4c7ca4d35e
@ -16,5 +16,5 @@
|
|||||||
# S3_ACCESS_KEY=minioadmin
|
# S3_ACCESS_KEY=minioadmin
|
||||||
# S3_SECRET__KEY=minioadmin
|
# S3_SECRET__KEY=minioadmin
|
||||||
# S3_REGION=eu-north-1
|
# S3_REGION=eu-north-1
|
||||||
# S3_BUCKET=uqbar
|
# S3_BUCKET=nectar
|
||||||
# S3_ENDPOINT=http://localhost:9000
|
# S3_ENDPOINT=http://localhost:9000
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,5 @@
|
|||||||
target/
|
target/
|
||||||
wit/
|
wit/
|
||||||
uqbar
|
|
||||||
.vscode
|
.vscode
|
||||||
.app-signing
|
.app-signing
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
122
Cargo.lock
generated
122
Cargo.lock
generated
@ -2978,6 +2978,67 @@ dependencies = [
|
|||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nectar"
|
||||||
|
version = "0.5.0"
|
||||||
|
dependencies = [
|
||||||
|
"aes-gcm 0.10.2",
|
||||||
|
"anyhow",
|
||||||
|
"async-trait",
|
||||||
|
"base64 0.13.1",
|
||||||
|
"bincode",
|
||||||
|
"blake3",
|
||||||
|
"bytes",
|
||||||
|
"cap-std",
|
||||||
|
"chacha20poly1305 0.10.1",
|
||||||
|
"chrono",
|
||||||
|
"clap",
|
||||||
|
"crossterm",
|
||||||
|
"dashmap",
|
||||||
|
"digest",
|
||||||
|
"elliptic-curve",
|
||||||
|
"ethers",
|
||||||
|
"ethers-providers",
|
||||||
|
"flate2",
|
||||||
|
"futures",
|
||||||
|
"generic-array",
|
||||||
|
"getrandom",
|
||||||
|
"hex",
|
||||||
|
"hkdf",
|
||||||
|
"hmac",
|
||||||
|
"http",
|
||||||
|
"jwt",
|
||||||
|
"lazy_static",
|
||||||
|
"log",
|
||||||
|
"nohash-hasher",
|
||||||
|
"num-traits",
|
||||||
|
"open",
|
||||||
|
"public-ip",
|
||||||
|
"rand",
|
||||||
|
"reqwest",
|
||||||
|
"ring",
|
||||||
|
"rmp-serde",
|
||||||
|
"rocksdb",
|
||||||
|
"route-recognizer",
|
||||||
|
"rusqlite",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"serde_urlencoded",
|
||||||
|
"sha2",
|
||||||
|
"snow",
|
||||||
|
"static_dir",
|
||||||
|
"thiserror",
|
||||||
|
"tokio",
|
||||||
|
"tokio-tungstenite 0.20.1",
|
||||||
|
"url",
|
||||||
|
"uuid 1.4.1",
|
||||||
|
"walkdir",
|
||||||
|
"warp",
|
||||||
|
"wasmtime",
|
||||||
|
"wasmtime-wasi",
|
||||||
|
"zip",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "new_debug_unreachable"
|
name = "new_debug_unreachable"
|
||||||
version = "1.0.4"
|
version = "1.0.4"
|
||||||
@ -5057,67 +5118,6 @@ version = "0.7.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "uqbar"
|
|
||||||
version = "0.5.0"
|
|
||||||
dependencies = [
|
|
||||||
"aes-gcm 0.10.2",
|
|
||||||
"anyhow",
|
|
||||||
"async-trait",
|
|
||||||
"base64 0.13.1",
|
|
||||||
"bincode",
|
|
||||||
"blake3",
|
|
||||||
"bytes",
|
|
||||||
"cap-std",
|
|
||||||
"chacha20poly1305 0.10.1",
|
|
||||||
"chrono",
|
|
||||||
"clap",
|
|
||||||
"crossterm",
|
|
||||||
"dashmap",
|
|
||||||
"digest",
|
|
||||||
"elliptic-curve",
|
|
||||||
"ethers",
|
|
||||||
"ethers-providers",
|
|
||||||
"flate2",
|
|
||||||
"futures",
|
|
||||||
"generic-array",
|
|
||||||
"getrandom",
|
|
||||||
"hex",
|
|
||||||
"hkdf",
|
|
||||||
"hmac",
|
|
||||||
"http",
|
|
||||||
"jwt",
|
|
||||||
"lazy_static",
|
|
||||||
"log",
|
|
||||||
"nohash-hasher",
|
|
||||||
"num-traits",
|
|
||||||
"open",
|
|
||||||
"public-ip",
|
|
||||||
"rand",
|
|
||||||
"reqwest",
|
|
||||||
"ring",
|
|
||||||
"rmp-serde",
|
|
||||||
"rocksdb",
|
|
||||||
"route-recognizer",
|
|
||||||
"rusqlite",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"serde_urlencoded",
|
|
||||||
"sha2",
|
|
||||||
"snow",
|
|
||||||
"static_dir",
|
|
||||||
"thiserror",
|
|
||||||
"tokio",
|
|
||||||
"tokio-tungstenite 0.20.1",
|
|
||||||
"url",
|
|
||||||
"uuid 1.4.1",
|
|
||||||
"walkdir",
|
|
||||||
"warp",
|
|
||||||
"wasmtime",
|
|
||||||
"wasmtime-wasi",
|
|
||||||
"zip",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "url"
|
name = "url"
|
||||||
version = "2.4.1"
|
version = "2.4.1"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "uqbar"
|
name = "nectar"
|
||||||
authors = ["UqbarDAO"]
|
authors = ["UqbarDAO"]
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
20
README.md
20
README.md
@ -5,15 +5,15 @@
|
|||||||
```bash
|
```bash
|
||||||
# Clone the repo.
|
# Clone the repo.
|
||||||
|
|
||||||
git clone git@github.com:uqbar-dao/uqbar.git
|
git clone git@github.com:uqbar-dao/nectar.git
|
||||||
|
|
||||||
# Configure dependency retrieval from GitHub
|
# Configure dependency retrieval from GitHub
|
||||||
mkdir .cargo
|
mkdir .cargo
|
||||||
echo "net.git-fetch-with-cli = true" > .cargo/config
|
echo "net.git-fetch-with-cli = true" > .cargo/config
|
||||||
|
|
||||||
# Get some stuff so we can build wasm.
|
# Get some stuff so we can build Wasm.
|
||||||
|
|
||||||
cd uqbar
|
cd nectar
|
||||||
cargo install wasm-tools
|
cargo install wasm-tools
|
||||||
rustup install nightly
|
rustup install nightly
|
||||||
rustup target add wasm32-wasi
|
rustup target add wasm32-wasi
|
||||||
@ -55,14 +55,14 @@ On boot you will be prompted to navigate to `localhost:8080`. Make sure your ETH
|
|||||||
- CTRL+R to search history, CTRL+R again to toggle through search results, CTRL+G to cancel search
|
- CTRL+R to search history, CTRL+R again to toggle through search results, CTRL+G to cancel search
|
||||||
|
|
||||||
- `/message <address> <json>`: send an inter-process message. <address> is formatted as <node>@<process_id>. <process_id> is formatted as <process_name>:<package_name>:<publisher_node>.
|
- `/message <address> <json>`: send an inter-process message. <address> is formatted as <node>@<process_id>. <process_id> is formatted as <process_name>:<package_name>:<publisher_node>.
|
||||||
- Example: `/message our@net:sys:uqbar diagnostics`
|
- Example: `/message our@net:sys:nectar diagnostics`
|
||||||
- `our` will always be interpolated by the system as your node's name
|
- `our` will always be interpolated by the system as your node's name
|
||||||
- Can also use `/m` for same command: `/m our@net:sys:uqbar diagnostics`
|
- Can also use `/m` for same command: `/m our@net:sys:nectar diagnostics`
|
||||||
- `/app <address>`: set the terminal to a mode where all messages go to a specific app. To clear this selection, use `/app clear` or simply `/app`. This is useful for apps that have a command line interface.
|
- `/app <address>`: set the terminal to a mode where all messages go to a specific app. To clear this selection, use `/app clear` or simply `/app`. This is useful for apps that have a command line interface.
|
||||||
- Example: `/app our@net:sys:uqbar`, then `/m diagnostics`
|
- Example: `/app our@net:sys:nectar`, then `/m diagnostics`
|
||||||
- Can also use `/a` for same command: `/a our@net:sys:uqbar`
|
- Can also use `/a` for same command: `/a our@net:sys:nectar`
|
||||||
- Example of sending many messages:
|
- Example of sending many messages:
|
||||||
- `/a ben.uq@net:sys:uqbar`
|
- `/a ben.uq@net:sys:nectar`
|
||||||
- `/m hey there`
|
- `/m hey there`
|
||||||
- `/m how are you?`
|
- `/m how are you?`
|
||||||
- `/a` (to exit app mode)
|
- `/a` (to exit app mode)
|
||||||
@ -73,6 +73,6 @@ On boot you will be prompted to navigate to `localhost:8080`. Make sure your ETH
|
|||||||
|
|
||||||
Download and install an app:
|
Download and install an app:
|
||||||
```
|
```
|
||||||
/m our@main:app_store:uqbar {"Download": {"package": {"package_name": "<pkg>", "publisher_node": "<node>"}, "install_from": "<node>"}}
|
/m our@main:app_store:nectar {"Download": {"package": {"package_name": "<pkg>", "publisher_node": "<node>"}, "install_from": "<node>"}}
|
||||||
/m our@main:app_store:uqbar {"Install": {"package_name": "<pkg>", "publisher_node": "<node>"}}
|
/m our@main:app_store:nectar {"Install": {"package_name": "<pkg>", "publisher_node": "<node>"}}
|
||||||
```
|
```
|
||||||
|
@ -11,13 +11,13 @@ def build_and_move(feature, tmp_dir):
|
|||||||
|
|
||||||
if feature:
|
if feature:
|
||||||
subprocess.run(["cargo", "+nightly", "build", "--release", "--features", feature], check=True)
|
subprocess.run(["cargo", "+nightly", "build", "--release", "--features", feature], check=True)
|
||||||
binary_name = f"uqbar-{feature}"
|
binary_name = f"nectar-{feature}"
|
||||||
else:
|
else:
|
||||||
subprocess.run(["cargo", "+nightly", "build", "--release"], check=True)
|
subprocess.run(["cargo", "+nightly", "build", "--release"], check=True)
|
||||||
binary_name = "uqbar"
|
binary_name = "nectar"
|
||||||
|
|
||||||
# Move and rename the binary
|
# Move and rename the binary
|
||||||
source_path = "target/release/uqbar"
|
source_path = "target/release/nectar"
|
||||||
dest_path = os.path.join(tmp_dir, binary_name)
|
dest_path = os.path.join(tmp_dir, binary_name)
|
||||||
shutil.move(source_path, dest_path)
|
shutil.move(source_path, dest_path)
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ def main():
|
|||||||
features = ["", "simulation-mode"] # Add more features as needed
|
features = ["", "simulation-mode"] # Add more features as needed
|
||||||
|
|
||||||
# Ensure the tmp directory is clean
|
# Ensure the tmp directory is clean
|
||||||
tmp_dir = "/tmp/uqbar-release"
|
tmp_dir = "/tmp/nectar-release"
|
||||||
if os.path.exists(tmp_dir):
|
if os.path.exists(tmp_dir):
|
||||||
shutil.rmtree(tmp_dir)
|
shutil.rmtree(tmp_dir)
|
||||||
os.makedirs(tmp_dir)
|
os.makedirs(tmp_dir)
|
||||||
|
6
build.rs
6
build.rs
@ -138,11 +138,11 @@ fn main() {
|
|||||||
// Pull wit from git repo
|
// Pull wit from git repo
|
||||||
let wit_dir = pwd.join("wit");
|
let wit_dir = pwd.join("wit");
|
||||||
fs::create_dir_all(&wit_dir).unwrap();
|
fs::create_dir_all(&wit_dir).unwrap();
|
||||||
let wit_file = wit_dir.join("uqbar.wit");
|
let wit_file = wit_dir.join("nectar.wit");
|
||||||
//if !wit_file.exists() { // TODO: cache in better way
|
//if !wit_file.exists() { // TODO: cache in better way
|
||||||
let mut wit_file = std::fs::File::create(&wit_file).unwrap();
|
let mut wit_file = std::fs::File::create(&wit_file).unwrap();
|
||||||
let uqbar_wit_url = "https://raw.githubusercontent.com/uqbar-dao/uqwit/master/uqbar.wit";
|
let nectar_wit_url = "https://raw.githubusercontent.com/uqbar-dao/uqwit/master/nectar.wit";
|
||||||
let mut response = reqwest::blocking::get(uqbar_wit_url).unwrap();
|
let mut response = reqwest::blocking::get(nectar_wit_url).unwrap();
|
||||||
io::copy(&mut response, &mut wit_file).unwrap();
|
io::copy(&mut response, &mut wit_file).unwrap();
|
||||||
|
|
||||||
// Create target.wasm (compiled .wit) & world
|
// Create target.wasm (compiled .wit) & world
|
||||||
|
@ -15,11 +15,11 @@ rand = "0.8"
|
|||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
sha2 = "0.10.8"
|
sha2 = "0.10.8"
|
||||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
|
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
|
||||||
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[package.metadata.component]
|
[package.metadata.component]
|
||||||
package = "uqbar:process"
|
package = "nectar:process"
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
use nectar_process_lib::kernel_types as kt;
|
||||||
|
use nectar_process_lib::println;
|
||||||
|
use nectar_process_lib::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use sha2::Digest;
|
use sha2::Digest;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use uqbar_process_lib::kernel_types as kt;
|
|
||||||
use uqbar_process_lib::println;
|
|
||||||
use uqbar_process_lib::*;
|
|
||||||
|
|
||||||
wit_bindgen::generate!({
|
wit_bindgen::generate!({
|
||||||
path: "../../../wit",
|
path: "../../../wit",
|
||||||
@ -19,7 +19,7 @@ use ft_worker_lib::{
|
|||||||
spawn_receive_transfer, spawn_transfer, FTWorkerCommand, FTWorkerResult, FileTransferContext,
|
spawn_receive_transfer, spawn_transfer, FTWorkerCommand, FTWorkerResult, FileTransferContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Uqbar App Store:
|
/// Nectar App Store:
|
||||||
/// acts as both a local package manager and a protocol to share packages across the network.
|
/// acts as both a local package manager and a protocol to share packages across the network.
|
||||||
/// packages are apps; apps are packages. we use an onchain app listing contract to determine
|
/// packages are apps; apps are packages. we use an onchain app listing contract to determine
|
||||||
/// what apps are available to download and what node(s) to download them from.
|
/// what apps are available to download and what node(s) to download them from.
|
||||||
@ -346,7 +346,7 @@ fn handle_new_package(
|
|||||||
|
|
||||||
// create a new drive for this package in VFS
|
// create a new drive for this package in VFS
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "uqbar"))
|
.target(("our", "vfs", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: drive.clone(),
|
path: drive.clone(),
|
||||||
action: vfs::VfsAction::CreateDrive,
|
action: vfs::VfsAction::CreateDrive,
|
||||||
@ -361,7 +361,7 @@ fn handle_new_package(
|
|||||||
// add zip bytes
|
// add zip bytes
|
||||||
payload.mime = Some("application/zip".to_string());
|
payload.mime = Some("application/zip".to_string());
|
||||||
let response = Request::new()
|
let response = Request::new()
|
||||||
.target(("our", "vfs", "sys", "uqbar"))
|
.target(("our", "vfs", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: drive.clone(),
|
path: drive.clone(),
|
||||||
action: vfs::VfsAction::AddZip,
|
action: vfs::VfsAction::AddZip,
|
||||||
@ -379,7 +379,7 @@ fn handle_new_package(
|
|||||||
// call it <package>.zip
|
// call it <package>.zip
|
||||||
let zip_path = format!("{}/{}.zip", drive.clone(), package);
|
let zip_path = format!("{}/{}.zip", drive.clone(), package);
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "uqbar"))
|
.target(("our", "vfs", "sys", "nectar"))
|
||||||
.inherit(true)
|
.inherit(true)
|
||||||
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: zip_path,
|
path: zip_path,
|
||||||
@ -392,7 +392,7 @@ fn handle_new_package(
|
|||||||
// now, read the pkg contents to create our own listing and state,
|
// now, read the pkg contents to create our own listing and state,
|
||||||
// such that we can mirror this package to others.
|
// such that we can mirror this package to others.
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "uqbar"))
|
.target(("our", "vfs", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: metadata_path,
|
path: metadata_path,
|
||||||
action: vfs::VfsAction::Read,
|
action: vfs::VfsAction::Read,
|
||||||
@ -427,7 +427,7 @@ fn handle_new_package(
|
|||||||
fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
||||||
let drive_path = format!("/{}/pkg", package);
|
let drive_path = format!("/{}/pkg", package);
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "uqbar"))
|
.target(("our", "vfs", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: format!("{}/manifest.json", drive_path),
|
path: format!("{}/manifest.json", drive_path),
|
||||||
action: vfs::VfsAction::Read,
|
action: vfs::VfsAction::Read,
|
||||||
@ -440,7 +440,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
let manifest = serde_json::from_str::<Vec<kt::PackageManifestEntry>>(&manifest)?;
|
let manifest = serde_json::from_str::<Vec<kt::PackageManifestEntry>>(&manifest)?;
|
||||||
// always grant read/write to their drive, which we created for them
|
// always grant read/write to their drive, which we created for them
|
||||||
let Some(read_cap) = get_capability(
|
let Some(read_cap) = get_capability(
|
||||||
&Address::new(&our.node, ("vfs", "sys", "uqbar")),
|
&Address::new(&our.node, ("vfs", "sys", "nectar")),
|
||||||
&serde_json::to_string(&serde_json::json!({
|
&serde_json::to_string(&serde_json::json!({
|
||||||
"kind": "read",
|
"kind": "read",
|
||||||
"drive": drive_path,
|
"drive": drive_path,
|
||||||
@ -449,7 +449,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
return Err(anyhow::anyhow!("app store: no read cap"));
|
return Err(anyhow::anyhow!("app store: no read cap"));
|
||||||
};
|
};
|
||||||
let Some(write_cap) = get_capability(
|
let Some(write_cap) = get_capability(
|
||||||
&Address::new(&our.node, ("vfs", "sys", "uqbar")),
|
&Address::new(&our.node, ("vfs", "sys", "nectar")),
|
||||||
&serde_json::to_string(&serde_json::json!({
|
&serde_json::to_string(&serde_json::json!({
|
||||||
"kind": "write",
|
"kind": "write",
|
||||||
"drive": drive_path,
|
"drive": drive_path,
|
||||||
@ -458,7 +458,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
return Err(anyhow::anyhow!("app store: no write cap"));
|
return Err(anyhow::anyhow!("app store: no write cap"));
|
||||||
};
|
};
|
||||||
let Some(networking_cap) = get_capability(
|
let Some(networking_cap) = get_capability(
|
||||||
&Address::new(&our.node, ("kernel", "sys", "uqbar")),
|
&Address::new(&our.node, ("kernel", "sys", "nectar")),
|
||||||
&"\"network\"".to_string(),
|
&"\"network\"".to_string(),
|
||||||
) else {
|
) else {
|
||||||
return Err(anyhow::anyhow!("app store: no net cap"));
|
return Err(anyhow::anyhow!("app store: no net cap"));
|
||||||
@ -486,14 +486,14 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
};
|
};
|
||||||
// kill process if it already exists
|
// kill process if it already exists
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "kernel", "sys", "uqbar"))
|
.target(("our", "kernel", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&kt::KernelCommand::KillProcess(
|
.ipc(serde_json::to_vec(&kt::KernelCommand::KillProcess(
|
||||||
parsed_new_process_id.clone(),
|
parsed_new_process_id.clone(),
|
||||||
))?)
|
))?)
|
||||||
.send()?;
|
.send()?;
|
||||||
|
|
||||||
let _bytes_response = Request::new()
|
let _bytes_response = Request::new()
|
||||||
.target(("our", "vfs", "sys", "uqbar"))
|
.target(("our", "vfs", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: wasm_path.clone(),
|
path: wasm_path.clone(),
|
||||||
action: vfs::VfsAction::Read,
|
action: vfs::VfsAction::Read,
|
||||||
@ -554,7 +554,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "kernel", "sys", "uqbar"))
|
.target(("our", "kernel", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
|
.ipc(serde_json::to_vec(&kt::KernelCommand::InitializeProcess {
|
||||||
id: parsed_new_process_id.clone(),
|
id: parsed_new_process_id.clone(),
|
||||||
wasm_bytes_handle: wasm_path,
|
wasm_bytes_handle: wasm_path,
|
||||||
@ -571,7 +571,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
serde_json::Value::String(process_name) => {
|
serde_json::Value::String(process_name) => {
|
||||||
if let Ok(parsed_process_id) = ProcessId::from_str(&process_name) {
|
if let Ok(parsed_process_id) = ProcessId::from_str(&process_name) {
|
||||||
let _ = Request::new()
|
let _ = Request::new()
|
||||||
.target(("our", "kernel", "sys", "uqbar"))
|
.target(("our", "kernel", "sys", "nectar"))
|
||||||
.ipc(
|
.ipc(
|
||||||
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
|
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
|
||||||
target: parsed_process_id,
|
target: parsed_process_id,
|
||||||
@ -595,7 +595,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
{
|
{
|
||||||
if let Some(params) = map.get("params") {
|
if let Some(params) = map.get("params") {
|
||||||
let _ = Request::new()
|
let _ = Request::new()
|
||||||
.target(("our", "kernel", "sys", "uqbar"))
|
.target(("our", "kernel", "sys", "nectar"))
|
||||||
.ipc(
|
.ipc(
|
||||||
serde_json::to_vec(
|
serde_json::to_vec(
|
||||||
&kt::KernelCommand::GrantCapabilities {
|
&kt::KernelCommand::GrantCapabilities {
|
||||||
@ -623,7 +623,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "kernel", "sys", "uqbar"))
|
.target(("our", "kernel", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&kt::KernelCommand::RunProcess(
|
.ipc(serde_json::to_vec(&kt::KernelCommand::RunProcess(
|
||||||
parsed_new_process_id,
|
parsed_new_process_id,
|
||||||
))?)
|
))?)
|
||||||
@ -635,7 +635,7 @@ fn handle_install(our: &Address, package: &PackageId) -> anyhow::Result<()> {
|
|||||||
fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
|
fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
|
||||||
let drive_path = format!("/{}/pkg", package);
|
let drive_path = format!("/{}/pkg", package);
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "uqbar"))
|
.target(("our", "vfs", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: format!("{}/manifest.json", drive_path),
|
path: format!("{}/manifest.json", drive_path),
|
||||||
action: vfs::VfsAction::Read,
|
action: vfs::VfsAction::Read,
|
||||||
@ -653,7 +653,7 @@ fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "kernel", "sys", "uqbar"))
|
.target(("our", "kernel", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&kt::KernelCommand::KillProcess(
|
.ipc(serde_json::to_vec(&kt::KernelCommand::KillProcess(
|
||||||
parsed_new_process_id,
|
parsed_new_process_id,
|
||||||
))?)
|
))?)
|
||||||
@ -661,7 +661,7 @@ fn handle_uninstall(package: &PackageId) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
// then, delete the drive
|
// then, delete the drive
|
||||||
Request::new()
|
Request::new()
|
||||||
.target(("our", "vfs", "sys", "uqbar"))
|
.target(("our", "vfs", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: drive_path,
|
path: drive_path,
|
||||||
action: vfs::VfsAction::RemoveDirAll,
|
action: vfs::VfsAction::RemoveDirAll,
|
||||||
@ -687,7 +687,7 @@ fn handle_remote_request(
|
|||||||
// get the .zip from VFS and attach as payload to response
|
// get the .zip from VFS and attach as payload to response
|
||||||
let file_path = format!("/{}/pkg/{}.zip", package, package);
|
let file_path = format!("/{}/pkg/{}.zip", package, package);
|
||||||
let Ok(Ok(_)) = Request::new()
|
let Ok(Ok(_)) = Request::new()
|
||||||
.target(("our", "vfs", "sys", "uqbar"))
|
.target(("our", "vfs", "sys", "nectar"))
|
||||||
.ipc(
|
.ipc(
|
||||||
serde_json::to_vec(&vfs::VfsRequest {
|
serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: file_path,
|
path: file_path,
|
||||||
|
@ -16,11 +16,11 @@ bincode = "1.3.3"
|
|||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
|
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
|
||||||
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[package.metadata.component]
|
[package.metadata.component]
|
||||||
package = "uqbar:process"
|
package = "nectar:process"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
use nectar_process_lib::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uqbar_process_lib::*;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct FileTransferContext {
|
pub struct FileTransferContext {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
use nectar_process_lib::println;
|
||||||
|
use nectar_process_lib::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uqbar_process_lib::*;
|
|
||||||
use uqbar_process_lib::println;
|
|
||||||
|
|
||||||
mod ft_worker_lib;
|
mod ft_worker_lib;
|
||||||
use ft_worker_lib::*;
|
use ft_worker_lib::*;
|
||||||
@ -23,9 +23,14 @@ pub enum FTWorkerProtocol {
|
|||||||
call_init!(init);
|
call_init!(init);
|
||||||
|
|
||||||
fn init(our: Address) {
|
fn init(our: Address) {
|
||||||
let Ok(Message::Request { source: parent_process, ipc, .. }) = await_message() else {
|
let Ok(Message::Request {
|
||||||
panic!("ft_worker: got bad init message");
|
source: parent_process,
|
||||||
};
|
ipc,
|
||||||
|
..
|
||||||
|
}) = await_message()
|
||||||
|
else {
|
||||||
|
panic!("ft_worker: got bad init message");
|
||||||
|
};
|
||||||
|
|
||||||
let command = serde_json::from_slice::<FTWorkerCommand>(&ipc)
|
let command = serde_json::from_slice::<FTWorkerCommand>(&ipc)
|
||||||
.expect("ft_worker: got unparseable init message");
|
.expect("ft_worker: got unparseable init message");
|
||||||
@ -42,7 +47,9 @@ fn init(our: Address) {
|
|||||||
timeout,
|
timeout,
|
||||||
..
|
..
|
||||||
} => handle_receive(parent_process, &file_name, total_chunks, timeout),
|
} => handle_receive(parent_process, &file_name, total_chunks, timeout),
|
||||||
}) else { return };
|
}) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
Response::new()
|
Response::new()
|
||||||
.ipc(serde_json::to_vec(&result).unwrap())
|
.ipc(serde_json::to_vec(&result).unwrap())
|
||||||
@ -56,7 +63,7 @@ fn handle_send(our: &Address, target: &Address, file_name: &str, timeout: u64) -
|
|||||||
let transfer_id: u64 = our.process().parse().unwrap();
|
let transfer_id: u64 = our.process().parse().unwrap();
|
||||||
let Some(payload) = get_payload() else {
|
let Some(payload) = get_payload() else {
|
||||||
println!("ft_worker: wasn't given payload!");
|
println!("ft_worker: wasn't given payload!");
|
||||||
return FTWorkerResult::Err(TransferError::SourceFailed)
|
return FTWorkerResult::Err(TransferError::SourceFailed);
|
||||||
};
|
};
|
||||||
let file_bytes = payload.bytes;
|
let file_bytes = payload.bytes;
|
||||||
let mut file_size = file_bytes.len() as u64;
|
let mut file_size = file_bytes.len() as u64;
|
||||||
@ -69,19 +76,23 @@ fn handle_send(our: &Address, target: &Address, file_name: &str, timeout: u64) -
|
|||||||
// send contents in chunks and wait for
|
// send contents in chunks and wait for
|
||||||
// acknowledgement.
|
// acknowledgement.
|
||||||
let Ok(Ok(response)) = Request::to(target.clone())
|
let Ok(Ok(response)) = Request::to(target.clone())
|
||||||
.ipc(serde_json::to_vec(&FTWorkerCommand::Receive {
|
.ipc(
|
||||||
transfer_id,
|
serde_json::to_vec(&FTWorkerCommand::Receive {
|
||||||
file_name: file_name.to_string(),
|
transfer_id,
|
||||||
file_size,
|
file_name: file_name.to_string(),
|
||||||
total_chunks,
|
file_size,
|
||||||
timeout,
|
total_chunks,
|
||||||
}).unwrap())
|
timeout,
|
||||||
.send_and_await_response(timeout) else {
|
})
|
||||||
return FTWorkerResult::Err(TransferError::TargetOffline)
|
.unwrap(),
|
||||||
};
|
)
|
||||||
|
.send_and_await_response(timeout)
|
||||||
|
else {
|
||||||
|
return FTWorkerResult::Err(TransferError::TargetOffline);
|
||||||
|
};
|
||||||
let opp_worker = response.source();
|
let opp_worker = response.source();
|
||||||
let Ok(FTWorkerProtocol::Ready) = serde_json::from_slice(&response.ipc()) else {
|
let Ok(FTWorkerProtocol::Ready) = serde_json::from_slice(&response.ipc()) else {
|
||||||
return FTWorkerResult::Err(TransferError::TargetRejected)
|
return FTWorkerResult::Err(TransferError::TargetRejected);
|
||||||
};
|
};
|
||||||
// send file in chunks
|
// send file in chunks
|
||||||
loop {
|
loop {
|
||||||
@ -110,10 +121,10 @@ fn handle_send(our: &Address, target: &Address, file_name: &str, timeout: u64) -
|
|||||||
}
|
}
|
||||||
// now wait for Finished response
|
// now wait for Finished response
|
||||||
let Ok(Message::Response { ipc, .. }) = await_message() else {
|
let Ok(Message::Response { ipc, .. }) = await_message() else {
|
||||||
return FTWorkerResult::Err(TransferError::TargetRejected)
|
return FTWorkerResult::Err(TransferError::TargetRejected);
|
||||||
};
|
};
|
||||||
let Ok(FTWorkerProtocol::Finished) = serde_json::from_slice(&ipc) else {
|
let Ok(FTWorkerProtocol::Finished) = serde_json::from_slice(&ipc) else {
|
||||||
return FTWorkerResult::Err(TransferError::TargetRejected)
|
return FTWorkerResult::Err(TransferError::TargetRejected);
|
||||||
};
|
};
|
||||||
// return success to parent
|
// return success to parent
|
||||||
return FTWorkerResult::SendSuccess;
|
return FTWorkerResult::SendSuccess;
|
||||||
@ -138,13 +149,13 @@ fn handle_receive(
|
|||||||
let start_time = std::time::Instant::now();
|
let start_time = std::time::Instant::now();
|
||||||
loop {
|
loop {
|
||||||
let Ok(Message::Request { .. }) = await_message() else {
|
let Ok(Message::Request { .. }) = await_message() else {
|
||||||
return Some(FTWorkerResult::Err(TransferError::SourceFailed))
|
return Some(FTWorkerResult::Err(TransferError::SourceFailed));
|
||||||
};
|
};
|
||||||
if start_time.elapsed().as_secs() > timeout {
|
if start_time.elapsed().as_secs() > timeout {
|
||||||
return Some(FTWorkerResult::Err(TransferError::SourceFailed))
|
return Some(FTWorkerResult::Err(TransferError::SourceFailed));
|
||||||
}
|
}
|
||||||
let Some(payload) = get_payload() else {
|
let Some(payload) = get_payload() else {
|
||||||
return Some(FTWorkerResult::Err(TransferError::SourceFailed))
|
return Some(FTWorkerResult::Err(TransferError::SourceFailed));
|
||||||
};
|
};
|
||||||
chunks_received += 1;
|
chunks_received += 1;
|
||||||
file_bytes.extend(payload.bytes);
|
file_bytes.extend(payload.bytes);
|
||||||
|
@ -5,25 +5,25 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": true,
|
"request_networking": true,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"terminal:terminal:uqbar",
|
"terminal:terminal:nectar",
|
||||||
"filesystem:sys:uqbar",
|
"filesystem:sys:nectar",
|
||||||
"http_server:sys:uqbar",
|
"http_server:sys:nectar",
|
||||||
"http_client:sys:uqbar",
|
"http_client:sys:nectar",
|
||||||
"net:sys:uqbar",
|
"net:sys:nectar",
|
||||||
"vfs:sys:uqbar",
|
"vfs:sys:nectar",
|
||||||
"kernel:sys:uqbar",
|
"kernel:sys:nectar",
|
||||||
"eth:sys:uqbar",
|
"eth:sys:nectar",
|
||||||
{
|
{
|
||||||
"process": "vfs:sys:uqbar",
|
"process": "vfs:sys:nectar",
|
||||||
"params": {
|
"params": {
|
||||||
"root": true
|
"root": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"grant_capabilities": [
|
"grant_capabilities": [
|
||||||
"http_server:sys:uqbar",
|
"http_server:sys:nectar",
|
||||||
"terminal:terminal:uqbar",
|
"terminal:terminal:nectar",
|
||||||
"vfs:sys:uqbar"
|
"vfs:sys:nectar"
|
||||||
],
|
],
|
||||||
"public": false
|
"public": false
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
{
|
{
|
||||||
"package": "app_store",
|
"package": "app_store",
|
||||||
"publisher": "uqbar",
|
"publisher": "nectar",
|
||||||
"version": [0, 2, 0],
|
"version": [
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
0
|
||||||
|
],
|
||||||
"description": "A package manager + app store."
|
"description": "A package manager + app store."
|
||||||
}
|
}
|
@ -16,11 +16,11 @@ pleco = "0.5"
|
|||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
url = "*"
|
url = "*"
|
||||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
|
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
|
||||||
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[package.metadata.component]
|
[package.metadata.component]
|
||||||
package = "uqbar:process"
|
package = "nectar:process"
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
use pleco::Board;
|
use nectar_process_lib::{
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
use uqbar_process_lib::{
|
|
||||||
await_message, call_init, get_payload, get_typed_state, http, println, set_state, Address,
|
await_message, call_init, get_payload, get_typed_state, http, println, set_state, Address,
|
||||||
Message, NodeId, Payload, Request, Response,
|
Message, NodeId, Payload, Request, Response,
|
||||||
};
|
};
|
||||||
|
use pleco::Board;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
extern crate base64;
|
extern crate base64;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -73,7 +73,7 @@ fn load_chess_state() -> ChessState {
|
|||||||
fn send_ws_update(our: &Address, game: &Game, open_channels: &HashSet<u32>) -> anyhow::Result<()> {
|
fn send_ws_update(our: &Address, game: &Game, open_channels: &HashSet<u32>) -> anyhow::Result<()> {
|
||||||
for channel in open_channels {
|
for channel in open_channels {
|
||||||
Request::new()
|
Request::new()
|
||||||
.target((&our.node, "http_server", "sys", "uqbar"))
|
.target((&our.node, "http_server", "sys", "nectar"))
|
||||||
.ipc(serde_json::to_vec(
|
.ipc(serde_json::to_vec(
|
||||||
&http::HttpServerAction::WebSocketPush {
|
&http::HttpServerAction::WebSocketPush {
|
||||||
channel_id: *channel,
|
channel_id: *channel,
|
||||||
@ -94,7 +94,7 @@ fn send_ws_update(our: &Address, game: &Game, open_channels: &HashSet<u32>) -> a
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boilerplate: generate the wasm bindings for an Uqbar app
|
// Boilerplate: generate the wasm bindings for a Nectar app
|
||||||
wit_bindgen::generate!({
|
wit_bindgen::generate!({
|
||||||
path: "../../../wit",
|
path: "../../../wit",
|
||||||
world: "process",
|
world: "process",
|
||||||
@ -168,14 +168,14 @@ fn handle_request(our: &Address, message: &Message, state: &mut ChessState) -> a
|
|||||||
// Note that since this is a local request, we *can* trust the ProcessId.
|
// Note that since this is a local request, we *can* trust the ProcessId.
|
||||||
// Here, we'll accept messages from the local terminal so as to make this a "CLI" app.
|
// Here, we'll accept messages from the local terminal so as to make this a "CLI" app.
|
||||||
} else if message.source().node == our.node
|
} else if message.source().node == our.node
|
||||||
&& message.source().process == "terminal:terminal:uqbar"
|
&& message.source().process == "terminal:terminal:nectar"
|
||||||
{
|
{
|
||||||
let Ok(chess_request) = serde_json::from_slice::<ChessRequest>(message.ipc()) else {
|
let Ok(chess_request) = serde_json::from_slice::<ChessRequest>(message.ipc()) else {
|
||||||
return Err(anyhow::anyhow!("invalid chess request"));
|
return Err(anyhow::anyhow!("invalid chess request"));
|
||||||
};
|
};
|
||||||
handle_local_request(our, state, &chess_request)
|
handle_local_request(our, state, &chess_request)
|
||||||
} else if message.source().node == our.node
|
} else if message.source().node == our.node
|
||||||
&& message.source().process == "http_server:sys:uqbar"
|
&& message.source().process == "http_server:sys:nectar"
|
||||||
{
|
{
|
||||||
// receive HTTP requests and websocket connection messages from our server
|
// receive HTTP requests and websocket connection messages from our server
|
||||||
match serde_json::from_slice::<http::HttpServerRequest>(message.ipc())? {
|
match serde_json::from_slice::<http::HttpServerRequest>(message.ipc())? {
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": true,
|
"request_networking": true,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"net:sys:uqbar"
|
"net:sys:nectar"
|
||||||
],
|
],
|
||||||
"grant_capabilities": [
|
"grant_capabilities": [
|
||||||
"http_server:sys:uqbar"
|
"http_server:sys:nectar"
|
||||||
],
|
],
|
||||||
"public": true
|
"public": true
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
{
|
{
|
||||||
"package": "chess",
|
"package": "chess",
|
||||||
"publisher": "uqbar",
|
"publisher": "nectar",
|
||||||
"version": [0, 2, 0]
|
"version": [
|
||||||
}
|
0,
|
||||||
|
2,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -15,11 +15,11 @@ anyhow = "1.0"
|
|||||||
bincode = "1.3.3"
|
bincode = "1.3.3"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
|
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
|
||||||
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[package.metadata.component]
|
[package.metadata.component]
|
||||||
package = "uqbar:process"
|
package = "nectar:process"
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
|||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
use uqbar_process_lib::{
|
use nectar_process_lib::{
|
||||||
await_message, http::bind_http_static_path, http::HttpServerError, println,
|
await_message, http::bind_http_static_path, http::HttpServerError, println, Address, Message,
|
||||||
Address, Message, ProcessId,
|
ProcessId,
|
||||||
};
|
};
|
||||||
|
|
||||||
wit_bindgen::generate!({
|
wit_bindgen::generate!({
|
||||||
@ -66,7 +66,7 @@ fn main(our: Address) -> anyhow::Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
if let Message::Response { source, ipc, .. } = message
|
if let Message::Response { source, ipc, .. } = message
|
||||||
&& source.process == "http_server:sys:uqbar"
|
&& source.process == "http_server:sys:nectar"
|
||||||
{
|
{
|
||||||
match serde_json::from_slice::<Result<(), HttpServerError>>(&ipc) {
|
match serde_json::from_slice::<Result<(), HttpServerError>>(&ipc) {
|
||||||
Ok(Ok(())) => continue,
|
Ok(Ok(())) => continue,
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": false,
|
"request_networking": false,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"http_server:sys:uqbar"
|
"http_server:sys:nectar"
|
||||||
],
|
],
|
||||||
"grant_capabilities": [
|
"grant_capabilities": [
|
||||||
"http_server:sys:uqbar"
|
"http_server:sys:nectar"
|
||||||
],
|
],
|
||||||
"public": false
|
"public": false
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
{
|
{
|
||||||
"package": "homepage",
|
"package": "homepage",
|
||||||
"publisher": "uqbar",
|
"publisher": "nectar",
|
||||||
"version": [0, 1, 0]
|
"version": [
|
||||||
}
|
0,
|
||||||
|
1,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
@ -5,10 +5,10 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": true,
|
"request_networking": true,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"net:sys:uqbar",
|
"net:sys:nectar",
|
||||||
"http_server:sys:uqbar",
|
"http_server:sys:nectar",
|
||||||
"eth:sys:uqbar"
|
"eth:sys:nectar"
|
||||||
],
|
],
|
||||||
"public": true
|
"public": true
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -1,5 +1,9 @@
|
|||||||
{
|
{
|
||||||
"package": "qns_indexer",
|
"package": "qns_indexer",
|
||||||
"publisher": "uqbar",
|
"publisher": "nectar",
|
||||||
"version": [0, 1, 0]
|
"version": [
|
||||||
}
|
0,
|
||||||
|
1,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
@ -20,11 +20,11 @@ hex = "0.4.3"
|
|||||||
rmp-serde = "1.1.2"
|
rmp-serde = "1.1.2"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6228e0f", features = ["eth"] }
|
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6228e0f", features = ["eth"] }
|
||||||
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[package.metadata.component]
|
[package.metadata.component]
|
||||||
package = "uqbar:process"
|
package = "nectar:process"
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
use alloy_primitives::B256;
|
use alloy_primitives::B256;
|
||||||
use alloy_rpc_types::Log;
|
use alloy_rpc_types::Log;
|
||||||
use alloy_sol_types::{sol, SolEvent};
|
use alloy_sol_types::{sol, SolEvent};
|
||||||
|
use nectar_process_lib::eth::{EthAddress, SubscribeLogsRequest};
|
||||||
|
use nectar_process_lib::{
|
||||||
|
await_message, get_typed_state, http, print_to_terminal, println, set_state, Address, Message,
|
||||||
|
Payload, Request, Response,
|
||||||
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::hash_map::{Entry, HashMap};
|
use std::collections::hash_map::{Entry, HashMap};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::string::FromUtf8Error;
|
use std::string::FromUtf8Error;
|
||||||
use uqbar_process_lib::eth::{EthAddress, SubscribeLogsRequest};
|
|
||||||
use uqbar_process_lib::{
|
|
||||||
await_message, get_typed_state, http, print_to_terminal, println, set_state, Address, Message,
|
|
||||||
Payload, Request, Response,
|
|
||||||
};
|
|
||||||
|
|
||||||
wit_bindgen::generate!({
|
wit_bindgen::generate!({
|
||||||
path: "../../../wit",
|
path: "../../../wit",
|
||||||
@ -112,7 +112,7 @@ impl Guest for Component {
|
|||||||
fn main(our: Address, mut state: State) -> anyhow::Result<()> {
|
fn main(our: Address, mut state: State) -> anyhow::Result<()> {
|
||||||
// shove all state into net::net
|
// shove all state into net::net
|
||||||
Request::new()
|
Request::new()
|
||||||
.target((&our.node, "net", "sys", "uqbar"))
|
.target((&our.node, "net", "sys", "nectar"))
|
||||||
.try_ipc(NetActions::QnsBatchUpdate(
|
.try_ipc(NetActions::QnsBatchUpdate(
|
||||||
state.nodes.values().cloned().collect::<Vec<_>>(),
|
state.nodes.values().cloned().collect::<Vec<_>>(),
|
||||||
))?
|
))?
|
||||||
@ -145,7 +145,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
if source.process == "http_server:sys:uqbar" {
|
if source.process == "http_server:sys:nectar" {
|
||||||
if let Ok(ipc_json) = serde_json::from_slice::<serde_json::Value>(&ipc) {
|
if let Ok(ipc_json) = serde_json::from_slice::<serde_json::Value>(&ipc) {
|
||||||
if ipc_json["path"].as_str().unwrap_or_default() == "/node/:name" {
|
if ipc_json["path"].as_str().unwrap_or_default() == "/node/:name" {
|
||||||
if let Some(name) = ipc_json["url_params"]["name"].as_str() {
|
if let Some(name) = ipc_json["url_params"]["name"].as_str() {
|
||||||
@ -239,7 +239,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> {
|
|||||||
if send {
|
if send {
|
||||||
print_to_terminal(1, &format!("qns_indexer: sending ID to net: {:?}", node));
|
print_to_terminal(1, &format!("qns_indexer: sending ID to net: {:?}", node));
|
||||||
Request::new()
|
Request::new()
|
||||||
.target((&our.node, "net", "sys", "uqbar"))
|
.target((&our.node, "net", "sys", "nectar"))
|
||||||
.try_ipc(NetActions::QnsUpdate(node.clone()))?
|
.try_ipc(NetActions::QnsUpdate(node.clone()))?
|
||||||
.send()?;
|
.send()?;
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": true,
|
"request_networking": true,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"net:sys:uqbar",
|
"net:sys:nectar",
|
||||||
"http_client:sys:uqbar",
|
"http_client:sys:nectar",
|
||||||
"kernel:sys:uqbar"
|
"kernel:sys:nectar"
|
||||||
],
|
],
|
||||||
"public": true
|
"public": true
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -1,5 +1,9 @@
|
|||||||
{
|
{
|
||||||
"package": "terminal",
|
"package": "terminal",
|
||||||
"publisher": "uqbar",
|
"publisher": "nectar",
|
||||||
"version": [0, 1, 0]
|
"version": [
|
||||||
}
|
0,
|
||||||
|
1,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
@ -15,11 +15,11 @@ anyhow = "1.0"
|
|||||||
bincode = "1.3.3"
|
bincode = "1.3.3"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
|
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
|
||||||
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[package.metadata.component]
|
[package.metadata.component]
|
||||||
package = "uqbar:process"
|
package = "nectar:process"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use uqbar_process_lib::uqbar::process::standard as wit;
|
use nectar_process_lib::nectar::process::standard as wit;
|
||||||
use uqbar_process_lib::{println, Address, Request};
|
use nectar_process_lib::{println, Address, Request};
|
||||||
|
|
||||||
wit_bindgen::generate!({
|
wit_bindgen::generate!({
|
||||||
path: "../../../wit",
|
path: "../../../wit",
|
||||||
@ -29,9 +29,13 @@ fn parse_command(state: &mut TerminalState, line: &str) -> anyhow::Result<()> {
|
|||||||
Some((s, t)) => (s, t),
|
Some((s, t)) => (s, t),
|
||||||
None => return Err(anyhow!("invalid command: \"{line}\"")),
|
None => return Err(anyhow!("invalid command: \"{line}\"")),
|
||||||
};
|
};
|
||||||
let node_id = if node_id == "our" { &state.our.node } else { node_id };
|
let node_id = if node_id == "our" {
|
||||||
|
&state.our.node
|
||||||
|
} else {
|
||||||
|
node_id
|
||||||
|
};
|
||||||
Request::new()
|
Request::new()
|
||||||
.target((node_id, "net", "sys", "uqbar"))
|
.target((node_id, "net", "sys", "nectar"))
|
||||||
.ipc(message)
|
.ipc(message)
|
||||||
.expects_response(5)
|
.expects_response(5)
|
||||||
.send()?;
|
.send()?;
|
||||||
@ -56,10 +60,7 @@ fn parse_command(state: &mut TerminalState, line: &str) -> anyhow::Result<()> {
|
|||||||
// otherwise use the current_target
|
// otherwise use the current_target
|
||||||
"/m" | "/message" => {
|
"/m" | "/message" => {
|
||||||
if let Some(target) = &state.current_target {
|
if let Some(target) = &state.current_target {
|
||||||
Request::new()
|
Request::new().target(target.clone()).ipc(tail).send()
|
||||||
.target(target.clone())
|
|
||||||
.ipc(tail)
|
|
||||||
.send()
|
|
||||||
} else {
|
} else {
|
||||||
let (target, ipc) = match tail.split_once(" ") {
|
let (target, ipc) = match tail.split_once(" ") {
|
||||||
Some((a, p)) => (a, p),
|
Some((a, p)) => (a, p),
|
||||||
@ -68,10 +69,7 @@ fn parse_command(state: &mut TerminalState, line: &str) -> anyhow::Result<()> {
|
|||||||
let Ok(target) = Address::from_str(target) else {
|
let Ok(target) = Address::from_str(target) else {
|
||||||
return Err(anyhow!("invalid address: \"{target}\""));
|
return Err(anyhow!("invalid address: \"{target}\""));
|
||||||
};
|
};
|
||||||
Request::new()
|
Request::new().target(target).ipc(ipc).send()
|
||||||
.target(target)
|
|
||||||
.ipc(ipc)
|
|
||||||
.send()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => return Err(anyhow!("invalid command: \"{line}\"")),
|
_ => return Err(anyhow!("invalid command: \"{line}\"")),
|
||||||
@ -94,10 +92,7 @@ impl Guest for Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
match message {
|
match message {
|
||||||
wit::Message::Request(wit::Request {
|
wit::Message::Request(wit::Request { ipc, .. }) => {
|
||||||
ipc,
|
|
||||||
..
|
|
||||||
}) => {
|
|
||||||
if state.our.node != source.node || state.our.process != source.process {
|
if state.our.node != source.node || state.our.process != source.process {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
"on_exit": "Restart",
|
"on_exit": "Restart",
|
||||||
"request_networking": true,
|
"request_networking": true,
|
||||||
"request_capabilities": [
|
"request_capabilities": [
|
||||||
"net:sys:uqbar",
|
"net:sys:nectar",
|
||||||
"kernel:sys:uqbar"
|
"kernel:sys:nectar"
|
||||||
],
|
],
|
||||||
"grant_capabilities": [
|
"grant_capabilities": [
|
||||||
"vfs:sys:uqbar"
|
"vfs:sys:nectar"
|
||||||
],
|
],
|
||||||
"public": true
|
"public": true
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
{
|
{
|
||||||
"package": "tester",
|
"package": "tester",
|
||||||
"publisher": "uqbar",
|
"publisher": "nectar",
|
||||||
"version": [0, 1, 0]
|
"version": [
|
||||||
}
|
0,
|
||||||
|
1,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
@ -16,11 +16,11 @@ bincode = "1.3.3"
|
|||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
|
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
|
||||||
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[package.metadata.component]
|
[package.metadata.component]
|
||||||
package = "uqbar:process"
|
package = "nectar:process"
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use uqbar_process_lib::kernel_types as kt;
|
use nectar_process_lib::kernel_types as kt;
|
||||||
use uqbar_process_lib::uqbar::process::standard as wit;
|
use nectar_process_lib::nectar::process::standard as wit;
|
||||||
use uqbar_process_lib::{
|
use nectar_process_lib::{
|
||||||
our_capabilities, spawn, vfs, Address, Message, OnExit, ProcessId, Request, Response,
|
our_capabilities, spawn, vfs, Address, Message, OnExit, ProcessId, Request, Response,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ wit_bindgen::generate!({
|
|||||||
fn make_vfs_address(our: &wit::Address) -> anyhow::Result<Address> {
|
fn make_vfs_address(our: &wit::Address) -> anyhow::Result<Address> {
|
||||||
Ok(wit::Address {
|
Ok(wit::Address {
|
||||||
node: our.node.clone(),
|
node: our.node.clone(),
|
||||||
process: ProcessId::from_str("vfs:sys:uqbar")?,
|
process: ProcessId::from_str("vfs:sys:nectar")?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ fn handle_message(our: &Address) -> anyhow::Result<()> {
|
|||||||
let response = Request::new()
|
let response = Request::new()
|
||||||
.target(make_vfs_address(&our)?)
|
.target(make_vfs_address(&our)?)
|
||||||
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
.ipc(serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: "/tester:uqbar/tests".into(),
|
path: "/tester:nectar/tests".into(),
|
||||||
action: vfs::VfsAction::ReadDir,
|
action: vfs::VfsAction::ReadDir,
|
||||||
})?)
|
})?)
|
||||||
.send_and_await_response(test_timeout)?
|
.send_and_await_response(test_timeout)?
|
||||||
|
@ -17,11 +17,11 @@ indexmap = "2.1"
|
|||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e72a791" }
|
nectar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "6520b95" }
|
||||||
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "efcc759" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[package.metadata.component]
|
[package.metadata.component]
|
||||||
package = "uqbar:process"
|
package = "nectar:process"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use indexmap::map::IndexMap;
|
use indexmap::map::IndexMap;
|
||||||
|
|
||||||
use uqbar_process_lib::kernel_types as kt;
|
use nectar_process_lib::kernel_types as kt;
|
||||||
use uqbar_process_lib::{
|
use nectar_process_lib::{
|
||||||
await_message, call_init, our_capabilities, println, spawn, vfs, Address, Capability, Message,
|
await_message, call_init, our_capabilities, println, spawn, vfs, Address, Capability, Message,
|
||||||
OnExit, ProcessId, Request, Response,
|
OnExit, ProcessId, Request, Response,
|
||||||
};
|
};
|
||||||
@ -22,7 +22,7 @@ type Messages = IndexMap<kt::Message, tt::KernelMessage>;
|
|||||||
fn make_vfs_address(our: &Address) -> anyhow::Result<Address> {
|
fn make_vfs_address(our: &Address) -> anyhow::Result<Address> {
|
||||||
Ok(Address {
|
Ok(Address {
|
||||||
node: our.node.clone(),
|
node: our.node.clone(),
|
||||||
process: ProcessId::from_str("vfs:sys:uqbar")?,
|
process: ProcessId::from_str("vfs:sys:nectar")?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ fn handle_message(
|
|||||||
match serde_json::from_slice(&ipc)? {
|
match serde_json::from_slice(&ipc)? {
|
||||||
tt::TesterResponse::Pass | tt::TesterResponse::Fail { .. } => {
|
tt::TesterResponse::Pass | tt::TesterResponse::Fail { .. } => {
|
||||||
if (source.process.package_name != "tester")
|
if (source.process.package_name != "tester")
|
||||||
| (source.process.publisher_node != "uqbar")
|
| (source.process.publisher_node != "nectar")
|
||||||
{
|
{
|
||||||
return Err(tt::TesterError::UnexpectedResponse.into());
|
return Err(tt::TesterError::UnexpectedResponse.into());
|
||||||
}
|
}
|
||||||
@ -70,13 +70,13 @@ fn handle_message(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
// we are master node
|
// we are master node
|
||||||
let child = "/tester:uqbar/pkg/test_runner.wasm";
|
let child = "/tester:nectar/pkg/test_runner.wasm";
|
||||||
let child_process_id = match spawn(
|
let child_process_id = match spawn(
|
||||||
None,
|
None,
|
||||||
child,
|
child,
|
||||||
OnExit::None, // TODO: notify us
|
OnExit::None, // TODO: notify us
|
||||||
our_capabilities(),
|
our_capabilities(),
|
||||||
vec![ProcessId::from_str("vfs:sys:uqbar").unwrap()],
|
vec![ProcessId::from_str("vfs:sys:nectar").unwrap()],
|
||||||
false, // not public
|
false, // not public
|
||||||
) {
|
) {
|
||||||
Ok(child_process_id) => child_process_id,
|
Ok(child_process_id) => child_process_id,
|
||||||
@ -114,7 +114,7 @@ fn init(our: Address) {
|
|||||||
.target(make_vfs_address(&our).unwrap())
|
.target(make_vfs_address(&our).unwrap())
|
||||||
.ipc(
|
.ipc(
|
||||||
serde_json::to_vec(&vfs::VfsRequest {
|
serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: "/tester:uqbar/tests".into(),
|
path: "/tester:nectar/tests".into(),
|
||||||
action: vfs::VfsAction::CreateDrive,
|
action: vfs::VfsAction::CreateDrive,
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
@ -123,18 +123,18 @@ fn init(our: Address) {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let _ = Request::new()
|
let _ = Request::new()
|
||||||
.target(("our", "kernel", "sys", "uqbar"))
|
.target(("our", "kernel", "sys", "nectar"))
|
||||||
.ipc(
|
.ipc(
|
||||||
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
|
serde_json::to_vec(&kt::KernelCommand::GrantCapabilities {
|
||||||
target: ProcessId::new(Some("http_server"), "sys", "uqbar"),
|
target: ProcessId::new(Some("http_server"), "sys", "nectar"),
|
||||||
capabilities: vec![kt::Capability {
|
capabilities: vec![kt::Capability {
|
||||||
issuer: Address::new(
|
issuer: Address::new(
|
||||||
our.node.clone(),
|
our.node.clone(),
|
||||||
ProcessId::new(Some("vfs"), "sys", "uqbar"),
|
ProcessId::new(Some("vfs"), "sys", "nectar"),
|
||||||
),
|
),
|
||||||
params: serde_json::json!({
|
params: serde_json::json!({
|
||||||
"kind": "write",
|
"kind": "write",
|
||||||
"drive": "/tester:uqbar/tests",
|
"drive": "/tester:nectar/tests",
|
||||||
})
|
})
|
||||||
.to_string(),
|
.to_string(),
|
||||||
}],
|
}],
|
||||||
@ -150,7 +150,7 @@ fn init(our: Address) {
|
|||||||
.target(make_vfs_address(&our).unwrap())
|
.target(make_vfs_address(&our).unwrap())
|
||||||
.ipc(
|
.ipc(
|
||||||
serde_json::to_vec(&vfs::VfsRequest {
|
serde_json::to_vec(&vfs::VfsRequest {
|
||||||
path: "/tester:uqbar/tests".into(),
|
path: "/tester:nectar/tests".into(),
|
||||||
action: vfs::VfsAction::CreateDrive,
|
action: vfs::VfsAction::CreateDrive,
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use uqbar_process_lib::kernel_types as kt;
|
use nectar_process_lib::kernel_types as kt;
|
||||||
use uqbar_process_lib::{Address, Response};
|
use nectar_process_lib::{Address, Response};
|
||||||
// use uqbar_process_lib::uqbar::process::standard as wit;
|
// use nectar_process_lib::nectar::process::standard as wit;
|
||||||
|
|
||||||
type Rsvp = Option<Address>;
|
type Rsvp = Option<Address>;
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ async fn connect_websocket(
|
|||||||
id,
|
id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.to_string(),
|
node: our.to_string(),
|
||||||
process: ProcessId::new(Some("http_client"), "sys", "uqbar"),
|
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
|
||||||
},
|
},
|
||||||
target: target.clone(),
|
target: target.clone(),
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
@ -449,7 +449,7 @@ async fn handle_http_request(
|
|||||||
id,
|
id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.to_string(),
|
node: our.to_string(),
|
||||||
process: ProcessId::new(Some("http_client"), "sys", "uqbar"),
|
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
|
||||||
},
|
},
|
||||||
target,
|
target,
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
@ -549,7 +549,7 @@ async fn http_error_message(
|
|||||||
id,
|
id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.to_string(),
|
node: our.to_string(),
|
||||||
process: ProcessId::new(Some("http_client"), "sys", "uqbar"),
|
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
|
||||||
},
|
},
|
||||||
target,
|
target,
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
@ -586,7 +586,7 @@ async fn websocket_error_message(
|
|||||||
id,
|
id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.to_string(),
|
node: our.to_string(),
|
||||||
process: ProcessId::new(Some("http_client"), "sys", "uqbar"),
|
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
|
||||||
},
|
},
|
||||||
target,
|
target,
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
@ -691,7 +691,7 @@ async fn handle_ws_message(
|
|||||||
id,
|
id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.to_string(),
|
node: our.to_string(),
|
||||||
process: ProcessId::new(Some("http_client"), "sys", "uqbar"),
|
process: ProcessId::new(Some("http_client"), "sys", "nectar"),
|
||||||
},
|
},
|
||||||
target,
|
target,
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
|
File diff suppressed because one or more lines are too long
@ -86,13 +86,13 @@ pub async fn http_server(
|
|||||||
// add RPC path
|
// add RPC path
|
||||||
let mut bindings_map: Router<BoundPath> = Router::new();
|
let mut bindings_map: Router<BoundPath> = Router::new();
|
||||||
let rpc_bound_path = BoundPath {
|
let rpc_bound_path = BoundPath {
|
||||||
app: ProcessId::from_str("rpc:sys:uqbar").unwrap(),
|
app: ProcessId::from_str("rpc:sys:nectar").unwrap(),
|
||||||
secure_subdomain: None, // TODO maybe RPC should have subdomain?
|
secure_subdomain: None, // TODO maybe RPC should have subdomain?
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
local_only: true,
|
local_only: true,
|
||||||
static_content: None,
|
static_content: None,
|
||||||
};
|
};
|
||||||
bindings_map.add("/rpc:sys:uqbar/message", rpc_bound_path);
|
bindings_map.add("/rpc:sys:nectar/message", rpc_bound_path);
|
||||||
let path_bindings: PathBindings = Arc::new(RwLock::new(bindings_map));
|
let path_bindings: PathBindings = Arc::new(RwLock::new(bindings_map));
|
||||||
|
|
||||||
// ws path bindings
|
// ws path bindings
|
||||||
@ -241,7 +241,7 @@ async fn login_handler(
|
|||||||
)
|
)
|
||||||
.into_response();
|
.into_response();
|
||||||
|
|
||||||
match HeaderValue::from_str(&format!("uqbar-auth_{}={};", our.as_ref(), &token)) {
|
match HeaderValue::from_str(&format!("nectar-auth_{}={};", our.as_ref(), &token)) {
|
||||||
Ok(v) => {
|
Ok(v) => {
|
||||||
response.headers_mut().append(http::header::SET_COOKIE, v);
|
response.headers_mut().append(http::header::SET_COOKIE, v);
|
||||||
Ok(response)
|
Ok(response)
|
||||||
@ -456,10 +456,10 @@ async fn http_handler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RPC functionality: if path is /rpc:sys:uqbar/message,
|
// RPC functionality: if path is /rpc:sys:nectar/message,
|
||||||
// we extract message from base64 encoded bytes in data
|
// we extract message from base64 encoded bytes in data
|
||||||
// and send it to the correct app.
|
// and send it to the correct app.
|
||||||
let message = if bound_path.app == "rpc:sys:uqbar" {
|
let message = if bound_path.app == "rpc:sys:nectar" {
|
||||||
match handle_rpc_message(our, id, body, print_tx).await {
|
match handle_rpc_message(our, id, body, print_tx).await {
|
||||||
Ok(message) => message,
|
Ok(message) => message,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -797,7 +797,7 @@ async fn handle_app_message(
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
// if path is /rpc/message, return accordingly with base64 encoded payload
|
// if path is /rpc/message, return accordingly with base64 encoded payload
|
||||||
if path == "/rpc:sys:uqbar/message" {
|
if path == "/rpc:sys:nectar/message" {
|
||||||
let payload = km.payload.map(|p| Payload {
|
let payload = km.payload.map(|p| Payload {
|
||||||
mime: p.mime,
|
mime: p.mime,
|
||||||
bytes: base64::encode(p.bytes).into_bytes(),
|
bytes: base64::encode(p.bytes).into_bytes(),
|
||||||
@ -859,7 +859,7 @@ async fn handle_app_message(
|
|||||||
cache,
|
cache,
|
||||||
} => {
|
} => {
|
||||||
let mut path_bindings = path_bindings.write().await;
|
let mut path_bindings = path_bindings.write().await;
|
||||||
if km.source.process != "homepage:homepage:uqbar" {
|
if km.source.process != "homepage:homepage:nectar" {
|
||||||
path = if path.starts_with('/') {
|
path = if path.starts_with('/') {
|
||||||
format!("/{}{}", km.source.process, path)
|
format!("/{}{}", km.source.process, path)
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,7 @@ use std::collections::HashMap;
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
/// HTTP Request type that can be shared over WASM boundary to apps.
|
/// HTTP Request type that can be shared over WASM boundary to apps.
|
||||||
/// This is the one you receive from the `http_server:sys:uqbar` service.
|
/// This is the one you receive from the `http_server:sys:nectar` service.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum HttpServerRequest {
|
pub enum HttpServerRequest {
|
||||||
Http(IncomingHttpRequest),
|
Http(IncomingHttpRequest),
|
||||||
@ -38,7 +38,7 @@ pub struct IncomingHttpRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// HTTP Request type that can be shared over WASM boundary to apps.
|
/// HTTP Request type that can be shared over WASM boundary to apps.
|
||||||
/// This is the one you send to the `http_client:sys:uqbar` service.
|
/// This is the one you send to the `http_client:sys:nectar` service.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct OutgoingHttpRequest {
|
pub struct OutgoingHttpRequest {
|
||||||
pub method: String, // must parse to http::Method
|
pub method: String, // must parse to http::Method
|
||||||
@ -59,7 +59,7 @@ pub struct HttpResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// WebSocket Client Request type that can be shared over WASM boundary to apps.
|
/// WebSocket Client Request type that can be shared over WASM boundary to apps.
|
||||||
/// This is the one you send to the `http_client:sys:uqbar` service.
|
/// This is the one you send to the `http_client:sys:nectar` service.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum WebSocketClientAction {
|
pub enum WebSocketClientAction {
|
||||||
Open {
|
Open {
|
||||||
@ -114,7 +114,7 @@ pub enum WebSocketClientError {
|
|||||||
CloseFailed { channel_id: u32 },
|
CloseFailed { channel_id: u32 },
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Request type sent to `http_server:sys:uqbar` in order to configure it.
|
/// Request type sent to `http_server:sys:nectar` in order to configure it.
|
||||||
/// You can also send [`type@HttpServerAction::WebSocketPush`], which
|
/// You can also send [`type@HttpServerAction::WebSocketPush`], which
|
||||||
/// allows you to push messages across an existing open WebSocket connection.
|
/// allows you to push messages across an existing open WebSocket connection.
|
||||||
///
|
///
|
||||||
|
@ -43,7 +43,7 @@ pub fn auth_cookie_valid(our_node: &str, cookie: &str, jwt_secret: &[u8]) -> boo
|
|||||||
for cookie_part in cookie_parts {
|
for cookie_part in cookie_parts {
|
||||||
let cookie_part_parts: Vec<&str> = cookie_part.split('=').collect();
|
let cookie_part_parts: Vec<&str> = cookie_part.split('=').collect();
|
||||||
if cookie_part_parts.len() == 2
|
if cookie_part_parts.len() == 2
|
||||||
&& cookie_part_parts[0] == format!("uqbar-auth_{}", our_node)
|
&& cookie_part_parts[0] == format!("nectar-auth_{}", our_node)
|
||||||
{
|
{
|
||||||
auth_token = Some(cookie_part_parts[1].to_string());
|
auth_token = Some(cookie_part_parts[1].to_string());
|
||||||
break;
|
break;
|
||||||
|
@ -12,7 +12,7 @@ use wasmtime::{Config, Engine, WasmBacktraceDetails};
|
|||||||
|
|
||||||
/// Manipulate a single process.
|
/// Manipulate a single process.
|
||||||
pub mod process;
|
pub mod process;
|
||||||
/// Implement the functions served to processes by `uqbar.wit`.
|
/// Implement the functions served to processes by `nectar.wit`.
|
||||||
mod standard_host;
|
mod standard_host;
|
||||||
|
|
||||||
const PROCESS_CHANNEL_CAPACITY: usize = 100;
|
const PROCESS_CHANNEL_CAPACITY: usize = 100;
|
||||||
@ -604,7 +604,7 @@ async fn start_process(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the uqbar kernel. contains event loop which handles all message-passing between
|
/// the nectar kernel. contains event loop which handles all message-passing between
|
||||||
/// all processes (WASM apps) and also runtime tasks.
|
/// all processes (WASM apps) and also runtime tasks.
|
||||||
pub async fn kernel(
|
pub async fn kernel(
|
||||||
our: t::Identity,
|
our: t::Identity,
|
||||||
@ -635,7 +635,7 @@ pub async fn kernel(
|
|||||||
|
|
||||||
let mut senders: Senders = HashMap::new();
|
let mut senders: Senders = HashMap::new();
|
||||||
senders.insert(
|
senders.insert(
|
||||||
t::ProcessId::new(Some("net"), "sys", "uqbar"),
|
t::ProcessId::new(Some("net"), "sys", "nectar"),
|
||||||
ProcessSender::Runtime(send_to_net.clone()),
|
ProcessSender::Runtime(send_to_net.clone()),
|
||||||
);
|
);
|
||||||
for (process_id, sender, _) in runtime_extensions {
|
for (process_id, sender, _) in runtime_extensions {
|
||||||
@ -777,7 +777,7 @@ pub async fn kernel(
|
|||||||
.expect("fatal: kernel event loop died");
|
.expect("fatal: kernel event loop died");
|
||||||
|
|
||||||
#[cfg(feature = "simulation-mode")]
|
#[cfg(feature = "simulation-mode")]
|
||||||
let tester_process_id = t::ProcessId::new(Some("tester"), "tester", "uqbar");
|
let tester_process_id = t::ProcessId::new(Some("tester"), "tester", "nectar");
|
||||||
|
|
||||||
// main event loop
|
// main event loop
|
||||||
loop {
|
loop {
|
||||||
|
@ -2,12 +2,12 @@ use crate::kernel::{ProcessMessageReceiver, ProcessMessageSender};
|
|||||||
use crate::types as t;
|
use crate::types as t;
|
||||||
use crate::KERNEL_PROCESS_ID;
|
use crate::KERNEL_PROCESS_ID;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
pub use nectar::process::standard as wit;
|
||||||
|
pub use nectar::process::standard::Host as StandardHost;
|
||||||
use ring::signature::{self, KeyPair};
|
use ring::signature::{self, KeyPair};
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::{HashMap, VecDeque};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
pub use uqbar::process::standard as wit;
|
|
||||||
pub use uqbar::process::standard::Host as StandardHost;
|
|
||||||
use wasmtime::component::*;
|
use wasmtime::component::*;
|
||||||
use wasmtime::{Engine, Store};
|
use wasmtime::{Engine, Store};
|
||||||
use wasmtime_wasi::preview2::{Table, WasiCtx, WasiCtxBuilder, WasiView};
|
use wasmtime_wasi::preview2::{Table, WasiCtx, WasiCtxBuilder, WasiView};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::kernel::process;
|
use crate::kernel::process;
|
||||||
use crate::kernel::process::uqbar::process::standard as wit;
|
use crate::kernel::process::nectar::process::standard as wit;
|
||||||
use crate::kernel::process::StandardHost;
|
use crate::kernel::process::StandardHost;
|
||||||
use crate::types as t;
|
use crate::types as t;
|
||||||
use crate::types::STATE_PROCESS_ID;
|
use crate::types::STATE_PROCESS_ID;
|
||||||
|
22
src/main.rs
22
src/main.rs
@ -91,7 +91,7 @@ async fn serve_register_fe(
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let app = Command::new("Uqbar")
|
let app = Command::new("nectar")
|
||||||
.version(VERSION)
|
.version(VERSION)
|
||||||
.author("Uqbar DAO: https://github.com/uqbar-dao")
|
.author("Uqbar DAO: https://github.com/uqbar-dao")
|
||||||
.about("A General Purpose Sovereign Cloud Computing Platform")
|
.about("A General Purpose Sovereign Cloud Computing Platform")
|
||||||
@ -197,7 +197,7 @@ async fn main() {
|
|||||||
let http_server_port = http::utils::find_open_port(port).await.unwrap();
|
let http_server_port = http::utils::find_open_port(port).await.unwrap();
|
||||||
if http_server_port != port {
|
if http_server_port != port {
|
||||||
let error_message = format!(
|
let error_message = format!(
|
||||||
"uqbar: couldn't bind {}; first available port found {}. Set an available port with `--port` and try again.",
|
"error: couldn't bind {}; first available port found {}. Set an available port with `--port` and try again.",
|
||||||
port,
|
port,
|
||||||
http_server_port,
|
http_server_port,
|
||||||
);
|
);
|
||||||
@ -315,38 +315,38 @@ async fn main() {
|
|||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
let mut runtime_extensions = vec![
|
let mut runtime_extensions = vec![
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("http_server"), "sys", "uqbar"),
|
ProcessId::new(Some("http_server"), "sys", "nectar"),
|
||||||
http_server_sender,
|
http_server_sender,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("http_client"), "sys", "uqbar"),
|
ProcessId::new(Some("http_client"), "sys", "nectar"),
|
||||||
http_client_sender,
|
http_client_sender,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("timer"), "sys", "uqbar"),
|
ProcessId::new(Some("timer"), "sys", "nectar"),
|
||||||
timer_service_sender,
|
timer_service_sender,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("eth"), "sys", "uqbar"),
|
ProcessId::new(Some("eth"), "sys", "nectar"),
|
||||||
eth_provider_sender,
|
eth_provider_sender,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("vfs"), "sys", "uqbar"),
|
ProcessId::new(Some("vfs"), "sys", "nectar"),
|
||||||
vfs_message_sender,
|
vfs_message_sender,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("state"), "sys", "uqbar"),
|
ProcessId::new(Some("state"), "sys", "nectar"),
|
||||||
state_sender,
|
state_sender,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
(ProcessId::new(Some("kv"), "sys", "uqbar"), kv_sender, true),
|
(ProcessId::new(Some("kv"), "sys", "nectar"), kv_sender, true),
|
||||||
(
|
(
|
||||||
ProcessId::new(Some("sqlite"), "sys", "uqbar"),
|
ProcessId::new(Some("sqlite"), "sys", "nectar"),
|
||||||
sqlite_sender,
|
sqlite_sender,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
@ -354,7 +354,7 @@ async fn main() {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* the kernel module will handle our userspace processes and receives
|
* the kernel module will handle our userspace processes and receives
|
||||||
* all "messages", the basic message format for uqbar.
|
* all "messages", the basic message format for nectar.
|
||||||
*
|
*
|
||||||
* if any of these modules fail, the program exits with an error.
|
* if any of these modules fail, the program exits with an error.
|
||||||
*/
|
*/
|
||||||
|
@ -638,7 +638,7 @@ async fn recv_connection(
|
|||||||
noise.read_message(first_message, &mut buf)?;
|
noise.read_message(first_message, &mut buf)?;
|
||||||
|
|
||||||
// -> e, ee, s, es
|
// -> e, ee, s, es
|
||||||
send_uqbar_handshake(
|
send_nectar_handshake(
|
||||||
our,
|
our,
|
||||||
keypair,
|
keypair,
|
||||||
&our_static_key,
|
&our_static_key,
|
||||||
@ -651,7 +651,7 @@ async fn recv_connection(
|
|||||||
|
|
||||||
// <- s, se
|
// <- s, se
|
||||||
let their_handshake =
|
let their_handshake =
|
||||||
recv_uqbar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
|
recv_nectar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
|
||||||
|
|
||||||
// now validate this handshake payload against the QNS PKI
|
// now validate this handshake payload against the QNS PKI
|
||||||
let their_id = pki
|
let their_id = pki
|
||||||
@ -717,7 +717,7 @@ async fn recv_connection_via_router(
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
// -> e, ee, s, es
|
// -> e, ee, s, es
|
||||||
send_uqbar_handshake(
|
send_nectar_handshake(
|
||||||
our,
|
our,
|
||||||
keypair,
|
keypair,
|
||||||
&our_static_key,
|
&our_static_key,
|
||||||
@ -730,7 +730,7 @@ async fn recv_connection_via_router(
|
|||||||
|
|
||||||
// <- s, se
|
// <- s, se
|
||||||
let their_handshake =
|
let their_handshake =
|
||||||
recv_uqbar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
|
recv_nectar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
|
||||||
|
|
||||||
// now validate this handshake payload against the QNS PKI
|
// now validate this handshake payload against the QNS PKI
|
||||||
let their_id = pki
|
let their_id = pki
|
||||||
@ -809,7 +809,7 @@ async fn init_connection(
|
|||||||
|
|
||||||
// <- e, ee, s, es
|
// <- e, ee, s, es
|
||||||
let their_handshake =
|
let their_handshake =
|
||||||
recv_uqbar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
|
recv_nectar_handshake(&mut noise, &mut buf, &mut read_stream, &mut write_stream).await?;
|
||||||
|
|
||||||
// now validate this handshake payload against the QNS PKI
|
// now validate this handshake payload against the QNS PKI
|
||||||
validate_handshake(
|
validate_handshake(
|
||||||
@ -821,7 +821,7 @@ async fn init_connection(
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
// -> s, se
|
// -> s, se
|
||||||
send_uqbar_handshake(
|
send_nectar_handshake(
|
||||||
our,
|
our,
|
||||||
keypair,
|
keypair,
|
||||||
&our_static_key,
|
&our_static_key,
|
||||||
@ -922,7 +922,7 @@ async fn handle_local_message(
|
|||||||
id: km.id,
|
id: km.id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.name.clone(),
|
node: our.name.clone(),
|
||||||
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
|
process: ProcessId::from_str("net:sys:nectar").unwrap(),
|
||||||
},
|
},
|
||||||
target: km.rsvp.unwrap_or(km.source),
|
target: km.rsvp.unwrap_or(km.source),
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
|
@ -59,7 +59,7 @@ pub async fn maintain_connection(
|
|||||||
let mut last_message = std::time::Instant::now();
|
let mut last_message = std::time::Instant::now();
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
recv_result = recv_uqbar_message(&mut conn) => {
|
recv_result = recv_nectar_message(&mut conn) => {
|
||||||
match recv_result {
|
match recv_result {
|
||||||
Ok(km) => {
|
Ok(km) => {
|
||||||
if km.source.node != peer_name {
|
if km.source.node != peer_name {
|
||||||
@ -81,7 +81,7 @@ pub async fn maintain_connection(
|
|||||||
maybe_recv = peer_rx.recv() => {
|
maybe_recv = peer_rx.recv() => {
|
||||||
match maybe_recv {
|
match maybe_recv {
|
||||||
Some(km) => {
|
Some(km) => {
|
||||||
match send_uqbar_message(&km, &mut conn).await {
|
match send_nectar_message(&km, &mut conn).await {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
last_message = std::time::Instant::now();
|
last_message = std::time::Instant::now();
|
||||||
continue
|
continue
|
||||||
@ -209,17 +209,17 @@ pub async fn create_passthrough(
|
|||||||
if !target_peer.routing_for {
|
if !target_peer.routing_for {
|
||||||
return Err(anyhow!("we don't route for that indirect node"));
|
return Err(anyhow!("we don't route for that indirect node"));
|
||||||
}
|
}
|
||||||
// send their net:sys:uqbar process a message, notifying it to create a *matching*
|
// send their net:sys:nectar process a message, notifying it to create a *matching*
|
||||||
// passthrough request, which we can pair with this pending one.
|
// passthrough request, which we can pair with this pending one.
|
||||||
target_peer.sender.send(KernelMessage {
|
target_peer.sender.send(KernelMessage {
|
||||||
id: rand::random(),
|
id: rand::random(),
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.name.clone(),
|
node: our.name.clone(),
|
||||||
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
|
process: ProcessId::from_str("net:sys:nectar").unwrap(),
|
||||||
},
|
},
|
||||||
target: Address {
|
target: Address {
|
||||||
node: to_name.clone(),
|
node: to_name.clone(),
|
||||||
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
|
process: ProcessId::from_str("net:sys:nectar").unwrap(),
|
||||||
},
|
},
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
message: Message::Request(Request {
|
message: Message::Request(Request {
|
||||||
@ -299,7 +299,7 @@ pub fn validate_handshake(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_uqbar_message(km: &KernelMessage, conn: &mut PeerConnection) -> Result<()> {
|
pub async fn send_nectar_message(km: &KernelMessage, conn: &mut PeerConnection) -> Result<()> {
|
||||||
let serialized = rmp_serde::to_vec(km)?;
|
let serialized = rmp_serde::to_vec(km)?;
|
||||||
if serialized.len() > MESSAGE_MAX_SIZE as usize {
|
if serialized.len() > MESSAGE_MAX_SIZE as usize {
|
||||||
return Err(anyhow!("message too large"));
|
return Err(anyhow!("message too large"));
|
||||||
@ -320,13 +320,13 @@ pub async fn send_uqbar_message(km: &KernelMessage, conn: &mut PeerConnection) -
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// any error in receiving a message will result in the connection being closed.
|
/// any error in receiving a message will result in the connection being closed.
|
||||||
pub async fn recv_uqbar_message(conn: &mut PeerConnection) -> Result<KernelMessage> {
|
pub async fn recv_nectar_message(conn: &mut PeerConnection) -> Result<KernelMessage> {
|
||||||
let outer_len = conn.noise.read_message(
|
let outer_len = conn.noise.read_message(
|
||||||
&ws_recv(&mut conn.read_stream, &mut conn.write_stream).await?,
|
&ws_recv(&mut conn.read_stream, &mut conn.write_stream).await?,
|
||||||
&mut conn.buf,
|
&mut conn.buf,
|
||||||
)?;
|
)?;
|
||||||
if outer_len < 4 {
|
if outer_len < 4 {
|
||||||
return Err(anyhow!("uqbar message too small!"));
|
return Err(anyhow!("nectar message too small!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let length_bytes = [conn.buf[0], conn.buf[1], conn.buf[2], conn.buf[3]];
|
let length_bytes = [conn.buf[0], conn.buf[1], conn.buf[2], conn.buf[3]];
|
||||||
@ -349,7 +349,7 @@ pub async fn recv_uqbar_message(conn: &mut PeerConnection) -> Result<KernelMessa
|
|||||||
Ok(rmp_serde::from_slice(&msg)?)
|
Ok(rmp_serde::from_slice(&msg)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_uqbar_handshake(
|
pub async fn send_nectar_handshake(
|
||||||
our: &Identity,
|
our: &Identity,
|
||||||
keypair: &Ed25519KeyPair,
|
keypair: &Ed25519KeyPair,
|
||||||
noise_static_key: &[u8],
|
noise_static_key: &[u8],
|
||||||
@ -373,7 +373,7 @@ pub async fn send_uqbar_handshake(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn recv_uqbar_handshake(
|
pub async fn recv_nectar_handshake(
|
||||||
noise: &mut snow::HandshakeState,
|
noise: &mut snow::HandshakeState,
|
||||||
buf: &mut [u8],
|
buf: &mut [u8],
|
||||||
read_stream: &mut SplitStream<WebSocketStream<MaybeTlsStream<TcpStream>>>,
|
read_stream: &mut SplitStream<WebSocketStream<MaybeTlsStream<TcpStream>>>,
|
||||||
@ -485,7 +485,7 @@ pub async fn parse_hello_message(
|
|||||||
id: km.id,
|
id: km.id,
|
||||||
source: Address {
|
source: Address {
|
||||||
node: our.name.clone(),
|
node: our.name.clone(),
|
||||||
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
|
process: ProcessId::from_str("net:sys:nectar").unwrap(),
|
||||||
},
|
},
|
||||||
target: km.rsvp.as_ref().unwrap_or(&km.source).clone(),
|
target: km.rsvp.as_ref().unwrap_or(&km.source).clone(),
|
||||||
rsvp: None,
|
rsvp: None,
|
||||||
|
File diff suppressed because one or more lines are too long
@ -117,9 +117,9 @@ pub async fn register(
|
|||||||
ws_routing: Some((ip.clone(), ws_port)),
|
ws_routing: Some((ip.clone(), ws_port)),
|
||||||
allowed_routers: vec![
|
allowed_routers: vec![
|
||||||
"nectar-next-router.uq".into(),
|
"nectar-next-router.uq".into(),
|
||||||
// "uqbar-router-1.uq".into(),
|
// "nectar-router-1.uq".into(),
|
||||||
// "uqbar-router-2.uq".into(),
|
// "nectar-router-2.uq".into(),
|
||||||
// "uqbar-router-3.uq".into(),
|
// "nectar-router-3.uq".into(),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -535,7 +535,7 @@ async fn success_response(
|
|||||||
|
|
||||||
let headers = response.headers_mut();
|
let headers = response.headers_mut();
|
||||||
|
|
||||||
match HeaderValue::from_str(&format!("uqbar-auth_{}={};", &our.name, &token)) {
|
match HeaderValue::from_str(&format!("nectar-auth_{}={};", &our.name, &token)) {
|
||||||
Ok(v) => {
|
Ok(v) => {
|
||||||
headers.append(SET_COOKIE, v);
|
headers.append(SET_COOKIE, v);
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ async fn bootstrap(
|
|||||||
let k_cap = Capability {
|
let k_cap = Capability {
|
||||||
issuer: Address {
|
issuer: Address {
|
||||||
node: our_name.to_string(),
|
node: our_name.to_string(),
|
||||||
process: ProcessId::from_str("kernel:sys:uqbar").unwrap(),
|
process: ProcessId::from_str("kernel:sys:nectar").unwrap(),
|
||||||
},
|
},
|
||||||
params: "\"messaging\"".into(),
|
params: "\"messaging\"".into(),
|
||||||
};
|
};
|
||||||
@ -308,7 +308,7 @@ async fn bootstrap(
|
|||||||
let n_cap = Capability {
|
let n_cap = Capability {
|
||||||
issuer: Address {
|
issuer: Address {
|
||||||
node: our_name.to_string(),
|
node: our_name.to_string(),
|
||||||
process: ProcessId::from_str("net:sys:uqbar").unwrap(),
|
process: ProcessId::from_str("net:sys:nectar").unwrap(),
|
||||||
},
|
},
|
||||||
params: "\"messaging\"".into(),
|
params: "\"messaging\"".into(),
|
||||||
};
|
};
|
||||||
@ -336,7 +336,7 @@ async fn bootstrap(
|
|||||||
// finally, save runtime modules in state map as well, somewhat fakely
|
// finally, save runtime modules in state map as well, somewhat fakely
|
||||||
// special cases for kernel and net
|
// special cases for kernel and net
|
||||||
process_map
|
process_map
|
||||||
.entry(ProcessId::from_str("kernel:sys:uqbar").unwrap())
|
.entry(ProcessId::from_str("kernel:sys:nectar").unwrap())
|
||||||
.or_insert(PersistedProcess {
|
.or_insert(PersistedProcess {
|
||||||
wasm_bytes_handle: "".into(),
|
wasm_bytes_handle: "".into(),
|
||||||
wit_version: None,
|
wit_version: None,
|
||||||
@ -345,7 +345,7 @@ async fn bootstrap(
|
|||||||
public: false,
|
public: false,
|
||||||
});
|
});
|
||||||
process_map
|
process_map
|
||||||
.entry(ProcessId::from_str("net:sys:uqbar").unwrap())
|
.entry(ProcessId::from_str("net:sys:nectar").unwrap())
|
||||||
.or_insert(PersistedProcess {
|
.or_insert(PersistedProcess {
|
||||||
wasm_bytes_handle: "".into(),
|
wasm_bytes_handle: "".into(),
|
||||||
wit_version: None,
|
wit_version: None,
|
||||||
|
@ -34,7 +34,7 @@ pub async fn terminal(
|
|||||||
execute!(
|
execute!(
|
||||||
stdout,
|
stdout,
|
||||||
EnableBracketedPaste,
|
EnableBracketedPaste,
|
||||||
terminal::SetTitle(format!("{}@{}", our.name, "uqbar"))
|
terminal::SetTitle(format!("{}@{}", our.name, "nectar"))
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (mut win_cols, mut win_rows) = terminal::size().unwrap();
|
let (mut win_cols, mut win_rows) = terminal::size().unwrap();
|
||||||
@ -131,18 +131,19 @@ pub async fn terminal(
|
|||||||
let mut log_writer = BufWriter::new(log_handle);
|
let mut log_writer = BufWriter::new(log_handle);
|
||||||
|
|
||||||
// use to trigger cleanup if receive signal to kill process
|
// use to trigger cleanup if receive signal to kill process
|
||||||
let mut sigalrm = signal(SignalKind::alarm()).expect("uqbar: failed to set up SIGALRM handler");
|
let mut sigalrm =
|
||||||
let mut sighup = signal(SignalKind::hangup()).expect("uqbar: failed to set up SIGHUP handler");
|
signal(SignalKind::alarm()).expect("nectar: failed to set up SIGALRM handler");
|
||||||
|
let mut sighup = signal(SignalKind::hangup()).expect("nectar: failed to set up SIGHUP handler");
|
||||||
let mut sigint =
|
let mut sigint =
|
||||||
signal(SignalKind::interrupt()).expect("uqbar: failed to set up SIGINT handler");
|
signal(SignalKind::interrupt()).expect("nectar: failed to set up SIGINT handler");
|
||||||
let mut sigpipe = signal(SignalKind::pipe()).expect("uqbar: failed to set up SIGPIPE handler");
|
let mut sigpipe = signal(SignalKind::pipe()).expect("nectar: failed to set up SIGPIPE handler");
|
||||||
let mut sigquit = signal(SignalKind::quit()).expect("uqbar: failed to set up SIGQUIT handler");
|
let mut sigquit = signal(SignalKind::quit()).expect("nectar: failed to set up SIGQUIT handler");
|
||||||
let mut sigterm =
|
let mut sigterm =
|
||||||
signal(SignalKind::terminate()).expect("uqbar: failed to set up SIGTERM handler");
|
signal(SignalKind::terminate()).expect("nectar: failed to set up SIGTERM handler");
|
||||||
let mut sigusr1 =
|
let mut sigusr1 =
|
||||||
signal(SignalKind::user_defined1()).expect("uqbar: failed to set up SIGUSR1 handler");
|
signal(SignalKind::user_defined1()).expect("nectar: failed to set up SIGUSR1 handler");
|
||||||
let mut sigusr2 =
|
let mut sigusr2 =
|
||||||
signal(SignalKind::user_defined2()).expect("uqbar: failed to set up SIGUSR2 handler");
|
signal(SignalKind::user_defined2()).expect("nectar: failed to set up SIGUSR2 handler");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let event = reader.next().fuse();
|
let event = reader.next().fuse();
|
||||||
|
22
src/types.rs
22
src/types.rs
@ -5,16 +5,16 @@ use std::collections::{HashMap, HashSet};
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref ETH_PROCESS_ID: ProcessId = ProcessId::new(Some("eth"), "sys", "uqbar");
|
pub static ref ETH_PROCESS_ID: ProcessId = ProcessId::new(Some("eth"), "sys", "nectar");
|
||||||
pub static ref HTTP_CLIENT_PROCESS_ID: ProcessId = ProcessId::new(Some("http_client"), "sys", "uqbar");
|
pub static ref HTTP_CLIENT_PROCESS_ID: ProcessId = ProcessId::new(Some("http_client"), "sys", "nectar");
|
||||||
pub static ref HTTP_SERVER_PROCESS_ID: ProcessId = ProcessId::new(Some("http_server"), "sys", "uqbar");
|
pub static ref HTTP_SERVER_PROCESS_ID: ProcessId = ProcessId::new(Some("http_server"), "sys", "nectar");
|
||||||
pub static ref KERNEL_PROCESS_ID: ProcessId = ProcessId::new(Some("kernel"), "sys", "uqbar");
|
pub static ref KERNEL_PROCESS_ID: ProcessId = ProcessId::new(Some("kernel"), "sys", "nectar");
|
||||||
pub static ref TERMINAL_PROCESS_ID: ProcessId = ProcessId::new(Some("terminal"), "terminal", "uqbar");
|
pub static ref TERMINAL_PROCESS_ID: ProcessId = ProcessId::new(Some("terminal"), "terminal", "nectar");
|
||||||
pub static ref TIMER_PROCESS_ID: ProcessId = ProcessId::new(Some("timer"), "sys", "uqbar");
|
pub static ref TIMER_PROCESS_ID: ProcessId = ProcessId::new(Some("timer"), "sys", "nectar");
|
||||||
pub static ref VFS_PROCESS_ID: ProcessId = ProcessId::new(Some("vfs"), "sys", "uqbar");
|
pub static ref VFS_PROCESS_ID: ProcessId = ProcessId::new(Some("vfs"), "sys", "nectar");
|
||||||
pub static ref STATE_PROCESS_ID: ProcessId = ProcessId::new(Some("state"), "sys", "uqbar");
|
pub static ref STATE_PROCESS_ID: ProcessId = ProcessId::new(Some("state"), "sys", "nectar");
|
||||||
pub static ref KV_PROCESS_ID: ProcessId = ProcessId::new(Some("kv"), "sys", "uqbar");
|
pub static ref KV_PROCESS_ID: ProcessId = ProcessId::new(Some("kv"), "sys", "nectar");
|
||||||
pub static ref SQLITE_PROCESS_ID: ProcessId = ProcessId::new(Some("sqlite"), "sys", "uqbar");
|
pub static ref SQLITE_PROCESS_ID: ProcessId = ProcessId::new(Some("sqlite"), "sys", "nectar");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -697,7 +697,7 @@ pub type CapMessageSender = tokio::sync::mpsc::Sender<CapMessage>;
|
|||||||
pub type CapMessageReceiver = tokio::sync::mpsc::Receiver<CapMessage>;
|
pub type CapMessageReceiver = tokio::sync::mpsc::Receiver<CapMessage>;
|
||||||
|
|
||||||
//
|
//
|
||||||
// types used for UQI: uqbar's identity system
|
// types used for Nectar's identity system
|
||||||
//
|
//
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
Loading…
Reference in New Issue
Block a user