[BUGFIX] binding listen port

This commit is contained in:
Martin Geno 2017-10-26 15:24:04 +02:00
parent dbc1353154
commit 9ee424b912
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941

View File

@ -19,6 +19,7 @@ import (
type Collector struct { type Collector struct {
connections []*net.UDPConn // UDP sockets connections []*net.UDPConn // UDP sockets
ifaceToConn map[string]*net.UDPConn // map from interface name to UDP socket ifaceToConn map[string]*net.UDPConn // map from interface name to UDP socket
port int
queue chan *Response // received responses queue chan *Response // received responses
db database.Connection db database.Connection
@ -33,6 +34,7 @@ func NewCollector(db database.Connection, nodes *runtime.Nodes, ifaces []string,
coll := &Collector{ coll := &Collector{
db: db, db: db,
nodes: nodes, nodes: nodes,
port: port,
queue: make(chan *Response, 400), queue: make(chan *Response, 400),
stop: make(chan interface{}), stop: make(chan interface{}),
ifaceToConn: make(map[string]*net.UDPConn), ifaceToConn: make(map[string]*net.UDPConn),
@ -63,7 +65,7 @@ func (coll *Collector) listenUDP(iface string) {
// Open socket // Open socket
conn, err := net.ListenUDP("udp", &net.UDPAddr{ conn, err := net.ListenUDP("udp", &net.UDPAddr{
IP: linkLocalAddr, IP: linkLocalAddr,
Port: port, Port: coll.port,
Zone: iface, Zone: iface,
}) })
if err != nil { if err != nil {