3 Commits

Author SHA1 Message Date
22e32a5715 working on tilde integration 2025-02-19 14:43:31 -05:00
6bbfb454de working on tild integration 2025-02-19 13:39:17 -05:00
b4e2dd2683 a lot of things are working 2024-09-09 15:34:22 -04:00
14 changed files with 709 additions and 282 deletions

451
Cargo.lock generated
View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 4
[[package]] [[package]]
name = "addr2line" name = "addr2line"
@ -96,6 +96,7 @@ dependencies = [
"futures-lite", "futures-lite",
"num_cpus", "num_cpus",
"once_cell", "once_cell",
"tokio 1.40.0",
] ]
[[package]] [[package]]
@ -112,7 +113,7 @@ dependencies = [
"parking", "parking",
"polling", "polling",
"slab 0.4.6", "slab 0.4.6",
"socket2", "socket2 0.4.10",
"waker-fn", "waker-fn",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -253,7 +254,7 @@ version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi 0.1.19",
"libc", "libc",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -334,6 +335,12 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.7.3" version = "0.7.3"
@ -535,6 +542,22 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]]
name = "core-foundation"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.2" version = "0.2.2"
@ -848,6 +871,21 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]] [[package]]
name = "form_urlencoded" name = "form_urlencoded"
version = "1.0.1" version = "1.0.1"
@ -1165,7 +1203,7 @@ dependencies = [
"http 0.2.8", "http 0.2.8",
"indexmap 2.5.0", "indexmap 2.5.0",
"slab 0.4.6", "slab 0.4.6",
"tokio 1.26.0", "tokio 1.40.0",
"tokio-util 0.7.8", "tokio-util 0.7.8",
"tracing", "tracing",
] ]
@ -1200,6 +1238,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "hermit-abi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]] [[package]]
name = "hex" name = "hex"
version = "0.4.3" version = "0.4.3"
@ -1253,9 +1297,9 @@ dependencies = [
[[package]] [[package]]
name = "httparse" name = "httparse"
version = "1.7.1" version = "1.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9"
[[package]] [[package]]
name = "httpdate" name = "httpdate"
@ -1337,9 +1381,9 @@ dependencies = [
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.14.20" version = "0.14.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9"
dependencies = [ dependencies = [
"bytes 1.1.0", "bytes 1.1.0",
"futures-channel", "futures-channel",
@ -1352,13 +1396,26 @@ dependencies = [
"httpdate", "httpdate",
"itoa 1.0.2", "itoa 1.0.2",
"pin-project-lite", "pin-project-lite",
"socket2", "socket2 0.5.7",
"tokio 1.26.0", "tokio 1.40.0",
"tower-service", "tower-service",
"tracing", "tracing",
"want 0.3.0", "want 0.3.0",
] ]
[[package]]
name = "hyper-tls"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes 1.1.0",
"hyper 0.14.30",
"native-tls",
"tokio 1.40.0",
"tokio-native-tls",
]
[[package]] [[package]]
name = "i2cdev" name = "i2cdev"
version = "0.4.4" version = "0.4.4"
@ -1574,7 +1631,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1dea6e07251d9ce6a552abfb5d7ad6bc290a4596c8dcc3d795fae2bbdc1f3ff" checksum = "e1dea6e07251d9ce6a552abfb5d7ad6bc290a4596c8dcc3d795fae2bbdc1f3ff"
dependencies = [ dependencies = [
"futures 0.3.21", "futures 0.3.21",
"hyper 0.14.20", "hyper 0.14.30",
"jsonrpc-core 18.0.0", "jsonrpc-core 18.0.0",
"jsonrpc-server-utils 18.0.0", "jsonrpc-server-utils 18.0.0",
"log 0.4.17", "log 0.4.17",
@ -1627,7 +1684,7 @@ dependencies = [
"jsonrpc-core 18.0.0", "jsonrpc-core 18.0.0",
"lazy_static", "lazy_static",
"log 0.4.17", "log 0.4.17",
"tokio 1.26.0", "tokio 1.40.0",
"tokio-stream", "tokio-stream",
"tokio-util 0.6.10", "tokio-util 0.6.10",
"unicase", "unicase",
@ -1762,9 +1819,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.126" version = "0.2.158"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
[[package]] [[package]]
name = "libsodium-sys" name = "libsodium-sys"
@ -1967,14 +2024,14 @@ dependencies = [
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.8.4" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
dependencies = [ dependencies = [
"hermit-abi 0.3.9",
"libc", "libc",
"log 0.4.17",
"wasi 0.11.0+wasi-snapshot-preview1", "wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.36.1", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@ -2045,6 +2102,23 @@ dependencies = [
"getrandom 0.2.7", "getrandom 0.2.7",
] ]
[[package]]
name = "native-tls"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466"
dependencies = [
"libc",
"log 0.4.17",
"openssl",
"openssl-probe",
"openssl-sys",
"schannel",
"security-framework",
"security-framework-sys",
"tempfile",
]
[[package]] [[package]]
name = "nb" name = "nb"
version = "0.1.3" version = "0.1.3"
@ -2205,7 +2279,7 @@ version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi 0.1.19",
"libc", "libc",
] ]
@ -2245,6 +2319,50 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "openssl"
version = "0.10.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1"
dependencies = [
"bitflags 2.6.0",
"cfg-if 1.0.0",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2 1.0.86",
"quote 1.0.37",
"syn 2.0.77",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]] [[package]]
name = "parking" name = "parking"
version = "2.0.0" version = "2.0.0"
@ -2365,7 +2483,7 @@ dependencies = [
"serde_json", "serde_json",
"serde_yaml", "serde_yaml",
"sha3", "sha3",
"solar_client", "tilde-client",
"toml", "toml",
] ]
@ -2448,14 +2566,15 @@ dependencies = [
"dirs 4.0.0", "dirs 4.0.0",
"env_logger 0.8.4", "env_logger 0.8.4",
"futures 0.3.21", "futures 0.3.21",
"jsonrpc_client",
"lazy_static", "lazy_static",
"log 0.4.17", "log 0.4.17",
"maud", "maud",
"peach-lib", "peach-lib",
"peach-network", "peach-network",
"peach-stats", "peach-stats",
"reqwest",
"rouille", "rouille",
"solar_client",
"temporary", "temporary",
"vnstat_parse", "vnstat_parse",
"xdg", "xdg",
@ -2475,9 +2594,9 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.9" version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
[[package]] [[package]]
name = "pin-utils" name = "pin-utils"
@ -2874,9 +2993,9 @@ dependencies = [
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.11.18" version = "0.11.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62"
dependencies = [ dependencies = [
"base64 0.21.7", "base64 0.21.7",
"bytes 1.1.0", "bytes 1.1.0",
@ -2886,18 +3005,24 @@ dependencies = [
"h2 0.3.26", "h2 0.3.26",
"http 0.2.8", "http 0.2.8",
"http-body 0.4.5", "http-body 0.4.5",
"hyper 0.14.20", "hyper 0.14.30",
"hyper-tls",
"ipnet", "ipnet",
"js-sys", "js-sys",
"log 0.4.17", "log 0.4.17",
"mime", "mime",
"native-tls",
"once_cell", "once_cell",
"percent-encoding 2.1.0", "percent-encoding 2.1.0",
"pin-project-lite", "pin-project-lite",
"rustls-pemfile",
"serde 1.0.209", "serde 1.0.209",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"tokio 1.26.0", "sync_wrapper",
"system-configuration",
"tokio 1.40.0",
"tokio-native-tls",
"tower-service", "tower-service",
"url 2.3.0", "url 2.3.0",
"wasm-bindgen", "wasm-bindgen",
@ -2972,6 +3097,15 @@ dependencies = [
"semver 1.0.12", "semver 1.0.12",
] ]
[[package]]
name = "rustls-pemfile"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
dependencies = [
"base64 0.21.7",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.10" version = "1.0.10"
@ -2993,6 +3127,15 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "schannel"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b"
dependencies = [
"windows-sys 0.59.0",
]
[[package]] [[package]]
name = "scoped-tls" name = "scoped-tls"
version = "0.1.2" version = "0.1.2"
@ -3005,6 +3148,29 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "security-framework"
version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
dependencies = [
"bitflags 2.6.0",
"core-foundation",
"core-foundation-sys",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework-sys"
version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]] [[package]]
name = "semver" name = "semver"
version = "0.1.20" version = "0.1.20"
@ -3260,22 +3426,22 @@ dependencies = [
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.4.4" version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d"
dependencies = [ dependencies = [
"libc", "libc",
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]] [[package]]
name = "solar_client" name = "socket2"
version = "0.1.0" version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c"
dependencies = [ dependencies = [
"anyhow", "libc",
"jsonrpc_client", "windows-sys 0.52.0",
"reqwest",
"serde_json",
] ]
[[package]] [[package]]
@ -3371,6 +3537,12 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "sync_wrapper"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]] [[package]]
name = "sysfs_gpio" name = "sysfs_gpio"
version = "0.5.4" version = "0.5.4"
@ -3380,6 +3552,27 @@ dependencies = [
"nix 0.14.1", "nix 0.14.1",
] ]
[[package]]
name = "system-configuration"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"system-configuration-sys",
]
[[package]]
name = "system-configuration-sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]] [[package]]
name = "systemstat" name = "systemstat"
version = "0.1.11" version = "0.1.11"
@ -3480,6 +3673,17 @@ dependencies = [
"num_cpus", "num_cpus",
] ]
[[package]]
name = "tilde-client"
version = "0.0.1"
dependencies = [
"anyhow",
"async-std",
"serde 1.0.209",
"serde_json",
"serde_yaml",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.44" version = "0.1.44"
@ -3573,19 +3777,17 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.26.0" version = "1.40.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998"
dependencies = [ dependencies = [
"autocfg 1.1.0", "backtrace",
"bytes 1.1.0", "bytes 1.1.0",
"libc", "libc",
"memchr", "mio 1.0.2",
"mio 0.8.4",
"num_cpus",
"pin-project-lite", "pin-project-lite",
"socket2", "socket2 0.5.7",
"windows-sys 0.45.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@ -3671,6 +3873,16 @@ dependencies = [
"log 0.4.17", "log 0.4.17",
] ]
[[package]]
name = "tokio-native-tls"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
dependencies = [
"native-tls",
"tokio 1.40.0",
]
[[package]] [[package]]
name = "tokio-proto" name = "tokio-proto"
version = "0.1.1" version = "0.1.1"
@ -3725,7 +3937,7 @@ checksum = "df54d54117d6fdc4e4fea40fe1e4e566b3505700e148a6827e59b34b0d2600d9"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"pin-project-lite", "pin-project-lite",
"tokio 1.26.0", "tokio 1.40.0",
] ]
[[package]] [[package]]
@ -3825,7 +4037,7 @@ dependencies = [
"futures-sink", "futures-sink",
"log 0.4.17", "log 0.4.17",
"pin-project-lite", "pin-project-lite",
"tokio 1.26.0", "tokio 1.40.0",
] ]
[[package]] [[package]]
@ -3838,7 +4050,7 @@ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"pin-project-lite", "pin-project-lite",
"tokio 1.26.0", "tokio 1.40.0",
"tracing", "tracing",
] ]
@ -3985,6 +4197,12 @@ dependencies = [
"version_check 0.9.4", "version_check 0.9.4",
] ]
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]] [[package]]
name = "vec_map" name = "vec_map"
version = "0.8.2" version = "0.8.2"
@ -4225,33 +4443,73 @@ dependencies = [
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.45.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [ dependencies = [
"windows-targets", "windows-targets 0.48.5",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets 0.52.6",
] ]
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.42.2" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.42.2", "windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.42.2", "windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.42.2", "windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.42.2", "windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.42.2", "windows_x86_64_msvc 0.48.5",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm 0.52.6",
"windows_aarch64_msvc 0.52.6",
"windows_i686_gnu 0.52.6",
"windows_i686_gnullvm",
"windows_i686_msvc 0.52.6",
"windows_x86_64_gnu 0.52.6",
"windows_x86_64_gnullvm 0.52.6",
"windows_x86_64_msvc 0.52.6",
] ]
[[package]] [[package]]
name = "windows_aarch64_gnullvm" name = "windows_aarch64_gnullvm"
version = "0.42.2" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
@ -4261,9 +4519,15 @@ checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.42.2" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
@ -4273,9 +4537,21 @@ checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.42.2" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
@ -4285,9 +4561,15 @@ checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.42.2" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
@ -4297,15 +4579,27 @@ checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.42.2" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.42.2" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
@ -4315,17 +4609,24 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.42.2" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]] [[package]]
name = "winreg" name = "winreg"
version = "0.10.1" version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
dependencies = [ dependencies = [
"winapi 0.3.9", "cfg-if 1.0.0",
"windows-sys 0.48.0",
] ]
[[package]] [[package]]

