input Getenvs to FlagXYZ
This commit is contained in:
@@ -8,6 +8,10 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var (
|
||||
FlagDebug = os.Getenv("DEBUG") == "true"
|
||||
)
|
||||
|
||||
type UDP struct {
|
||||
conn net.PacketConn
|
||||
c chan []byte
|
||||
@@ -29,14 +33,13 @@ func NewUDP(ctx context.Context, port int) UDP {
|
||||
}
|
||||
|
||||
func (udp UDP) listen() {
|
||||
debugging := os.Getenv("DEBUG") == "true"
|
||||
for udp.ctx.Err() == nil {
|
||||
buff := make([]byte, 256)
|
||||
n, _, err := udp.conn.ReadFrom(buff)
|
||||
if err != nil && udp.ctx.Err() == nil {
|
||||
panic(err)
|
||||
}
|
||||
if debugging {
|
||||
if FlagDebug {
|
||||
log.Printf("raw.UDP.Read() => %s", buff[:n])
|
||||
}
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user