aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-01-23 19:34:09 +0000
committerterminaldweller <devi@terminaldweller.com>2024-01-23 19:34:09 +0000
commit891fa79cbb91186f3bd2427485b6364fc8bf9a49 (patch)
tree51bf5f11a61d879968714de0ef8b49051700baba
parentadded a reverse proxy (diff)
downloadsms-webhook-891fa79cbb91186f3bd2427485b6364fc8bf9a49.tar.gz
sms-webhook-891fa79cbb91186f3bd2427485b6364fc8bf9a49.zip
added a reverse proxy
-rw-r--r--main.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/main.go b/main.go
index 78daff6..4614a60 100644
--- a/main.go
+++ b/main.go
@@ -22,6 +22,7 @@ const (
redisDialTimeout = 5
redisReadTimeout = 10
redisWriteTimetout = 10
+ reconnectTime = 30
)
type handlerWrapper struct {
@@ -66,21 +67,18 @@ func (hw handlerWrapper) postHandler(context echo.Context) error {
}
for {
- fmt.Println("one")
- // irc = <-hw.irc
if hw.irc != nil {
if hw.irc.IsConnected() {
break
}
}
- fmt.Println("two")
}
hw.irc.Cmd.Message(hw.config.IrcChannel, fmt.Sprintf("From: %s, Text: %s", sms.From, sms.Text))
- fmt.Println(smsInfoReal)
+ log.Println(smsInfoReal)
- return context.JSON(http.StatusOK, sms)
+ return context.JSON(http.StatusOK, "OK")
}
func runIRC(appConfig TomlConfig, ircChan chan *girc.Client) {
@@ -96,6 +94,7 @@ func runIRC(appConfig TomlConfig, ircChan chan *girc.Client) {
saslUser := appConfig.IrcSaslUser
saslPass := appConfig.IrcSaslPass
+
if saslUser != "" && saslPass != "" {
irc.Config.SASL = &girc.SASLPlain{
User: appConfig.IrcSaslUser,
@@ -114,7 +113,7 @@ func runIRC(appConfig TomlConfig, ircChan chan *girc.Client) {
if err := irc.Connect(); err != nil {
log.Println(err)
log.Println("reconnecting in 30 seconds")
- time.Sleep(30 * time.Second)
+ time.Sleep(reconnectTime * time.Second)
} else {
return
}