View File

@ -9,6 +9,7 @@ members = [
"peach-monitor", "peach-monitor",
"peach-stats", "peach-stats",
"peach-jsonrpc-server", "peach-jsonrpc-server",
"peach-dyndns-updater" "peach-dyndns-updater",
"tilde-client"
] ]

View File

@ -10,7 +10,7 @@ chrono = "0.4"
dirs = "4.0" dirs = "4.0"
fslock="0.1" fslock="0.1"
kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb" } kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb" }
solar_client = { path = "../../solarpub/solar_client" } tilde-client = { path = "../tilde-client" }
jsonrpc-client-core = "0.5" jsonrpc-client-core = "0.5"
jsonrpc-client-http = "0.5" jsonrpc-client-http = "0.5"
jsonrpc-core = "8.0" jsonrpc-core = "8.0"

View File

@ -59,8 +59,8 @@ pub fn get_peach_config_defaults() -> HashMap<String, String> {
("SSB_ADMIN_IDS", ""), ("SSB_ADMIN_IDS", ""),
("ADMIN_PASSWORD_HASH", "47"), ("ADMIN_PASSWORD_HASH", "47"),
("TEMPORARY_PASSWORD_HASH", ""), ("TEMPORARY_PASSWORD_HASH", ""),
("SOLAR_SBOT_DATADIR", "/home/peach/.ssb-solar"), ("TILDE_SBOT_DATADIR", "/home/notplants/.local/share/tildefriends/"),
("SOLAR_SBOT_SERVICE", "solar-sbot.service"), ("TILDE_SBOT_SERVICE", "tilde-sbot.service"),
("PEACH_CONFIGDIR", "/var/lib/peachcloud"), ("PEACH_CONFIGDIR", "/var/lib/peachcloud"),
("PEACH_HOMEDIR", "/home/peach"), ("PEACH_HOMEDIR", "/home/peach"),
("PEACH_WEBDIR", "/usr/share/peach-web"), ("PEACH_WEBDIR", "/usr/share/peach-web"),

View File

@ -13,3 +13,4 @@ pub use jsonrpc_client_core;
pub use jsonrpc_core; pub use jsonrpc_core;
pub use serde_json; pub use serde_json;
pub use serde_yaml; pub use serde_yaml;
pub use tilde_client;

View File

@ -2,7 +2,7 @@
use std::{fs, fs::File, io, io::Write, path::PathBuf, process::Command, str}; use std::{fs, fs::File, io, io::Write, path::PathBuf, process::Command, str};
use std::os::linux::raw::ino_t; use std::os::linux::raw::ino_t;
use solar_client::{Client, SolarClient}; use tilde_client::{TildeClient, get_sbot_client};
use log::debug; use log::debug;
use crate::config_manager; use crate::config_manager;
@ -68,9 +68,10 @@ impl SbotStatus {
// note this command does not need to be run as sudo // note this command does not need to be run as sudo
// because non-privileged users are able to run systemctl show // because non-privileged users are able to run systemctl show
let service_name = config_manager::get_config_value("TILDE_SBOT_SERVICE")?;
let info_output = Command::new("systemctl") let info_output = Command::new("systemctl")
.arg("show") .arg("show")
.arg(config_manager::get_config_value("SOLAR_SBOT_SERVICE")?) .arg(service_name)
.arg("--no-page") .arg("--no-page")
.output()?; .output()?;
@ -92,7 +93,7 @@ impl SbotStatus {
// because non-privileged users are able to run systemctl status // because non-privileged users are able to run systemctl status
let status_output = Command::new("systemctl") let status_output = Command::new("systemctl")
.arg("status") .arg("status")
.arg(config_manager::get_config_value("SOLAR_SBOT_SERVICE")?) .arg(config_manager::get_config_value("TILDE_SBOT_SERVICE")?)
.output()?; .output()?;
let service_status = str::from_utf8(&status_output.stdout)?; let service_status = str::from_utf8(&status_output.stdout)?;
@ -130,10 +131,15 @@ impl SbotStatus {
} }
} }
// TOOD restore this
// get path to blobstore // get path to blobstore
// let blobstore_path = format!(
// "{}/blobs/sha256",
// config_manager::get_config_value("TILDE_SBOT_DATADIR")?
// );
let blobstore_path = format!( let blobstore_path = format!(
"{}/blobs/sha256", "{}",
config_manager::get_config_value("SOLAR_SBOT_DATADIR")? config_manager::get_config_value("TILDE_SBOT_DATADIR")?
); );
// determine the size of the blobstore directory in bytes // determine the size of the blobstore directory in bytes
@ -265,7 +271,7 @@ impl SbotConfig {
} }
/// Initialise an sbot client /// Initialise an sbot client
pub async fn init_sbot() -> Result<Client, PeachError> { pub async fn init_sbot() -> Result<TildeClient, PeachError> {
// read sbot config from config.toml // read sbot config from config.toml
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
@ -277,6 +283,6 @@ pub async fn init_sbot() -> Result<Client, PeachError> {
); );
// TODO: read this from config // TODO: read this from config
const SERVER_ADDR: &str = "http://127.0.0.1:3030"; const SERVER_ADDR: &str = "http://127.0.0.1:3030";
let sbot_client = Client::new(SERVER_ADDR.to_owned())?; let sbot_client = get_sbot_client();
Ok(sbot_client) Ok(sbot_client)
} }

