-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
44 lines (36 loc) · 910 Bytes
/
server.go
File metadata and controls
44 lines (36 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
Copyright (c) 2020-2022 by Eric Jacksch VE3XEJ
*/
package main
import (
"log"
"net"
"dmrcmd/bytes"
"dmrcmd/hotspot"
)
// Structure to hold UDP message metadata and contents
// This avoids having to pass multiple variables
type datagram struct {
pc net.PacketConn // connection
addr net.Addr // source address
data bytes.Bytes // data
hotspot bytes.Bytes // hotspot ID
proxy bool // proxy mode flag
local bool // datagram is from local hotspot (proxy mode only)
drop bool // drop packet flag (proxy mode only)
}
func startServer(id uint32) {
// CheckAuthenticated that repeater entry exists
if !hotspot.Exists(id) {
log.Printf("Unable to start server, %d does not exist", id)
return
}
// Get repeater configuration
h := hotspot.Get(id)
// Start server or proxy
if h.Proxy {
dmrProxy(h)
} else {
dmrServer(h)
}
}