diff --git a/.gitignore b/.gitignore index 1596390..a62c7a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/target +**/target/ nostr.db diff --git a/README.md b/README.md index 4af884e..e394c81 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ settings. For examples of putting the relay behind a reverse proxy (for TLS termination, load balancing, and other features), see [Reverse -Proxy](reverse-proxy.md). +Proxy](docs/reverse-proxy.md). ## Dev Channel diff --git a/reverse-proxy.md b/docs/reverse-proxy.md similarity index 97% rename from reverse-proxy.md rename to docs/reverse-proxy.md index 1737eec..c8d0221 100644 --- a/reverse-proxy.md +++ b/docs/reverse-proxy.md @@ -104,7 +104,7 @@ http { ### Nginx Notes -The above configuration was tested on `nginx` `1.18.0` was tested on `Ubuntu 20.04`. +The above configuration was tested on `nginx` `1.18.0` on `Ubuntu` `20.04` and `22.04` For help installing `nginx` on `Ubuntu`, see [this guide](https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04). diff --git a/nauthz_server_example/Cargo.lock b/examples/nauthz/Cargo.lock similarity index 100% rename from nauthz_server_example/Cargo.lock rename to examples/nauthz/Cargo.lock diff --git a/nauthz_server_example/Cargo.toml b/examples/nauthz/Cargo.toml similarity index 100% rename from nauthz_server_example/Cargo.toml rename to examples/nauthz/Cargo.toml diff --git a/nauthz_server_example/build.rs b/examples/nauthz/build.rs similarity index 65% rename from nauthz_server_example/build.rs rename to examples/nauthz/build.rs index ef72247..5bc38a9 100644 --- a/nauthz_server_example/build.rs +++ b/examples/nauthz/build.rs @@ -2,9 +2,6 @@ fn main() -> Result<(), Box> { tonic_build::configure() .build_server(false) .protoc_arg("--experimental_allow_proto3_optional") - .compile( - &["../proto/nauthz.proto"], - &["../proto"], - )?; + .compile(&["../../proto/nauthz.proto"], &["../../proto"])?; Ok(()) -} \ No newline at end of file +} diff --git a/nauthz_server_example/src/main.rs b/examples/nauthz/src/main.rs similarity index 83% rename from nauthz_server_example/src/main.rs rename to examples/nauthz/src/main.rs index df5de84..4778181 100644 --- a/nauthz_server_example/src/main.rs +++ b/examples/nauthz/src/main.rs @@ -1,7 +1,7 @@ use tonic::{transport::Server, Request, Response, Status}; use nauthz_grpc::authorization_server::{Authorization, AuthorizationServer}; -use nauthz_grpc::{EventReply, EventRequest, Decision}; +use nauthz_grpc::{Decision, EventReply, EventRequest}; pub mod nauthz_grpc { tonic::include_proto!("nauthz"); @@ -14,7 +14,6 @@ pub struct EventAuthz { #[tonic::async_trait] impl Authorization for EventAuthz { - async fn event_admit( &self, request: Request, @@ -22,18 +21,18 @@ impl Authorization for EventAuthz { let reply; let req = request.into_inner(); let event = req.event.unwrap(); - let content_prefix:String = event.content.chars().take(40).collect(); + let content_prefix: String = event.content.chars().take(40).collect(); println!("recvd event, [kind={}, origin={:?}, nip05_domain={:?}, tag_count={}, content_sample={:?}]", event.kind, req.origin, req.nip05.map(|x| x.domain), event.tags.len(), content_prefix); // Permit any event with a whitelisted kind if self.allowed_kinds.contains(&event.kind) { - println!("This looks fine! (kind={})",event.kind); + println!("This looks fine! (kind={})", event.kind); reply = nauthz_grpc::EventReply { decision: Decision::Permit as i32, - message: None + message: None, }; } else { - println!("Blocked! (kind={})",event.kind); + println!("Blocked! (kind={})", event.kind); reply = nauthz_grpc::EventReply { decision: Decision::Deny as i32, message: Some(format!("kind {} not permitted", event.kind)), @@ -49,7 +48,7 @@ async fn main() -> Result<(), Box> { // A simple authorization engine that allows kinds 0-3 let checker = EventAuthz { - allowed_kinds: vec![0,1,2,3], + allowed_kinds: vec![0, 1, 2, 3], }; println!("EventAuthz Server listening on {}", addr); // Start serving