Compare commits
No commits in common. "06f4ebf47f88cd79cb9d9a13753552bc61e579e4" and "e9f9e35c9d4283c4f6d766660bf415ccd7978eae" have entirely different histories.
06f4ebf47f
...
e9f9e35c9d
4 changed files with 6 additions and 16 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{borrow::Cow, collections::BTreeSet};
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
|
@ -11,7 +11,6 @@ pub struct RelayServer {
|
||||||
pub db_users: sled::Tree,
|
pub db_users: sled::Tree,
|
||||||
pub db_index_cursors: sled::Tree,
|
pub db_index_cursors: sled::Tree,
|
||||||
|
|
||||||
pub plc_resolver: Cow<'static, str>,
|
|
||||||
pub known_good_hosts: Mutex<BTreeSet<String>>,
|
pub known_good_hosts: Mutex<BTreeSet<String>>,
|
||||||
pub active_indexers: Mutex<BTreeSet<String>>,
|
pub active_indexers: Mutex<BTreeSet<String>>,
|
||||||
|
|
||||||
|
|
@ -33,7 +32,6 @@ impl RelayServer {
|
||||||
event_tx,
|
event_tx,
|
||||||
raw_block_tx,
|
raw_block_tx,
|
||||||
|
|
||||||
plc_resolver: Cow::Borrowed("plc.directory"),
|
|
||||||
known_good_hosts: Mutex::new(hosts.into_iter().collect()),
|
known_good_hosts: Mutex::new(hosts.into_iter().collect()),
|
||||||
active_indexers: Default::default(),
|
active_indexers: Default::default(),
|
||||||
|
|
||||||
|
|
|
||||||
13
src/main.rs
13
src/main.rs
|
|
@ -1,6 +1,6 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::{borrow::Cow, net::SocketAddr, str::FromStr, sync::Arc};
|
use std::{net::SocketAddr, str::FromStr, sync::Arc};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
||||||
|
|
||||||
|
|
@ -21,10 +21,6 @@ struct Args {
|
||||||
/// Database RAM cache capacity in megabytes
|
/// Database RAM cache capacity in megabytes
|
||||||
#[arg(long, default_value_t = 1024)]
|
#[arg(long, default_value_t = 1024)]
|
||||||
cache_capacity: u64,
|
cache_capacity: u64,
|
||||||
|
|
||||||
/// did:plc directory HTTPS host. defaults to plc.directory if unset
|
|
||||||
#[arg(long)]
|
|
||||||
plc_resolver: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
@ -45,12 +41,7 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
let (event_tx, event_rx) = mpsc::channel(128);
|
let (event_tx, event_rx) = mpsc::channel(128);
|
||||||
|
|
||||||
let mut server = RelayServer::new(db, event_tx);
|
let server = Arc::new(RelayServer::new(db, event_tx));
|
||||||
if let Some(plc_directory) = args.plc_resolver {
|
|
||||||
server.plc_resolver = Cow::Owned(plc_directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
let server = Arc::new(server);
|
|
||||||
let initial_hosts: Vec<String> = {
|
let initial_hosts: Vec<String> = {
|
||||||
let hosts = server.known_good_hosts.lock().await;
|
let hosts = server.known_good_hosts.lock().await;
|
||||||
hosts.iter().cloned().collect()
|
hosts.iter().cloned().collect()
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use http_body_util::BodyExt;
|
||||||
use hyper::{body::Incoming, Request, Response};
|
use hyper::{body::Incoming, Request, Response};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
http::{body_full, ServerResponse},
|
http::{body_empty, body_full, ServerResponse},
|
||||||
indexer::index_server,
|
indexer::index_server,
|
||||||
RelayServer,
|
RelayServer,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,8 @@ fn create_user_from_did_doc(did_doc: DidDocument) -> Result<User> {
|
||||||
pub async fn fetch_user(server: &RelayServer, did: &str) -> Result<User> {
|
pub async fn fetch_user(server: &RelayServer, did: &str) -> Result<User> {
|
||||||
tracing::debug!(%did, "fetching user");
|
tracing::debug!(%did, "fetching user");
|
||||||
if did.starts_with("did:plc:") {
|
if did.starts_with("did:plc:") {
|
||||||
let domain: &str = &server.plc_resolver;
|
// TODO: configurable plc resolver location
|
||||||
|
let domain = "plc.directory";
|
||||||
|
|
||||||
let tcp_stream = TcpStream::connect((domain, 443)).await?;
|
let tcp_stream = TcpStream::connect((domain, 443)).await?;
|
||||||
let domain_tls: ServerName<'_> = ServerName::try_from(domain.to_string())?;
|
let domain_tls: ServerName<'_> = ServerName::try_from(domain.to_string())?;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue