up
This commit is contained in:
parent
e99a0a921d
commit
1f83105c8c
26
TCPClient.go
26
TCPClient.go
@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ func (s *TCPServer) broadcastMessage(message string) {
|
||||
s.Mutex.Lock()
|
||||
defer s.Mutex.Unlock()
|
||||
for client := range s.Clients {
|
||||
_, err := client.Write([]byte(message))
|
||||
_, err := client.Write([]byte(message + "\r\n"))
|
||||
if err != nil {
|
||||
fmt.Println("Error while sending message to clients:", client.RemoteAddr())
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
general:
|
||||
delete_log_file_at_start: true
|
||||
log_to_file: true
|
||||
log_level: DEBUG # INFO or DEBUG or WARN
|
||||
log_level: INFO # INFO or DEBUG or WARN
|
||||
httpserver: true # not in use for now
|
||||
telnetserver: true # not in use for now
|
||||
flexradiospot: true # not in use for now
|
||||
|
32
flexradio.go
32
flexradio.go
@ -158,8 +158,8 @@ func (fc *FlexClient) SendSpottoFlex(spot TelnetSpot) {
|
||||
UTCTime: spot.Time,
|
||||
LifeTime: Cfg.Flex.SpotLife,
|
||||
Comment: spot.Comment,
|
||||
Color: "#eaeaea",
|
||||
BackgroundColor: "#000000",
|
||||
Color: "#ffeaeaea",
|
||||
BackgroundColor: "#ff000000",
|
||||
Priority: "5",
|
||||
NewDXCC: spot.NewDXCC,
|
||||
NewBand: spot.NewBand,
|
||||
@ -171,38 +171,38 @@ func (fc *FlexClient) SendSpottoFlex(spot TelnetSpot) {
|
||||
|
||||
// If new DXCC
|
||||
if spot.NewDXCC {
|
||||
flexSpot.Color = "#3bf908"
|
||||
flexSpot.Color = "#ff3bf908"
|
||||
flexSpot.Priority = "1"
|
||||
flexSpot.BackgroundColor = "#000000"
|
||||
flexSpot.BackgroundColor = "#ff000000"
|
||||
flexSpot.Comment = flexSpot.Comment + " [New DXCC]"
|
||||
} else if spot.DX == Cfg.SQLite.Callsign {
|
||||
flexSpot.Color = "#ff0000"
|
||||
flexSpot.Color = "#ffff0000"
|
||||
flexSpot.Priority = "1"
|
||||
flexSpot.BackgroundColor = "#000000"
|
||||
flexSpot.BackgroundColor = "#ff000000"
|
||||
} else if spot.CallsignWorked {
|
||||
flexSpot.Color = "#000000"
|
||||
flexSpot.BackgroundColor = "#00c0c0"
|
||||
flexSpot.Color = "#ff000000"
|
||||
flexSpot.BackgroundColor = "#ff00c0c0"
|
||||
flexSpot.Priority = "5"
|
||||
flexSpot.Comment = flexSpot.Comment + " [Worked]"
|
||||
} else if spot.NewMode && spot.NewBand {
|
||||
flexSpot.Color = "#c603fc"
|
||||
flexSpot.Color = "#ffc603fc"
|
||||
flexSpot.Priority = "1"
|
||||
flexSpot.BackgroundColor = "#000000"
|
||||
flexSpot.BackgroundColor = "#ff000000"
|
||||
flexSpot.Comment = flexSpot.Comment + " [New Band & Mode]"
|
||||
} else if spot.NewMode && !spot.NewBand {
|
||||
flexSpot.Color = "#f9a908"
|
||||
flexSpot.Color = "#fff9a908"
|
||||
flexSpot.Priority = "2"
|
||||
flexSpot.BackgroundColor = "#000000"
|
||||
flexSpot.BackgroundColor = "#ff000000"
|
||||
flexSpot.Comment = flexSpot.Comment + " [New Mode]"
|
||||
} else if spot.NewBand && !spot.NewMode {
|
||||
flexSpot.Color = "#f9f508"
|
||||
flexSpot.Color = "#fff9f508"
|
||||
flexSpot.Priority = "3"
|
||||
flexSpot.BackgroundColor = "#000000"
|
||||
flexSpot.BackgroundColor = "#ff000000"
|
||||
flexSpot.Comment = flexSpot.Comment + " [New Band]"
|
||||
} else if !spot.NewBand && !spot.NewMode && !spot.NewDXCC && !spot.CallsignWorked {
|
||||
flexSpot.Color = "#eaeaea"
|
||||
flexSpot.Color = "#ffeaeaea"
|
||||
flexSpot.Priority = "5"
|
||||
flexSpot.BackgroundColor = "#000000"
|
||||
flexSpot.BackgroundColor = "#ff000000"
|
||||
}
|
||||
|
||||
flexSpot.Comment = strings.ReplaceAll(flexSpot.Comment, " ", "\u00A0")
|
||||
|
28
log.go
28
log.go
@ -53,20 +53,20 @@ func NewLog() *log.Logger {
|
||||
}
|
||||
|
||||
// Info ...
|
||||
func Info(format string, v ...interface{}) {
|
||||
log.Infof(format, v...)
|
||||
}
|
||||
// func Info(format string, v ...interface{}) {
|
||||
// log.Infof(format, v...)
|
||||
// }
|
||||
|
||||
// Warn ...
|
||||
func Warn(format string, v ...interface{}) {
|
||||
log.Warnf(format, v...)
|
||||
}
|
||||
// // Warn ...
|
||||
// func Warn(format string, v ...interface{}) {
|
||||
// log.Warnf(format, v...)
|
||||
// }
|
||||
|
||||
// Error ...
|
||||
func Error(format string, v ...interface{}) {
|
||||
log.Errorf(format, v...)
|
||||
}
|
||||
// // Error ...
|
||||
// func Error(format string, v ...interface{}) {
|
||||
// log.Errorf(format, v...)
|
||||
// }
|
||||
|
||||
func Debug(format string, v ...interface{}) {
|
||||
log.Debugf(format, v...)
|
||||
}
|
||||
// func Debug(format string, v ...interface{}) {
|
||||
// log.Debugf(format, v...)
|
||||
// }
|
||||
|
Loading…
x
Reference in New Issue
Block a user