Compare commits
No commits in common. "main" and "noHTTP" have entirely different histories.
@ -4,7 +4,7 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
COPY config.go config.yml database.go flexradio.go spot.go main.go TCPClient.go TCPServer.go utils.go log.go xml.go ./
|
COPY clublog.go config.go config.yml database.go flexradio.go HTTPServer.go spot.go main.go TCPClient.go TCPServer.go utils.go log.go ./
|
||||||
COPY templates/* .
|
COPY templates/* .
|
||||||
|
|
||||||
RUN go build -o bin main.go
|
RUN go build -o bin main.go
|
||||||
|
@ -135,8 +135,7 @@ func (c *TCPClient) ReadLine() {
|
|||||||
message, _ = strings.CutSuffix(message, "\r")
|
message, _ = strings.CutSuffix(message, "\r")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Log.Errorf("Error reading message: %s", err)
|
Log.Errorf("Error reading message: %s", err)
|
||||||
c.Conn.Close()
|
continue
|
||||||
c.StartClient()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(message, Cfg.Cluster.LoginPrompt) {
|
if strings.Contains(message, Cfg.Cluster.LoginPrompt) {
|
||||||
|
12
config.yml
12
config.yml
@ -1,18 +1,18 @@
|
|||||||
general:
|
general:
|
||||||
delete_log_file_at_start: true
|
delete_log_file_at_start: true
|
||||||
log_to_file: true
|
log_to_file: true
|
||||||
log_level: DEBUG # INFO or DEBUG or WARN
|
log_level: INFO # INFO or DEBUG or WARN
|
||||||
telnetserver: true # not in use for now
|
telnetserver: true # not in use for now
|
||||||
flexradiospot: true # not in use for now
|
flexradiospot: true # not in use for now
|
||||||
sqlite:
|
sqlite:
|
||||||
sqlite_path: 'C:\Perso\Seafile\Radio\Logs\Log4OM\F4BPO.SQLite' # SQLite Db oath of Log4OM
|
sqlite_path: 'C:\Perso\Seafile\Radio\Logs\Log4OM\Vietnam.SQLite' # SQLite Db oath of Log4OM
|
||||||
callsign: F4BPO # Log4OM Callsign used to check if you get spotted by someone
|
callsign: XV9Q # Log4OM Callsign used to check if you get spotted by someone
|
||||||
cluster:
|
cluster:
|
||||||
server: cluster.f4bpo.com # dxc.k0xm.net
|
server: dxc.k0xm.net
|
||||||
port: 7300
|
port: 7300
|
||||||
login: f4bpo
|
login: xv9q
|
||||||
skimmer: true
|
skimmer: true
|
||||||
ft8: false
|
ft8: true
|
||||||
ft4: false
|
ft4: false
|
||||||
command: #SET/NOFILTER
|
command: #SET/NOFILTER
|
||||||
login_prompt: "Please enter your call:"
|
login_prompt: "Please enter your call:"
|
||||||
|
@ -180,7 +180,7 @@ func (fc *FlexClient) SendSpottoFlex(spot TelnetSpot) {
|
|||||||
flexSpot.Priority = "1"
|
flexSpot.Priority = "1"
|
||||||
flexSpot.BackgroundColor = "#ff000000"
|
flexSpot.BackgroundColor = "#ff000000"
|
||||||
} else if spot.CallsignWorked {
|
} else if spot.CallsignWorked {
|
||||||
flexSpot.Color = "#ffeaeaea"
|
flexSpot.Color = "#ff000000"
|
||||||
flexSpot.BackgroundColor = "#ff00c0c0"
|
flexSpot.BackgroundColor = "#ff00c0c0"
|
||||||
flexSpot.Priority = "5"
|
flexSpot.Priority = "5"
|
||||||
flexSpot.Comment = flexSpot.Comment + " [Worked]"
|
flexSpot.Comment = flexSpot.Comment + " [Worked]"
|
||||||
@ -203,10 +203,6 @@ func (fc *FlexClient) SendSpottoFlex(spot TelnetSpot) {
|
|||||||
flexSpot.Color = "#ffeaeaea"
|
flexSpot.Color = "#ffeaeaea"
|
||||||
flexSpot.Priority = "5"
|
flexSpot.Priority = "5"
|
||||||
flexSpot.BackgroundColor = "#ff000000"
|
flexSpot.BackgroundColor = "#ff000000"
|
||||||
} else {
|
|
||||||
flexSpot.Color = "#ffeaeaea"
|
|
||||||
flexSpot.Priority = "5"
|
|
||||||
flexSpot.BackgroundColor = "#ff000000"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flexSpot.Comment = strings.ReplaceAll(flexSpot.Comment, " ", "\u00A0")
|
flexSpot.Comment = strings.ReplaceAll(flexSpot.Comment, " ", "\u00A0")
|
||||||
|
28
main.go
28
main.go
@ -4,7 +4,9 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ParseFlags() (string, error) {
|
func ParseFlags() (string, error) {
|
||||||
@ -42,7 +44,7 @@ func main() {
|
|||||||
cfg := NewConfig(cfgPath)
|
cfg := NewConfig(cfgPath)
|
||||||
|
|
||||||
log := NewLog()
|
log := NewLog()
|
||||||
log.Info("Running FlexDXCluster version 0.2")
|
log.Info("Running FlexDXCluster version 0.1")
|
||||||
log.Infof("Callsign: %s", cfg.SQLite.Callsign)
|
log.Infof("Callsign: %s", cfg.SQLite.Callsign)
|
||||||
|
|
||||||
DeleteDatabase("./flex.sqlite", log)
|
DeleteDatabase("./flex.sqlite", log)
|
||||||
@ -63,10 +65,32 @@ func main() {
|
|||||||
FlexClient := NewFlexClient(*fRepo, TCPServer, TCPClient.SpotChanToFlex)
|
FlexClient := NewFlexClient(*fRepo, TCPServer, TCPClient.SpotChanToFlex)
|
||||||
// HTTPServer := NewHTTPServer(*cRepo, *fRepo, TCPServer, TCPClient.SpotChanToHTTPServer)
|
// HTTPServer := NewHTTPServer(*cRepo, *fRepo, TCPServer, TCPClient.SpotChanToHTTPServer)
|
||||||
|
|
||||||
|
sigCh := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
|
||||||
|
|
||||||
go FlexClient.StartFlexClient()
|
go FlexClient.StartFlexClient()
|
||||||
go TCPClient.StartClient()
|
go TCPClient.StartClient()
|
||||||
go TCPServer.StartServer()
|
go TCPServer.StartServer()
|
||||||
|
|
||||||
CheckSignal(TCPClient, TCPServer, FlexClient, fRepo, cRepo)
|
// Gracely closing all connextions if signal is received
|
||||||
|
for sig := range sigCh {
|
||||||
|
log.Infof("received signal: %v, shutting down all connections.", sig)
|
||||||
|
|
||||||
|
TCPClient.Close()
|
||||||
|
TCPServer.Conn.Close()
|
||||||
|
FlexClient.Conn.Close()
|
||||||
|
|
||||||
|
if err := fRepo.db.Close(); err != nil {
|
||||||
|
log.Error("failed to close the database connection properly")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := cRepo.db.Close(); err != nil {
|
||||||
|
log.Error("failed to close Log4OM database connection properly")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
29
spot.go
29
spot.go
@ -96,8 +96,8 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChanToFlex chan Te
|
|||||||
SpotChanToFlex <- spot
|
SpotChanToFlex <- spot
|
||||||
|
|
||||||
if spot.NewDXCC {
|
if spot.NewDXCC {
|
||||||
Log.Debugf("(** New DXCC **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - DXCC: %s",
|
Log.Debugf("(** New DXCC **) DX: %s - Spotter: %s - Freq: %s - Band: %s - Mode: %s - Comment: %s - Time: %s - Command: %v, FlexSpot: %v",
|
||||||
spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.DXCC)
|
spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.CommandNumber, spot.FlexSpotNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !spot.NewDXCC && spot.NewBand && spot.NewMode {
|
if !spot.NewDXCC && spot.NewBand && spot.NewMode {
|
||||||
@ -131,61 +131,60 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChanToFlex chan Te
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (spot *TelnetSpot) GetBand() {
|
func (spot *TelnetSpot) GetBand() {
|
||||||
freq := FreqMhztoHz(spot.Frequency)
|
|
||||||
switch true {
|
switch true {
|
||||||
case strings.HasPrefix(freq, "1.8"):
|
case strings.HasPrefix(spot.Frequency, "1.8"):
|
||||||
spot.Band = "160M"
|
spot.Band = "160M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "LSB"
|
spot.Mode = "LSB"
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(freq, "3."):
|
case strings.HasPrefix(spot.Frequency, "3"):
|
||||||
spot.Band = "80M"
|
spot.Band = "80M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "LSB"
|
spot.Mode = "LSB"
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(freq, "5."):
|
case strings.HasPrefix(spot.Frequency, "5."):
|
||||||
spot.Band = "60M"
|
spot.Band = "60M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "LSB"
|
spot.Mode = "LSB"
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(freq, "7."):
|
case strings.HasPrefix(spot.Frequency, "7"):
|
||||||
spot.Band = "40M"
|
spot.Band = "40M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "LSB"
|
spot.Mode = "LSB"
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(freq, "10."):
|
case strings.HasPrefix(spot.Frequency, "10"):
|
||||||
spot.Band = "30M"
|
spot.Band = "30M"
|
||||||
case strings.HasPrefix(freq, "14."):
|
case strings.HasPrefix(spot.Frequency, "14"):
|
||||||
spot.Band = "20M"
|
spot.Band = "20M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "USB"
|
spot.Mode = "USB"
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(freq, "18."):
|
case strings.HasPrefix(spot.Frequency, "18"):
|
||||||
spot.Band = "17M"
|
spot.Band = "17M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "USB"
|
spot.Mode = "USB"
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(freq, "21."):
|
case strings.HasPrefix(spot.Frequency, "21"):
|
||||||
spot.Band = "15M"
|
spot.Band = "15M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "USB"
|
spot.Mode = "USB"
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(freq, "24."):
|
case strings.HasPrefix(spot.Frequency, "24"):
|
||||||
spot.Band = "12M"
|
spot.Band = "12M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "USB"
|
spot.Mode = "USB"
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(freq, "28."):
|
case strings.HasPrefix(spot.Frequency, "28"):
|
||||||
spot.Band = "10M"
|
spot.Band = "10M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "USB"
|
spot.Mode = "USB"
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(freq, "29."):
|
case strings.HasPrefix(spot.Frequency, "29"):
|
||||||
spot.Band = "10M"
|
spot.Band = "10M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "USB"
|
spot.Mode = "USB"
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(freq, "50."):
|
case strings.HasPrefix(spot.Frequency, "50"):
|
||||||
spot.Band = "6M"
|
spot.Band = "6M"
|
||||||
if spot.Mode == "SSB" {
|
if spot.Mode == "SSB" {
|
||||||
spot.Mode = "USB"
|
spot.Mode = "USB"
|
||||||
|
30
utils.go
30
utils.go
@ -2,10 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"syscall"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func FreqMhztoHz(freq string) string {
|
func FreqMhztoHz(freq string) string {
|
||||||
@ -29,30 +26,3 @@ func FreqHztoMhz(freq string) string {
|
|||||||
|
|
||||||
return strconv.FormatFloat(frequency, 'f', 6, 64)
|
return strconv.FormatFloat(frequency, 'f', 6, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckSignal(TCPClient *TCPClient, TCPServer *TCPServer, FlexClient *FlexClient, fRepo *FlexDXClusterRepository, cRepo *Log4OMContactsRepository) {
|
|
||||||
|
|
||||||
sigCh := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
|
|
||||||
|
|
||||||
// Gracely closing all connextions if signal is received
|
|
||||||
for sig := range sigCh {
|
|
||||||
Log.Infof("received signal: %v, shutting down all connections.", sig)
|
|
||||||
|
|
||||||
TCPClient.Close()
|
|
||||||
TCPServer.Conn.Close()
|
|
||||||
FlexClient.Conn.Close()
|
|
||||||
|
|
||||||
if err := fRepo.db.Close(); err != nil {
|
|
||||||
Log.Error("failed to close the database connection properly")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := cRepo.db.Close(); err != nil {
|
|
||||||
Log.Error("failed to close Log4OM database connection properly")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user