Compare commits
2 commits
1e1ca5d5ac
...
38e72e2a0c
| Author | SHA1 | Date | |
|---|---|---|---|
| 38e72e2a0c | |||
| 2c9807cff6 |
3 changed files with 13 additions and 5 deletions
|
|
@ -15,6 +15,7 @@ import (
|
|||
type Config struct {
|
||||
Port int
|
||||
NSec string
|
||||
SecretKey nostr.SecretKey
|
||||
NPub string
|
||||
Relays []string
|
||||
}
|
||||
|
|
@ -71,6 +72,7 @@ func LoadConfig() *Config {
|
|||
npub := nip19.EncodeNpub(pk)
|
||||
log.Printf("Loading private key from file %s. Will send alerts from %s", nsecfile, npub)
|
||||
config.NSec = nsec
|
||||
config.SecretKey = sk
|
||||
} else {
|
||||
sk := nostr.Generate()
|
||||
pk := nostr.GetPublicKey(sk)
|
||||
|
|
@ -78,6 +80,7 @@ func LoadConfig() *Config {
|
|||
npub := nip19.EncodeNpub(pk)
|
||||
log.Printf("Using random private key. Will send alerts from %s", npub)
|
||||
config.NSec = nsec
|
||||
config.SecretKey = sk
|
||||
}
|
||||
|
||||
npub, ok := os.LookupEnv("NOSTR_NPUB")
|
||||
|
|
@ -90,6 +93,8 @@ func LoadConfig() *Config {
|
|||
relays, ok := os.LookupEnv("NOSTR_RELAYS")
|
||||
if ok {
|
||||
config.Relays = strings.Split(relays, ",")
|
||||
} else {
|
||||
config.Relays = strings.Split(relayargs, ",")
|
||||
}
|
||||
return &config
|
||||
}
|
||||
|
|
|
|||
3
main.go
3
main.go
|
|
@ -8,6 +8,9 @@ import (
|
|||
|
||||
func main() {
|
||||
cfg := LoadConfig()
|
||||
for _, relay := range cfg.Relays {
|
||||
log.Printf(relay)
|
||||
}
|
||||
http.HandleFunc("/", alertReceiver)
|
||||
log.Printf("Server starting on http://localhost:%d", cfg.Port)
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), nil))
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue