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