View File

@ -33,13 +33,12 @@ travis-ci = { repository = "peachcloud/peach-web", branch = "master" }
maintenance = { status = "actively-developed" } maintenance = { status = "actively-developed" }
[dependencies] [dependencies]
async-std = "1.10" async-std = { version = "1", features=["attributes", "tokio1"] }
base64 = "0.13" base64 = "0.13"
chrono = "0.4" chrono = "0.4"
dirs = "4.0" dirs = "4.0"
env_logger = "0.8" env_logger = "0.8"
futures = "0.3" futures = "0.3"
solar_client = { path = "../../solarpub/solar_client" }
lazy_static = "1.4" lazy_static = "1.4"
log = "0.4" log = "0.4"
maud = "0.23" maud = "0.23"
@ -50,3 +49,5 @@ rouille = { version = "3.5", default-features = false }
temporary = "0.6" temporary = "0.6"
vnstat_parse = "0.1.0" vnstat_parse = "0.1.0"
xdg = "2.2" xdg = "2.2"
jsonrpc_client = { version = "0.7", features = ["macros", "reqwest"] }
reqwest = "0.11.24"

View File

@ -84,4 +84,3 @@ impl From<YamlError> for PeachWebError {
PeachWebError::Yaml(err) PeachWebError::Yaml(err)
} }
} }

