kopia lustrzana https://github.com/cyoung/stratux
Gofmt.
rodzic
cfd8b9fcaf
commit
1ba6f744ea
12
gen_gdl90.go
12
gen_gdl90.go
|
@ -17,7 +17,6 @@ import (
|
||||||
const (
|
const (
|
||||||
stratuxVersion = "v0.1"
|
stratuxVersion = "v0.1"
|
||||||
configLocation = "/etc/stratux.conf"
|
configLocation = "/etc/stratux.conf"
|
||||||
ipadAddr = "192.168.10.255:4000" // Port 4000 for FreeFlight RANGR.
|
|
||||||
managementAddr = "127.0.0.1:9110"
|
managementAddr = "127.0.0.1:9110"
|
||||||
maxDatagramSize = 8192
|
maxDatagramSize = 8192
|
||||||
UPLINK_BLOCK_DATA_BITS = 576
|
UPLINK_BLOCK_DATA_BITS = 576
|
||||||
|
@ -357,11 +356,10 @@ func parseInput(buf string) ([]byte, uint16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type settings struct {
|
type settings struct {
|
||||||
UAT_Enabled bool
|
UAT_Enabled bool
|
||||||
ES_Enabled bool
|
ES_Enabled bool
|
||||||
GPS_Enabled bool
|
GPS_Enabled bool
|
||||||
GDLOutputPorts []uint16
|
GDLOutputPorts []uint16
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type status struct {
|
type status struct {
|
||||||
|
@ -492,7 +490,7 @@ func main() {
|
||||||
go gpsReader()
|
go gpsReader()
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: network stuff
|
//TODO: network stuff
|
||||||
|
|
||||||
// Start the heartbeat message loop in the background, once per second.
|
// Start the heartbeat message loop in the background, once per second.
|
||||||
go heartBeatSender()
|
go heartBeatSender()
|
||||||
|
|
15
network.go
15
network.go
|
@ -1,19 +1,18 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"time"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"log"
|
||||||
"strconv"
|
|
||||||
"net"
|
"net"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var messageQueue chan []byte
|
var messageQueue chan []byte
|
||||||
var outSockets map[string]*net.UDPConn
|
var outSockets map[string]*net.UDPConn
|
||||||
var dhcpLeases map[string]string
|
var dhcpLeases map[string]string
|
||||||
|
|
||||||
|
|
||||||
// Read the "dhcpd.leases" file and parse out IP/hostname.
|
// Read the "dhcpd.leases" file and parse out IP/hostname.
|
||||||
func getDHCPLeases() (map[string]string, error) {
|
func getDHCPLeases() (map[string]string, error) {
|
||||||
dat, err := ioutil.ReadFile("/var/lib/dhcp/dhcpd.leases")
|
dat, err := ioutil.ReadFile("/var/lib/dhcp/dhcpd.leases")
|
||||||
|
@ -94,14 +93,14 @@ func messageQueueSender() {
|
||||||
dhcpRefresh := time.NewTicker(30 * time.Second)
|
dhcpRefresh := time.NewTicker(30 * time.Second)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case msg := <- messageQueue:
|
case msg := <-messageQueue:
|
||||||
sendToAllConnectedClients(msg)
|
sendToAllConnectedClients(msg)
|
||||||
case <-secondTimer.C:
|
case <-secondTimer.C:
|
||||||
getNetworkStats()
|
getNetworkStats()
|
||||||
case <-dhcpRefresh.C:
|
case <-dhcpRefresh.C:
|
||||||
refreshConnectedClients()
|
refreshConnectedClients()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,4 +113,4 @@ func initNetwork() {
|
||||||
outSockets = make(map[string]*net.UDPConn)
|
outSockets = make(map[string]*net.UDPConn)
|
||||||
refreshConnectedClients()
|
refreshConnectedClients()
|
||||||
go messageQueueSender()
|
go messageQueueSender()
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue