[TASK] Allow binding to arbitrary ports for respondd querying (#48)
Allow binding respondd to a specific port
This commit is contained in:
parent
4550887f69
commit
c4d8fbd4df
@ -19,7 +19,7 @@ func main() {
|
||||
|
||||
nodes := models.NewNodes(&models.Config{})
|
||||
|
||||
collector := respond.NewCollector(nil, nodes, iface)
|
||||
collector := respond.NewCollector(nil, nodes, iface, 0)
|
||||
collector.SendPacket(net.ParseIP(dstAddress))
|
||||
|
||||
time.Sleep(time.Second)
|
||||
|
@ -50,7 +50,7 @@ func main() {
|
||||
nodes.Start()
|
||||
|
||||
if config.Respondd.Enable {
|
||||
collector = respond.NewCollector(db, nodes, config.Respondd.Interface)
|
||||
collector = respond.NewCollector(db, nodes, config.Respondd.Interface, config.Respondd.Port)
|
||||
collector.Start(config.Respondd.CollectInterval.Duration)
|
||||
defer collector.Close()
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ enable = true
|
||||
collect_interval = "1m"
|
||||
# on which interface
|
||||
interface = "eth0"
|
||||
# define a port to listen
|
||||
# (no or 0 would choose at port at his own)
|
||||
#port = 10001
|
||||
|
||||
|
||||
# A little build-in webserver, which statically serves a directory.
|
||||
|
@ -11,6 +11,7 @@ type Config struct {
|
||||
Respondd struct {
|
||||
Enable bool
|
||||
Interface string
|
||||
Port int
|
||||
CollectInterval Duration
|
||||
}
|
||||
Webserver struct {
|
||||
|
@ -27,7 +27,7 @@ type Collector struct {
|
||||
}
|
||||
|
||||
// NewCollector creates a Collector struct
|
||||
func NewCollector(db *database.DB, nodes *models.Nodes, iface string) *Collector {
|
||||
func NewCollector(db *database.DB, nodes *models.Nodes, iface string, port int) *Collector {
|
||||
linkLocalAddr, err := getLinkLocalAddr(iface)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
@ -36,6 +36,7 @@ func NewCollector(db *database.DB, nodes *models.Nodes, iface string) *Collector
|
||||
// Open socket
|
||||
conn, err := net.ListenUDP("udp", &net.UDPAddr{
|
||||
IP: linkLocalAddr,
|
||||
Port: port,
|
||||
Zone: iface,
|
||||
})
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user