implement bootstrap relays
This commit is contained in:
@@ -42,6 +42,7 @@ type C struct {
|
|||||||
ACLMode string `env:"ORLY_ACL_MODE" usage:"ACL mode: follows,none" default:"none"`
|
ACLMode string `env:"ORLY_ACL_MODE" usage:"ACL mode: follows,none" default:"none"`
|
||||||
SpiderMode string `env:"ORLY_SPIDER_MODE" usage:"spider mode: none,follows" default:"none"`
|
SpiderMode string `env:"ORLY_SPIDER_MODE" usage:"spider mode: none,follows" default:"none"`
|
||||||
SpiderFrequency time.Duration `env:"ORLY_SPIDER_FREQUENCY" usage:"spider frequency in seconds" default:"1h"`
|
SpiderFrequency time.Duration `env:"ORLY_SPIDER_FREQUENCY" usage:"spider frequency in seconds" default:"1h"`
|
||||||
|
BootstrapRelays []string `env:"ORLY_BOOTSTRAP_RELAYS" usage:"comma-separated list of bootstrap relay URLs for initial sync"`
|
||||||
NWCUri string `env:"ORLY_NWC_URI" usage:"NWC (Nostr Wallet Connect) connection string for Lightning payments"`
|
NWCUri string `env:"ORLY_NWC_URI" usage:"NWC (Nostr Wallet Connect) connection string for Lightning payments"`
|
||||||
SubscriptionEnabled bool `env:"ORLY_SUBSCRIPTION_ENABLED" default:"false" usage:"enable subscription-based access control requiring payment for non-directory events"`
|
SubscriptionEnabled bool `env:"ORLY_SUBSCRIPTION_ENABLED" default:"false" usage:"enable subscription-based access control requiring payment for non-directory events"`
|
||||||
MonthlyPriceSats int64 `env:"ORLY_MONTHLY_PRICE_SATS" default:"6000" usage:"price in satoshis for one month subscription (default ~$2 USD)"`
|
MonthlyPriceSats int64 `env:"ORLY_MONTHLY_PRICE_SATS" default:"6000" usage:"price in satoshis for one month subscription (default ~$2 USD)"`
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ services:
|
|||||||
- ORLY_ACL_MODE=follows
|
- ORLY_ACL_MODE=follows
|
||||||
- ORLY_SPIDER_MODE=follows
|
- ORLY_SPIDER_MODE=follows
|
||||||
|
|
||||||
|
# Bootstrap relay URLs for initial sync
|
||||||
|
- ORLY_BOOTSTRAP_RELAYS=wss://profiles.nostr1.com,wss://purplepag.es,wss://relay.damus.io,wss://nostr.wine,wss://relay.nostr.band,wss://freelay.sovbit.host
|
||||||
|
|
||||||
# Subscription Settings (optional)
|
# Subscription Settings (optional)
|
||||||
- ORLY_SUBSCRIPTION_ENABLED=false
|
- ORLY_SUBSCRIPTION_ENABLED=false
|
||||||
- ORLY_MONTHLY_PRICE_SATS=0
|
- ORLY_MONTHLY_PRICE_SATS=0
|
||||||
|
|||||||
@@ -158,6 +158,8 @@ func (f *Follows) adminRelays() (urls []string) {
|
|||||||
copy(admins, f.admins)
|
copy(admins, f.admins)
|
||||||
f.followsMx.RUnlock()
|
f.followsMx.RUnlock()
|
||||||
seen := make(map[string]struct{})
|
seen := make(map[string]struct{})
|
||||||
|
|
||||||
|
// First, try to get relay URLs from admin kind 10002 events
|
||||||
for _, adm := range admins {
|
for _, adm := range admins {
|
||||||
fl := &filter.F{
|
fl := &filter.F{
|
||||||
Authors: tag.NewFromAny(adm),
|
Authors: tag.NewFromAny(adm),
|
||||||
@@ -194,6 +196,29 @@ func (f *Follows) adminRelays() (urls []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no admin relays found, use bootstrap relays as fallback
|
||||||
|
if len(urls) == 0 {
|
||||||
|
log.I.F("no admin relays found in DB, checking bootstrap relays")
|
||||||
|
if len(f.cfg.BootstrapRelays) > 0 {
|
||||||
|
log.I.F("using bootstrap relays: %v", f.cfg.BootstrapRelays)
|
||||||
|
for _, relay := range f.cfg.BootstrapRelays {
|
||||||
|
n := string(normalize.URL(relay))
|
||||||
|
if n == "" {
|
||||||
|
log.W.F("invalid bootstrap relay URL: %s", relay)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok := seen[n]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
seen[n] = struct{}{}
|
||||||
|
urls = append(urls, n)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.W.F("no bootstrap relays configured")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +236,7 @@ func (f *Follows) startSubscriptions(ctx context.Context) {
|
|||||||
urls := f.adminRelays()
|
urls := f.adminRelays()
|
||||||
log.I.S(urls)
|
log.I.S(urls)
|
||||||
if len(urls) == 0 {
|
if len(urls) == 0 {
|
||||||
log.W.F("follows syncer: no admin relays found in DB (kind 10002)")
|
log.W.F("follows syncer: no admin relays found in DB (kind 10002) and no bootstrap relays configured")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.T.F(
|
log.T.F(
|
||||||
@@ -256,6 +281,7 @@ func (f *Follows) startSubscriptions(ctx context.Context) {
|
|||||||
ff := &filter.S{}
|
ff := &filter.S{}
|
||||||
f1 := &filter.F{
|
f1 := &filter.F{
|
||||||
Authors: tag.NewFromBytesSlice(authors...),
|
Authors: tag.NewFromBytesSlice(authors...),
|
||||||
|
Kinds: kind.NewS(kind.New(kind.RelayListMetadata.K)),
|
||||||
Limit: values.ToUintPointer(0),
|
Limit: values.ToUintPointer(0),
|
||||||
}
|
}
|
||||||
*ff = append(*ff, f1)
|
*ff = append(*ff, f1)
|
||||||
|
|||||||
Reference in New Issue
Block a user