mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-22 00:59:07 -05:00
docs: cleanup location of documentation
This commit is contained in:
parent
136e41d234
commit
40abd6858e
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
||||||
/target
|
**/target/
|
||||||
nostr.db
|
nostr.db
|
||||||
|
|
|
@ -139,7 +139,7 @@ settings.
|
||||||
|
|
||||||
For examples of putting the relay behind a reverse proxy (for TLS
|
For examples of putting the relay behind a reverse proxy (for TLS
|
||||||
termination, load balancing, and other features), see [Reverse
|
termination, load balancing, and other features), see [Reverse
|
||||||
Proxy](reverse-proxy.md).
|
Proxy](docs/reverse-proxy.md).
|
||||||
|
|
||||||
## Dev Channel
|
## Dev Channel
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ http {
|
||||||
|
|
||||||
### Nginx Notes
|
### 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).
|
For help installing `nginx` on `Ubuntu`, see [this guide](https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04).
|
||||||
|
|
|
@ -2,9 +2,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
tonic_build::configure()
|
tonic_build::configure()
|
||||||
.build_server(false)
|
.build_server(false)
|
||||||
.protoc_arg("--experimental_allow_proto3_optional")
|
.protoc_arg("--experimental_allow_proto3_optional")
|
||||||
.compile(
|
.compile(&["../../proto/nauthz.proto"], &["../../proto"])?;
|
||||||
&["../proto/nauthz.proto"],
|
|
||||||
&["../proto"],
|
|
||||||
)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
use tonic::{transport::Server, Request, Response, Status};
|
use tonic::{transport::Server, Request, Response, Status};
|
||||||
|
|
||||||
use nauthz_grpc::authorization_server::{Authorization, AuthorizationServer};
|
use nauthz_grpc::authorization_server::{Authorization, AuthorizationServer};
|
||||||
use nauthz_grpc::{EventReply, EventRequest, Decision};
|
use nauthz_grpc::{Decision, EventReply, EventRequest};
|
||||||
|
|
||||||
pub mod nauthz_grpc {
|
pub mod nauthz_grpc {
|
||||||
tonic::include_proto!("nauthz");
|
tonic::include_proto!("nauthz");
|
||||||
|
@ -14,7 +14,6 @@ pub struct EventAuthz {
|
||||||
|
|
||||||
#[tonic::async_trait]
|
#[tonic::async_trait]
|
||||||
impl Authorization for EventAuthz {
|
impl Authorization for EventAuthz {
|
||||||
|
|
||||||
async fn event_admit(
|
async fn event_admit(
|
||||||
&self,
|
&self,
|
||||||
request: Request<EventRequest>,
|
request: Request<EventRequest>,
|
||||||
|
@ -22,18 +21,18 @@ impl Authorization for EventAuthz {
|
||||||
let reply;
|
let reply;
|
||||||
let req = request.into_inner();
|
let req = request.into_inner();
|
||||||
let event = req.event.unwrap();
|
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={:?}]",
|
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);
|
event.kind, req.origin, req.nip05.map(|x| x.domain), event.tags.len(), content_prefix);
|
||||||
// Permit any event with a whitelisted kind
|
// Permit any event with a whitelisted kind
|
||||||
if self.allowed_kinds.contains(&event.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 {
|
reply = nauthz_grpc::EventReply {
|
||||||
decision: Decision::Permit as i32,
|
decision: Decision::Permit as i32,
|
||||||
message: None
|
message: None,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
println!("Blocked! (kind={})",event.kind);
|
println!("Blocked! (kind={})", event.kind);
|
||||||
reply = nauthz_grpc::EventReply {
|
reply = nauthz_grpc::EventReply {
|
||||||
decision: Decision::Deny as i32,
|
decision: Decision::Deny as i32,
|
||||||
message: Some(format!("kind {} not permitted", event.kind)),
|
message: Some(format!("kind {} not permitted", event.kind)),
|
||||||
|
@ -49,7 +48,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
// A simple authorization engine that allows kinds 0-3
|
// A simple authorization engine that allows kinds 0-3
|
||||||
let checker = EventAuthz {
|
let checker = EventAuthz {
|
||||||
allowed_kinds: vec![0,1,2,3],
|
allowed_kinds: vec![0, 1, 2, 3],
|
||||||
};
|
};
|
||||||
println!("EventAuthz Server listening on {}", addr);
|
println!("EventAuthz Server listening on {}", addr);
|
||||||
// Start serving
|
// Start serving
|
Loading…
Reference in New Issue
Block a user