()
| 89 | } |
| 90 | |
| 91 | func (i *IPFIX) run() { |
| 92 | // exit if the ipfix is disabled |
| 93 | if !opts.IPFIXEnabled { |
| 94 | logger.Println("ipfix has been disabled") |
| 95 | return |
| 96 | } |
| 97 | |
| 98 | i.pool = make(chan chan struct{}, maxWorkers) |
| 99 | |
| 100 | hostPort := net.JoinHostPort(i.addr, strconv.Itoa(i.port)) |
| 101 | udpAddr, _ := net.ResolveUDPAddr("udp", hostPort) |
| 102 | |
| 103 | conn, err := net.ListenUDP("udp", udpAddr) |
| 104 | if err != nil { |
| 105 | logger.Fatal(err) |
| 106 | } |
| 107 | |
| 108 | atomic.AddInt32(&i.stats.Workers, int32(i.workers)) |
| 109 | for n := 0; n < i.workers; n++ { |
| 110 | go func() { |
| 111 | wQuit := make(chan struct{}) |
| 112 | i.pool <- wQuit |
| 113 | i.ipfixWorker(wQuit) |
| 114 | }() |
| 115 | } |
| 116 | |
| 117 | logger.Printf("ipfix is running (UDP: listening on [::]:%d workers#: %d)", i.port, i.workers) |
| 118 | |
| 119 | err = ipfix.LoadExtElements(opts.VFlowConfigPath) |
| 120 | if err != nil { |
| 121 | logger.Println("load.ext.elements:", err) |
| 122 | } |
| 123 | |
| 124 | mCache = ipfix.GetCache(opts.IPFIXTplCacheFile) |
| 125 | go ipfix.RPC(mCache, &ipfix.RPCConfig{ |
| 126 | Enabled: opts.IPFIXRPCEnabled, |
| 127 | Logger: logger, |
| 128 | }) |
| 129 | |
| 130 | go mirrorIPFIXDispatcher(ipfixMCh) |
| 131 | |
| 132 | go func() { |
| 133 | if !opts.ProducerEnabled { |
| 134 | return |
| 135 | } |
| 136 | |
| 137 | p := producer.NewProducer(opts.MQName) |
| 138 | p.MQConfigFile = path.Join(opts.VFlowConfigPath, opts.MQConfigFile) |
| 139 | p.MQErrorCount = &i.stats.MQErrorCount |
| 140 | p.Logger = logger |
| 141 | p.Chan = ipfixMQCh |
| 142 | p.Topic = opts.IPFIXTopic |
| 143 | |
| 144 | if err := p.Run(); err != nil { |
| 145 | logger.Fatal(err) |
| 146 | } |
| 147 | }() |
| 148 |
nothing calls this directly
no test coverage detected