2023-01-25 05:47:06 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2023-04-29 18:01:40 +00:00
|
|
|
"git.minhas.io/asara/well-goknown/config"
|
2024-01-01 01:08:48 +00:00
|
|
|
"git.minhas.io/asara/well-goknown/lnurlp"
|
2023-04-29 18:01:40 +00:00
|
|
|
"git.minhas.io/asara/well-goknown/logger"
|
2023-01-25 05:47:06 +00:00
|
|
|
"git.minhas.io/asara/well-goknown/matrix"
|
|
|
|
"git.minhas.io/asara/well-goknown/nostr"
|
2023-05-01 22:41:28 +00:00
|
|
|
"git.minhas.io/asara/well-goknown/redis"
|
2023-01-25 05:47:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-05-01 22:41:28 +00:00
|
|
|
var err error
|
|
|
|
l := logger.Get()
|
|
|
|
// connect to redis
|
|
|
|
redis.NostrRedisConn, err = redis.New("localhost:6379", "", redis.NostrKeyspace)
|
|
|
|
if err != nil {
|
|
|
|
l.Fatal().Msg("unable to connect to redis")
|
|
|
|
}
|
|
|
|
redis.LndRedisConn, err = redis.New("localhost:6379", "", redis.LndKeyspace)
|
|
|
|
if err != nil {
|
|
|
|
l.Fatal().Msg("unable to connect to redis")
|
|
|
|
}
|
2024-01-01 01:08:48 +00:00
|
|
|
redis.LnurlpRedisConn, err = redis.New("localhost:6379", "", redis.LnurlpKeyspace)
|
|
|
|
if err != nil {
|
|
|
|
l.Fatal().Msg("unable to connect to redis")
|
|
|
|
}
|
2023-05-06 23:50:10 +00:00
|
|
|
|
2023-02-03 04:56:15 +00:00
|
|
|
// matrix endpoints
|
2023-04-29 18:01:40 +00:00
|
|
|
l.Debug().Msg("enabling matrix server endpoint")
|
2023-02-04 01:15:41 +00:00
|
|
|
http.HandleFunc("/.well-known/matrix/server", matrix.MatrixServer)
|
2023-04-29 18:01:40 +00:00
|
|
|
l.Debug().Msg("enabling matrix client endpoint")
|
2023-02-04 01:15:41 +00:00
|
|
|
http.HandleFunc("/.well-known/matrix/client", matrix.MatrixClient)
|
2023-02-03 04:56:15 +00:00
|
|
|
|
|
|
|
// nostr endpoints
|
2023-04-29 18:01:40 +00:00
|
|
|
l.Debug().Msg("enabling nostr user endpoint")
|
2023-01-25 05:47:06 +00:00
|
|
|
http.HandleFunc("/.well-known/nostr.json", nostr.GetNostrAddr)
|
2023-12-31 01:12:01 +00:00
|
|
|
|
2024-01-01 01:08:48 +00:00
|
|
|
// enable requesting of nostr addresses
|
|
|
|
lndAddr := config.GetConfig().LndAddr
|
|
|
|
if lndAddr != "" {
|
2023-12-31 01:12:01 +00:00
|
|
|
l.Debug().Msg("enabling nostr request endpoint")
|
|
|
|
http.HandleFunc("/request/nostr", nostr.RequestNostrAddr)
|
|
|
|
}
|
2023-02-03 04:56:15 +00:00
|
|
|
|
2024-01-01 01:08:48 +00:00
|
|
|
//lnurlp endpoints
|
|
|
|
l.Debug().Msg("enabling lnurlp endpoint")
|
|
|
|
http.HandleFunc("/.well-known/lnurlp/", lnurlp.GetLnurlpUser)
|
|
|
|
|
2023-02-03 04:56:15 +00:00
|
|
|
// start server
|
2023-04-29 18:01:40 +00:00
|
|
|
port := config.GetConfig().ListenAddr
|
|
|
|
l.Info().Msgf("starting server on %s", port)
|
|
|
|
http.ListenAndServe(port, nil)
|
2023-01-25 05:47:06 +00:00
|
|
|
}
|