This commit is contained in:
2025-08-07 10:18:28 +02:00
parent 170b5c7912
commit d988e50f0d
7 changed files with 39 additions and 27 deletions

2
Makefile Normal file
View File

@@ -0,0 +1,2 @@
build:
go build .

View File

@@ -7,6 +7,7 @@ import (
"os" "os"
"strings" "strings"
"sync" "sync"
"time"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
@@ -16,29 +17,31 @@ var (
) )
type TCPServer struct { type TCPServer struct {
Address string Address string
Port string Port string
Clients map[net.Conn]bool Clients map[net.Conn]bool
Mutex *sync.Mutex Mutex *sync.Mutex
LogWriter *bufio.Writer LogWriter *bufio.Writer
Reader *bufio.Reader Reader *bufio.Reader
Writer *bufio.Writer Writer *bufio.Writer
Conn net.Conn Conn net.Conn
Listener net.Listener Listener net.Listener
MsgChan chan string MsgChan chan string
CmdChan chan string CmdChan chan string
Log *log.Logger Log *log.Logger
Config *Config Config *Config
MessageSent int
} }
func NewTCPServer(address string, port string) *TCPServer { func NewTCPServer(address string, port string) *TCPServer {
return &TCPServer{ return &TCPServer{
Address: address, Address: address,
Port: port, Port: port,
Clients: make(map[net.Conn]bool), Clients: make(map[net.Conn]bool),
MsgChan: make(chan string, 100), MsgChan: make(chan string, 100),
CmdChan: make(chan string), CmdChan: make(chan string),
Mutex: new(sync.Mutex), 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) { func (s *TCPServer) broadcastMessage(message string) {
s.Mutex.Lock() s.Mutex.Lock()
defer s.Mutex.Unlock() defer s.Mutex.Unlock()
for client := range s.Clients { if len(s.Clients) > 0 {
_, err := client.Write([]byte(message + "\r\n")) if s.MessageSent == 0 {
if err != nil { time.Sleep(3 * time.Second)
fmt.Println("Error while sending message to clients:", client.RemoteAddr()) 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())
}
} }
} }
} }

View File

@@ -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" command: "SET/NOFILTER" #"SET/FILTER DOC/PASS EA,OH,G,F,DL,I,SV,9A,SK,S5,LX,OE,HA,CT"
login_prompt: "login:" login_prompt: "login:"
flex: flex:
discovery: true # Radio must be on same LAN than the program discovery: false # Radio must be on same LAN than the program
ip: 192.168.2.131 # if discovery is true no need to put an IP ip: 82.67.157.19 # if discovery is true no need to put an IP
spot_life: 600 #seconds 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 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 host: 0.0.0.0

View File

@@ -20,7 +20,7 @@ func Gotify(spot FlexSpot) {
if Cfg.Gotify.Enable && !strings.Contains(ExceptionList, spot.DX) { 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{ gotifyMsg := GotifyMessage{
Title: "", Title: "",

BIN
images/FlexDXCluster.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

BIN
images/background.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@@ -42,7 +42,7 @@ func main() {
cfg := NewConfig(cfgPath) cfg := NewConfig(cfgPath)
log := NewLog() log := NewLog()
log.Info("Running FlexDXCluster version 0.7") log.Info("Running FlexDXCluster version 0.8")
log.Infof("Callsign: %s", cfg.General.Callsign) log.Infof("Callsign: %s", cfg.General.Callsign)
DeleteDatabase("./flex.sqlite", log) DeleteDatabase("./flex.sqlite", log)