diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1b9fa00 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +build: + go build . \ No newline at end of file diff --git a/TCPServer.go b/TCPServer.go index dd6b2e3..ed294ce 100644 --- a/TCPServer.go +++ b/TCPServer.go @@ -7,6 +7,7 @@ import ( "os" "strings" "sync" + "time" log "github.com/sirupsen/logrus" ) @@ -16,29 +17,31 @@ var ( ) type TCPServer struct { - Address string - Port string - Clients map[net.Conn]bool - Mutex *sync.Mutex - LogWriter *bufio.Writer - Reader *bufio.Reader - Writer *bufio.Writer - Conn net.Conn - Listener net.Listener - MsgChan chan string - CmdChan chan string - Log *log.Logger - Config *Config + Address string + Port string + Clients map[net.Conn]bool + Mutex *sync.Mutex + LogWriter *bufio.Writer + Reader *bufio.Reader + Writer *bufio.Writer + Conn net.Conn + Listener net.Listener + MsgChan chan string + CmdChan chan string + Log *log.Logger + Config *Config + MessageSent int } func NewTCPServer(address string, port string) *TCPServer { return &TCPServer{ - Address: address, - Port: port, - Clients: make(map[net.Conn]bool), - MsgChan: make(chan string, 100), - CmdChan: make(chan string), - Mutex: new(sync.Mutex), + Address: address, + Port: port, + Clients: make(map[net.Conn]bool), + MsgChan: make(chan string, 100), + CmdChan: make(chan string), + Mutex: new(sync.Mutex), + MessageSent: 0, } } @@ -120,10 +123,17 @@ func (s *TCPServer) Write(message string) (n int, err error) { func (s *TCPServer) broadcastMessage(message string) { s.Mutex.Lock() defer s.Mutex.Unlock() - for client := range s.Clients { - _, err := client.Write([]byte(message + "\r\n")) - if err != nil { - fmt.Println("Error while sending message to clients:", client.RemoteAddr()) + if len(s.Clients) > 0 { + if s.MessageSent == 0 { + time.Sleep(3 * time.Second) + s.MessageSent += 1 + } + for client := range s.Clients { + _, err := client.Write([]byte(message + "\r\n")) + s.MessageSent += 1 + if err != nil { + fmt.Println("Error while sending message to clients:", client.RemoteAddr()) + } } } } diff --git a/config.yml b/config.yml index 7019407..6580567 100644 --- a/config.yml +++ b/config.yml @@ -26,8 +26,8 @@ cluster: command: "SET/NOFILTER" #"SET/FILTER DOC/PASS EA,OH,G,F,DL,I,SV,9A,SK,S5,LX,OE,HA,CT" login_prompt: "login:" flex: - discovery: true # Radio must be on same LAN than the program - ip: 192.168.2.131 # if discovery is true no need to put an IP + discovery: false # Radio must be on same LAN than the program + ip: 82.67.157.19 # if discovery is true no need to put an IP spot_life: 600 #seconds telnetserver: # Log4OM must be connected to this server ie: localhost:7301 if on same machine as this program else ip:7301 host: 0.0.0.0 diff --git a/gotify.go b/gotify.go index a9ca680..b0ae1d5 100644 --- a/gotify.go +++ b/gotify.go @@ -20,7 +20,7 @@ func Gotify(spot FlexSpot) { if Cfg.Gotify.Enable && !strings.Contains(ExceptionList, spot.DX) { - message := fmt.Sprintf("DX: %s\nFrom: %s\nFreq: %s\nMode: %s\nTime: %s\n", spot.DX, spot.SpotterCallsign, spot.FrequencyMhz, spot.Mode, spot.TimeStamp) + message := fmt.Sprintf("DX: %s\nFrom: %s\nFreq: %s\nMode: %s\nTime: %v\n", spot.DX, spot.SpotterCallsign, spot.FrequencyMhz, spot.Mode, spot.TimeStamp) gotifyMsg := GotifyMessage{ Title: "", diff --git a/images/FlexDXCluster.ico b/images/FlexDXCluster.ico new file mode 100644 index 0000000..61ee39e Binary files /dev/null and b/images/FlexDXCluster.ico differ diff --git a/images/background.jpg b/images/background.jpg new file mode 100644 index 0000000..2eee2ce Binary files /dev/null and b/images/background.jpg differ diff --git a/main.go b/main.go index 6a9d1eb..e5e7b6b 100644 --- a/main.go +++ b/main.go @@ -42,7 +42,7 @@ func main() { cfg := NewConfig(cfgPath) log := NewLog() - log.Info("Running FlexDXCluster version 0.7") + log.Info("Running FlexDXCluster version 0.8") log.Infof("Callsign: %s", cfg.General.Callsign) DeleteDatabase("./flex.sqlite", log)