2018-06-03 20:37:52 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								package controller
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import (
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									"net"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-28 16:24:29 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// "github.com/bdlm/log"
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-03 20:37:52 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-03-08 05:57:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									"dev.sum7.eu/genofire/wifictld-analyzer/capture"
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-03 20:37:52 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-03-08 05:57:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								func (c *Controller) Handler(addr *net.UDPAddr, msg *capture.SocketMSG) (*capture.SocketMSG, error) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-03 20:37:52 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ignore := false
							 | 
						
					
						
							
								
									
										
										
										
											2019-03-08 05:57:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if msg.Types.Is(capture.SocketMSGTypeClient) && msg.Client != nil {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-03 20:37:52 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ignore = c.db.LearnClient(addr.IP, msg.Client)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2019-03-08 05:57:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if !msg.Types.Is(capture.SocketMSGTypeRequest) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-03 20:37:52 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										return nil, nil
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-03-08 05:57:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									msg = &capture.SocketMSG{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Types:  (capture.SocketMSGTypeResponse | capture.SocketMSGTypeClient),
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-03 20:37:52 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Client: c.db.GetClient(msg.Client.Addr),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-16 13:00:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if !ignore {
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-03 20:37:52 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										return msg, nil
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									return nil, nil
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |