From 891fa79cbb91186f3bd2427485b6364fc8bf9a49 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Tue, 23 Jan 2024 14:34:09 -0500 Subject: added a reverse proxy --- main.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'main.go') 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 } -- cgit v1.2.3