View File

@ -16,10 +16,10 @@ use peach_lib::config_manager;
use peach_lib::sbot::SbotConfig; use peach_lib::sbot::SbotConfig;
use peach_lib::sbot::init_sbot; use peach_lib::sbot::init_sbot;
use peach_lib::ssb_messages::SsbMessageKVT; use peach_lib::ssb_messages::SsbMessageKVT;
use solar_client::{Client, SolarClient};
use rouille::input::post::BufferedFile; use rouille::input::post::BufferedFile;
use temporary::Directory; use temporary::Directory;
use peach_lib::serde_json::json; use peach_lib::serde_json::json;
use peach_lib::tilde_client::TildeClient;
use crate::{error::PeachWebError, utils::sbot}; use crate::{error::PeachWebError, utils::sbot};
// SBOT HELPER FUNCTIONS // SBOT HELPER FUNCTIONS
@ -29,7 +29,7 @@ pub fn systemctl_sbot_cmd(cmd: &str) -> Result<Output, PeachWebError> {
let output = Command::new("sudo") let output = Command::new("sudo")
.arg("systemctl") .arg("systemctl")
.arg(cmd) .arg(cmd)
.arg(config_manager::get_config_value("SOLAR_SBOT_SERVICE")?) .arg(config_manager::get_config_value("TILDE_SBOT_SERVICE")?)
.output()?; .output()?;
Ok(output) Ok(output)
} }
@ -64,14 +64,12 @@ pub fn restart_sbot_process() -> (String, String) {
} }
/// Initialise an sbot client with the given configuration parameters. /// Initialise an sbot client with the given configuration parameters.
pub async fn init_sbot_with_config( pub async fn init_sbot_client() -> Result<TildeClient, PeachWebError> {
sbot_config: &Option<SbotConfig>,
) -> Result<Client, PeachWebError> {
debug!("Initialising an sbot client with configuration parameters"); debug!("Initialising an sbot client with configuration parameters");
// initialise sbot connection with ip:port and shscap from config file // initialise sbot connection with ip:port and shscap from config file
let key_path = format!( let key_path = format!(
"{}/secret", "{}/secret.toml",
config_manager::get_config_value("GO_SBOT_DATADIR")? config_manager::get_config_value("TILDE_SBOT_DATADIR")?
); );
let sbot_client = init_sbot().await?; let sbot_client = init_sbot().await?;
Ok(sbot_client) Ok(sbot_client)
@ -121,7 +119,7 @@ pub fn latest_sequence_number() -> Result<u64, PeachWebError> {
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config).await?; let mut sbot_client = init_sbot_client().await?;
Err(PeachWebError::NotYetImplemented) Err(PeachWebError::NotYetImplemented)
@ -150,7 +148,7 @@ pub fn create_invite(uses: u16) -> Result<String, PeachWebError> {
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config).await?; let mut sbot_client = init_sbot_client().await?;
debug!("Generating Scuttlebutt invite code"); debug!("Generating Scuttlebutt invite code");
Err(PeachWebError::NotYetImplemented) Err(PeachWebError::NotYetImplemented)
@ -201,54 +199,52 @@ impl Profile {
} }
/// Retrieve the profile info for the given public key. /// Retrieve the profile info for the given public key.
pub fn get_profile_info(ssb_id: Option<String>) -> Result<Profile, PeachWebError> { pub fn get_profile_info(ssb_id: Option<String>) -> Result<Profile, Box<dyn Error>> {
// retrieve latest solar-sbot configuration parameters
let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config).await?; let sbot_client = init_sbot_client().await?;
Err(PeachWebError::NotYetImplemented) let local_id = sbot_client.whoami().await?;
// let local_id = sbot_client.whoami().await?;
// let mut profile = Profile::default();
// let mut profile = Profile::default();
// // if an ssb_id has been provided, we assume that the profile info
// // if an ssb_id has been provided, we assume that the profile info // being retrieved is for a peer (ie. not for our local profile)
// // being retrieved is for a peer (ie. not for our local profile) let id = if let Some(peer_id) = ssb_id {
// let id = if let Some(peer_id) = ssb_id { // we are not dealing with the local profile
// // we are not dealing with the local profile profile.is_local_profile = false;
// profile.is_local_profile = false;
// // query follow state
// // query follow state profile.following = Some(sbot_client.is_following(&local_id, &peer_id).await?);
// profile.following = Some(sbot_client.is_following(&local_id, &peer_id).await?);
// // TODO: implement this check in solar_client so that this can be a real value
// // TODO: implement this check in solar_client so that this can be a real value profile.blocking = Some(false);
// profile.blocking = Some(false);
// peer_id
// peer_id } else {
// } else { // if an ssb_id has not been provided, retrieve the local id using whoami
// // if an ssb_id has not been provided, retrieve the local id using whoami profile.is_local_profile = true;
// profile.is_local_profile = true;
// local_id
// local_id };
// };
// // retrieve the profile info for the given id
// // retrieve the profile info for the given id let info = get_peer_info(&id).await?;
// let info = sbot_client.get_profile_info(&id).await?; // set each profile field accordingly
// // set each profile field accordingly for (key, val) in info {
// for (key, val) in info { match key.as_str() {
// match key.as_str() { "name" => profile.name = Some(val),
// "name" => profile.name = Some(val), "description" => profile.description = Some(val),
// "description" => profile.description = Some(val), "image" => profile.image = Some(val),
// "image" => profile.image = Some(val), _ => (),
// _ => (), }
// } }
// }
//
// // assign the ssb public key
// // (could be for the local profile or a peer)
// profile.id = Some(id);
// //
// assign the ssb public key
// (could be for the local profile or a peer)
profile.id = Some(id);
// TODO: blobs support
// // determine the path to the blob defined by the value of `profile.image` // // determine the path to the blob defined by the value of `profile.image`
// if let Some(ref blob_id) = profile.image { // if let Some(ref blob_id) = profile.image {
// profile.blob_path = match blobs::get_blob_path(blob_id) { // profile.blob_path = match blobs::get_blob_path(blob_id) {
@ -264,8 +260,8 @@ pub fn get_profile_info(ssb_id: Option<String>) -> Result<Profile, PeachWebError
// Err(_) => None, // Err(_) => None,
// } // }
// } // }
//
// Ok(profile) Ok(profile)
}) })
} }
@ -283,7 +279,7 @@ pub fn update_profile_info(
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config) let mut sbot_client = init_sbot_client()
.await?; .await?;
Err(PeachWebError::NotYetImplemented) Err(PeachWebError::NotYetImplemented)
@ -348,20 +344,16 @@ pub fn update_profile_info(
} }
/// Follow a peer. /// Follow a peer.
pub fn follow_peer(public_key: &str) -> Result<String, String> { pub fn follow_peer(public_key: &str) -> Result<String, PeachWebError> {
// retrieve latest solar-sbot configuration parameters // retrieve latest solar-sbot configuration parameters
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config) let mut sbot_client = init_sbot_client()
.await .await?;
.map_err(|e| e.to_string())?;
debug!("Following a Scuttlebutt peer"); debug!("Following a Scuttlebutt peer");
match sbot_client.follows(public_key).await { Err(PeachWebError::NotYetImplemented)
Ok(_) => Ok("Followed peer".to_string()),
Err(e) => Err(format!("Failed to follow peer: {}", e)),
}
}) })
} }
@ -371,7 +363,7 @@ pub fn unfollow_peer(public_key: &str) -> Result<String, PeachWebError> {
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config) let mut sbot_client = init_sbot_client()
.await?; .await?;
Err(PeachWebError::NotYetImplemented) Err(PeachWebError::NotYetImplemented)
@ -389,12 +381,12 @@ pub fn block_peer(public_key: &str) -> Result<String, String> {
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config) let mut sbot_client = init_sbot_client()
.await .await
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
debug!("Blocking a Scuttlebutt peer"); debug!("Blocking a Scuttlebutt peer");
match sbot_client.blocks(public_key).await { match sbot_client.create_block(public_key).await {
Ok(_) => Ok("Blocked peer".to_string()), Ok(_) => Ok("Blocked peer".to_string()),
Err(e) => Err(format!("Failed to block peer: {}", e)), Err(e) => Err(format!("Failed to block peer: {}", e)),
} }
@ -407,7 +399,7 @@ pub fn unblock_peer(public_key: &str) -> Result<String, PeachWebError> {
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config) let mut sbot_client = init_sbot_client()
.await?; .await?;
debug!("Unblocking a Scuttlebutt peer"); debug!("Unblocking a Scuttlebutt peer");
@ -420,147 +412,131 @@ pub fn unblock_peer(public_key: &str) -> Result<String, PeachWebError> {
} }
/// Retrieve a list of peers blocked by the local public key. /// Retrieve a list of peers blocked by the local public key.
pub fn get_blocks_list() -> Result<Vec<HashMap<String, String>>, PeachWebError> { pub fn get_blocks_list() -> Result<Vec<HashMap<String, String>>, Box<dyn Error>> {
// retrieve latest solar-sbot configuration parameters // populate this vec to return
let sbot_config = SbotConfig::read().ok(); let mut to_return: Vec<HashMap<String, String>> = Vec::new();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config).await?; let mut sbot_client = init_sbot_client().await?;
Err(PeachWebError::NotYetImplemented) let self_id = sbot_client.whoami().await?;
// let blocks = sbot_client.get_blocks().await?;
// let blocks = sbot_client.get_blocks(&self_id).await?;
// // we'll use this to store the profile info for each peer whom we block
// let mut peer_list = Vec::new(); if !blocks.is_empty() {
// for peer in blocks.iter() {
// if !blocks.is_empty() { // trim whitespace (including newline characters) and
// for peer in blocks.iter() { // remove the inverted-commas around the id
// // trim whitespace (including newline characters) and // TODO: is this necessary?
// // remove the inverted-commas around the id let key = peer.trim().replace('"', "");
// let key = peer.trim().replace('"', ""); let peer_info = get_peer_info(&key).await?;
// // retrieve the profile info for the given peer
// let mut peer_info = sbot_client.get_profile_info(&key).await?; // push profile info to peer_list vec
// // insert the public key of the peer into the info hashmap to_return.push(peer_info)
// peer_info.insert("id".to_string(), key.to_string()); }
// // we do not even attempt to find the blob for a blocked peer, }
// // since it may be vulgar to cause distress to the local peer.
// peer_info.insert("blob_exists".to_string(), "false".to_string()); // return the list of peers
// // push profile info to peer_list vec Ok(to_return)
// peer_list.push(peer_info)
// }
// }
//
// // return the list of blocked peers
// Ok(peer_list)
}) })
} }
pub async fn get_peer_info(key: &str) -> Result<HashMap<String, String>, Box<dyn Error>> {
let mut sbot_client = init_sbot_client().await?;
// key,value dict of info about this peer
let mut peer_info = HashMap::new();
// retrieve the profile info for the given peer
// TODO: get all profile info not just latest_name
// TODO: latest_name throws an error
// TODO: just show as "error" isntead of aborting, if some field doesn't fetch
// let latest_name = sbot_client.latest_name(&key).await?;
let latest_name = "latest name".to_string();
if let Some(latest_description) = sbot_client.latest_description(&key).await.ok() {
peer_info.insert("description".to_string(), latest_description);
}
// insert the public key of the peer into the info hashmap
peer_info.insert("id".to_string(), key.to_string());
peer_info.insert("name".to_string(), latest_name);
// retrieve the profile image blob id for the given peer
// TODO: blob support
// if let Some(blob_id) = peer_info.get("image") {
// // look-up the path for the image blob
// if let Ok(blob_path) = blobs::get_blob_path(blob_id) {
// // insert the image blob path of the peer into the info hashmap
// peer_info.insert("blob_path".to_string(), blob_path.to_string());
// // check if the blob is in the blobstore
// // set a flag in the info hashmap
// match blob_is_stored_locally(&blob_path).await {
// Ok(exists) if exists => {
// peer_info.insert("blob_exists".to_string(), "true".to_string())
// }
// _ => peer_info.insert("blob_exists".to_string(), "false".to_string()),
// };
// }
// }
Ok(peer_info)
}
/// Retrieve a list of peers followed by the local public key. /// Retrieve a list of peers followed by the local public key.
pub fn get_follows_list() -> Result<Vec<HashMap<String, String>>, PeachWebError> { pub fn get_follows_list() -> Result<Vec<HashMap<String, String>>, Box<dyn Error>> {
// retrieve latest solar-sbot configuration parameters
let sbot_config = SbotConfig::read().ok(); // populate this vec to return
let mut to_return: Vec<HashMap<String, String>> = Vec::new();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config).await?; let mut sbot_client = init_sbot_client().await?;
Err(PeachWebError::NotYetImplemented) let self_id = sbot_client.whoami().await?;
// let follows = sbot_client.get_follows().await?; let follows = sbot_client.get_follows(&self_id).await?;
//
// // we'll use this to store the profile info for each peer who follows us if !follows.is_empty() {
// let mut peer_list = Vec::new(); for peer in follows.iter() {
// // trim whitespace (including newline characters) and
// if !follows.is_empty() { // remove the inverted-commas around the id
// for peer in follows.iter() { // TODO: is this necessary?
// // trim whitespace (including newline characters) and let key = peer.trim().replace('"', "");
// // remove the inverted-commas around the id let peer_info = get_peer_info(&key).await?;
// let key = peer.trim().replace('"', "");
// // retrieve the profile info for the given peer // push profile info to peer_list vec
// let mut peer_info = sbot_client.get_profile_info(&key).await?; to_return.push(peer_info)
// // insert the public key of the peer into the info hashmap }
// peer_info.insert("id".to_string(), key.to_string()); }
// // retrieve the profile image blob id for the given peer
// if let Some(blob_id) = peer_info.get("image") { // return the list of peers
// // look-up the path for the image blob Ok(to_return)
// if let Ok(blob_path) = blobs::get_blob_path(blob_id) {
// // insert the image blob path of the peer into the info hashmap
// peer_info.insert("blob_path".to_string(), blob_path.to_string());
// // check if the blob is in the blobstore
// // set a flag in the info hashmap
// match blob_is_stored_locally(&blob_path).await {
// Ok(exists) if exists => {
// peer_info.insert("blob_exists".to_string(), "true".to_string())
// }
// _ => peer_info.insert("blob_exists".to_string(), "false".to_string()),
// };
// }
// }
// // push profile info to peer_list vec
// peer_list.push(peer_info)
// }
// }
//
// // return the list of peers
// Ok(peer_list)
}) })
} }
/// Retrieve a list of peers friended by the local public key. /// Retrieve a list of peers friended by the local public key.
pub fn get_friends_list() -> Result<Vec<HashMap<String, String>>, PeachWebError> { pub fn get_friends_list() -> Result<Vec<HashMap<String, String>>, Box<dyn Error>> {
// retrieve latest solar-sbot configuration parameters
let sbot_config = SbotConfig::read().ok(); // populate this vec to return
let mut to_return: Vec<HashMap<String, String>> = Vec::new();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config).await?; let mut sbot_client = init_sbot_client().await?;
Err(PeachWebError::NotYetImplemented) let self_id = sbot_client.whoami().await?;
// let local_id = sbot_client.whoami().await?; let friends = sbot_client.get_friends(&self_id).await?;
//
// let follows = sbot_client.get_follows().await?; if !friends.is_empty() {
// for peer in friends.iter() {
// // we'll use this to store the profile info for each friend // trim whitespace (including newline characters) and
// let mut peer_list = Vec::new(); // remove the inverted-commas around the id
// // TODO: is this necessary?
// if !follows.is_empty() { let key = peer.trim().replace('"', "");
// for peer in follows.iter() { let peer_info = get_peer_info(&key).await?;
// // trim whitespace (including newline characters) and
// // remove the inverted-commas around the id // push profile info to peer_list vec
// let peer_id = peer.trim().replace('"', ""); to_return.push(peer_info)
// // retrieve the profile info for the given peer }
// let mut peer_info = sbot_client.get_profile_info(&peer_id).await?; }
// // insert the public key of the peer into the info hashmap
// peer_info.insert("id".to_string(), peer_id.to_string()); // return the list of peers
// // retrieve the profile image blob id for the given peer Ok(to_return)
// if let Some(blob_id) = peer_info.get("image") {
// // look-up the path for the image blob
// if let Ok(blob_path) = blobs::get_blob_path(blob_id) {
// // insert the image blob path of the peer into the info hashmap
// peer_info.insert("blob_path".to_string(), blob_path.to_string());
// // check if the blob is in the blobstore
// // set a flag in the info hashmap
// match sbot::blob_is_stored_locally(&blob_path).await {
// Ok(exists) if exists => {
// peer_info.insert("blob_exists".to_string(), "true".to_string())
// }
// _ => peer_info.insert("blob_exists".to_string(), "false".to_string()),
// };
// }
// }
//
// // query follow state
// match sbot_client.is_following(peer.id, local_id).await {
// Ok(true) => {
// // only push profile info to peer_list vec if they follow us
// peer_list.push(peer_info)
// }
// _ => (),
// };
// }
// }
//
// // return the list of peers
// Ok(peer_list)
}) })
} }
@ -570,7 +546,7 @@ pub fn get_local_id() -> Result<String, Box<dyn Error>> {
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config).await?; let mut sbot_client = init_sbot_client().await?;
let local_id = sbot_client.whoami().await?; let local_id = sbot_client.whoami().await?;
@ -584,7 +560,7 @@ pub fn publish_public_post(text: String) -> Result<String, String> {
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config) let mut sbot_client = init_sbot_client()
.await .await
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
@ -606,7 +582,7 @@ pub fn publish_private_msg(text: String, recipients: Vec<String>) -> Result<Stri
let sbot_config = SbotConfig::read().ok(); let sbot_config = SbotConfig::read().ok();
task::block_on(async { task::block_on(async {
let mut sbot_client = init_sbot_with_config(&sbot_config) let mut sbot_client = init_sbot_client()
.await?; .await?;
Err(PeachWebError::NotYetImplemented) Err(PeachWebError::NotYetImplemented)

2
tilde-client/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
Cargo.lock

12
tilde-client/Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "tilde-client"
version = "0.0.1"
authors = ["Max Fowler <max@mfowler.info>"]
edition = "2018"
[dependencies]
async-std = "1.10"
anyhow = "1.0.86"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.8"

37
tilde-client/README.md Normal file
View File

@ -0,0 +1,37 @@
# peach-lib
![Generic badge](https://img.shields.io/badge/version-1.2.9-<COLOR>.svg)
JSON-RPC client library for the PeachCloud ecosystem.
`peach-lib` offers the ability to programmatically interact with the `peach-network`, `peach-oled` and `peach-stats` microservices.
## Overview
The `peach-lib` crate bundles JSON-RPC client code for making requests to the three PeachCloud microservices which expose JSON-RPC servers (`peach-network`, `peach-oled` and `peach-menu`). The full list of available RPC APIs can be found in the READMEs of the respective microservices ([peach-network](https://github.com/peachcloud/peach-network), [peach-oled](https://github.com/peachcloud/peach-oled), [peach-menu](https://github.com/peachcloud/peach-menu)), or in the [developer documentation for PeachCloud](http://docs.peachcloud.org/software/microservices/index.html).
The library also includes a custom error type, `PeachError`, which bundles the underlying error types into three variants: `JsonRpcHttp`, `JsonRpcCore` and `Serde`. When used as the returned error type in a `Result` function response, this allows convenient use of the `?` operator (as illustrated in the example usage code below).
## Usage
Define the dependency in your `Cargo.toml` file:
`peach-lib = { git = "https://github.com/peachcloud/peach-lib", branch = "main" }`
Import the required client from the library:
```rust
use peach_lib::network_client;
```
Call one of the exposed methods:
```rust
network_client::ip("wlan0")?;
```
Further example usage can be found in the [`peach-menu`](https://github.com/peachcloud/peach-menu) code (see `src/states.rs`).
## Licensing
AGPL-3.0

18
tilde-client/src/error.rs Normal file
View File

@ -0,0 +1,18 @@
#![warn(missing_docs)]
use std::error::Error;
use std::fmt;
/// all tilde client errors
#[derive(Debug)]
pub struct TildeError {
pub(crate) message: String,
}
impl fmt::Display for TildeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.message)
}
}
impl Error for TildeError {}

73
tilde-client/src/lib.rs Normal file
View File

@ -0,0 +1,73 @@
// methods for interacting with tilde sbot
use crate::error::TildeError;
use serde_json::Value;
use std::process::{Command, exit};
mod error;
pub struct TildeClient {
name: String,
port: String
}
pub fn init_sbot() {
println!("++ init sbot!");
}
pub fn get_sbot_client() -> TildeClient {
TildeClient {
name: "name".to_string(),
port: "8009".to_string()
}
}
impl TildeClient {
pub fn run_tilde_command(&self, command: &str) -> Result<String, TildeError> {
let output = Command::new("out/release/tildefriends.standalone")
.arg(command)
.output().map_err(|e| TildeError {
message: format!("Command execution failed: {}", e),
})?;
if !output.status.success() {
return Err(TildeError { message: format!("Command failed with status: {}", output.status) })
}
let result = String::from_utf8_lossy(&output.stdout).to_string();
println!("Command output: {}", result);
Ok(result)
}
pub async fn latest_description(&self, key: &str) -> Result<String, TildeError> {
todo!();
}
pub async fn whoami(&self) -> Result<String, TildeError> {
self.run_tilde_command("get_identity")
}
pub async fn is_following(&self, from_id: &str, to_id: &str) -> Result<bool, TildeError> {
todo!();
}
pub async fn create_block(&self, key: &str) -> Result<bool, TildeError> {
todo!();
}
pub async fn get_blocks(&self, key: &str) -> Result<Vec<String>, TildeError> {
todo!();
}
pub async fn get_follows(&self, key: &str) -> Result<Vec<String>, TildeError> {
todo!();
}
pub async fn get_friends(&self, key: &str) -> Result<Vec<String>, TildeError> {
todo!();
}
pub async fn publish(&self, post: Value) -> Result<Vec<String>, TildeError> {
todo!();
}
}