This commit is contained in:
2024-11-15 20:41:34 +07:00
parent e99a0a921d
commit 1f83105c8c
5 changed files with 43 additions and 47 deletions

View File

@ -132,36 +132,32 @@ func (c *TCPClient) ReadLine() {
for {
message, err := c.Reader.ReadString('\n')
message, _ = strings.CutSuffix(message, "\n")
message, _ = strings.CutSuffix(message, "\r")
if err != nil {
Log.Errorf("Error reading message: %s", err)
continue
}
Log.Debugf("Received Message: %s", message)
if strings.Contains(message, Cfg.Cluster.LoginPrompt+"\r\n") || strings.Contains(message, Cfg.Cluster.LoginPrompt+" \r\n") {
if strings.Contains(message, Cfg.Cluster.LoginPrompt) {
Log.Debug("Found login prompt...sending callsign")
c.Write([]byte(c.Login + "\r\n"))
time.Sleep(time.Second * 2)
c.SetFilters()
time.Sleep(time.Second * 1)
if Cfg.Cluster.Command != "" {
c.WriteString(Cfg.Cluster.Command)
}
Log.Info("Start receiving spots")
} else if strings.Contains(message, "Error reading from server: read tcp") {
Log.Error("Disconnected from Telnet Server, reconnecting")
c.Close()
c.StartClient()
} else {
ProcessTelnetSpot(spotRe, message, c.SpotChanToFlex, c.SpotChanToHTTPServer, c.Countries)
}
ProcessTelnetSpot(spotRe, message, c.SpotChanToFlex, c.SpotChanToHTTPServer, c.Countries)
// Send the spot message to TCP server
if len(c.TCPServer.Clients) > 0 {
if count == 0 {
// wait 5 seconds before sending messages to allow the client to connect
time.Sleep(time.Second * 5)
count++
}
c.MsgChan <- message
}
c.MsgChan <- message
}
}