mirror of
https://github.com/aljazceru/haven.git
synced 2025-12-19 06:34:22 +01:00
set relay service urls
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
OWNER_NPUB="npub1utx00neqgqln72j22kej3ux7803c2k986henvvha4thuwfkper4s7r50e8"
|
OWNER_NPUB="npub1utx00neqgqln72j22kej3ux7803c2k986henvvha4thuwfkper4s7r50e8"
|
||||||
|
RELAY_URL="relay.utxo.one"
|
||||||
|
|
||||||
## Private Relay Settings
|
## Private Relay Settings
|
||||||
PRIVATE_RELAY_NAME="utxo's private relay"
|
PRIVATE_RELAY_NAME="utxo's private relay"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
OwnerNpub string `json:"owner_npub"`
|
OwnerNpub string `json:"owner_npub"`
|
||||||
|
RelayURL string `json:"relay_url"`
|
||||||
RelaySoftware string `json:"relay_software"`
|
RelaySoftware string `json:"relay_software"`
|
||||||
RelayVersion string `json:"relay_version"`
|
RelayVersion string `json:"relay_version"`
|
||||||
PrivateRelayName string `json:"private_relay_name"`
|
PrivateRelayName string `json:"private_relay_name"`
|
||||||
@@ -53,6 +54,7 @@ func loadConfig() Config {
|
|||||||
|
|
||||||
return Config{
|
return Config{
|
||||||
OwnerNpub: getEnv("OWNER_NPUB"),
|
OwnerNpub: getEnv("OWNER_NPUB"),
|
||||||
|
RelayURL: getEnv("RELAY_URL"),
|
||||||
RelaySoftware: "https://github.com/bitvora/haven",
|
RelaySoftware: "https://github.com/bitvora/haven",
|
||||||
RelayVersion: "v0.1.0",
|
RelayVersion: "v0.1.0",
|
||||||
PrivateRelayName: getEnv("PRIVATE_RELAY_NAME"),
|
PrivateRelayName: getEnv("PRIVATE_RELAY_NAME"),
|
||||||
|
|||||||
3
init.go
3
init.go
@@ -65,6 +65,7 @@ func initRelays() {
|
|||||||
privateRelay.Info.Icon = config.PrivateRelayIcon
|
privateRelay.Info.Icon = config.PrivateRelayIcon
|
||||||
privateRelay.Info.Version = config.RelayVersion
|
privateRelay.Info.Version = config.RelayVersion
|
||||||
privateRelay.Info.Software = config.RelaySoftware
|
privateRelay.Info.Software = config.RelaySoftware
|
||||||
|
privateRelay.ServiceURL = "https://" + config.RelayURL + "/private"
|
||||||
|
|
||||||
chatRelay.Info.Name = config.ChatRelayName
|
chatRelay.Info.Name = config.ChatRelayName
|
||||||
chatRelay.Info.PubKey = nPubToPubkey(config.ChatRelayNpub)
|
chatRelay.Info.PubKey = nPubToPubkey(config.ChatRelayNpub)
|
||||||
@@ -72,6 +73,7 @@ func initRelays() {
|
|||||||
chatRelay.Info.Icon = config.ChatRelayIcon
|
chatRelay.Info.Icon = config.ChatRelayIcon
|
||||||
chatRelay.Info.Version = config.RelayVersion
|
chatRelay.Info.Version = config.RelayVersion
|
||||||
chatRelay.Info.Software = config.RelaySoftware
|
chatRelay.Info.Software = config.RelaySoftware
|
||||||
|
privateRelay.ServiceURL = "https://" + config.RelayURL + "/chat"
|
||||||
|
|
||||||
outboxRelay.Info.Name = config.OutboxRelayName
|
outboxRelay.Info.Name = config.OutboxRelayName
|
||||||
outboxRelay.Info.PubKey = nPubToPubkey(config.OutboxRelayNpub)
|
outboxRelay.Info.PubKey = nPubToPubkey(config.OutboxRelayNpub)
|
||||||
@@ -86,4 +88,5 @@ func initRelays() {
|
|||||||
inboxRelay.Info.Icon = config.InboxRelayIcon
|
inboxRelay.Info.Icon = config.InboxRelayIcon
|
||||||
inboxRelay.Info.Version = config.RelayVersion
|
inboxRelay.Info.Version = config.RelayVersion
|
||||||
inboxRelay.Info.Software = config.RelaySoftware
|
inboxRelay.Info.Software = config.RelaySoftware
|
||||||
|
inboxRelay.ServiceURL = "https://" + config.RelayURL + "/inbox"
|
||||||
}
|
}
|
||||||
|
|||||||
11
main.go
11
main.go
@@ -75,12 +75,21 @@ func makeNewRelay(relayType string) *khatru.Relay {
|
|||||||
|
|
||||||
privateRelay.RejectFilter = append(privateRelay.RejectFilter, func(ctx context.Context, filter nostr.Filter) (bool, string) {
|
privateRelay.RejectFilter = append(privateRelay.RejectFilter, func(ctx context.Context, filter nostr.Filter) (bool, string) {
|
||||||
authenticatedUser := khatru.GetAuthed(ctx)
|
authenticatedUser := khatru.GetAuthed(ctx)
|
||||||
|
if authenticatedUser == nPubToPubkey(config.OwnerNpub) {
|
||||||
|
return false, ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, "auth-required: this query requires you to be authenticated"
|
||||||
|
})
|
||||||
|
|
||||||
|
privateRelay.RejectEvent = append(privateRelay.RejectEvent, func(ctx context.Context, event *nostr.Event) (bool, string) {
|
||||||
|
authenticatedUser := khatru.GetAuthed(ctx)
|
||||||
|
|
||||||
if authenticatedUser == nPubToPubkey(config.OwnerNpub) {
|
if authenticatedUser == nPubToPubkey(config.OwnerNpub) {
|
||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, "only the owner can access this relay"
|
return true, "auth-required: publishing this event requires authentication"
|
||||||
})
|
})
|
||||||
|
|
||||||
return privateRelay
|
return privateRelay
|
||||||
|
|||||||
Reference in New Issue
Block a user