wallet-sync-server/main.go

71 lines
1.6 KiB
Go
Raw Normal View History

package main
import (
"log"
2022-07-12 04:10:19 +02:00
"lbryio/lbry-id/auth"
2022-07-24 00:13:56 +02:00
"lbryio/lbry-id/env"
2022-07-29 19:42:25 +02:00
"lbryio/lbry-id/mail"
2022-07-12 04:10:19 +02:00
"lbryio/lbry-id/server"
"lbryio/lbry-id/store"
)
func storeInit() (s store.Store) {
s = store.Store{}
s.Init("sql.db")
err := s.Migrate()
if err != nil {
log.Fatalf("DB setup failure: %+v", err)
}
return
}
2022-07-29 19:42:25 +02:00
// Output information about the email verification mode so the user can confirm
// what they set. Also trigger an error on startup if there's a configuration
// problem.
2022-08-01 17:50:16 +02:00
func logEmailVerificationConfigs(e *env.Env) (err error) {
2022-07-29 19:42:25 +02:00
verificationMode, err := env.GetAccountVerificationMode(e)
if err != nil {
return
}
accountWhitelist, err := env.GetAccountWhitelist(e, verificationMode)
if err != nil {
return
}
2022-08-01 01:18:04 +02:00
// just to report config errors to the user on startup
2022-08-01 17:50:16 +02:00
sendingDomain, serverDomain, _, _, err := env.GetMailgunConfigs(e, verificationMode)
2022-08-01 01:18:04 +02:00
if err != nil {
return
}
2022-07-29 19:42:25 +02:00
if verificationMode == env.AccountVerificationModeWhitelist {
log.Printf("Account verification mode: %s - Whitelist has %d email(s).\n", verificationMode, len(accountWhitelist))
} else {
log.Printf("Account verification mode: %s", verificationMode)
}
2022-08-01 17:50:16 +02:00
if verificationMode == env.AccountVerificationModeEmailVerify {
log.Printf("Mailgun domains: %s for sending addresses, %s for links in the email", sendingDomain, serverDomain)
}
2022-07-29 19:42:25 +02:00
return
}
func main() {
2022-07-29 19:42:25 +02:00
e := env.Env{}
2022-08-01 17:50:16 +02:00
if err := logEmailVerificationConfigs(&e); err != nil {
2022-07-29 19:42:25 +02:00
log.Fatal(err.Error())
}
store := storeInit()
2022-08-01 17:50:16 +02:00
// The port that the sync server serves from.
internalPort := 8090
srv := server.Init(&auth.Auth{}, &store, &e, &mail.Mail{&e}, internalPort)
srv.Serve()
}