| 
									
										
										
										
											2016-03-28 12:08:05 +01:00
										 |  |  | package file
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-03 07:37:41 +01:00
										 |  |  | import (
 | 
					
						
							| 
									
										
										
										
											2017-06-21 23:46:20 -07:00
										 |  |  | 	"net"
 | 
					
						
							| 
									
										
										
										
											2016-04-03 07:37:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-21 22:51:47 -08:00
										 |  |  | 	"github.com/coredns/coredns/request"
 | 
					
						
							| 
									
										
										
										
											2016-04-03 07:44:28 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-03 07:37:41 +01:00
										 |  |  | 	"github.com/miekg/dns"
 | 
					
						
							|  |  |  | )
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-05 10:53:23 +01:00
										 |  |  | // isNotify checks if state is a notify message and if so, will *also* check if it
 | 
					
						
							|  |  |  | // is from one of the configured masters. If not it will not be a valid notify
 | 
					
						
							|  |  |  | // message. If the zone z is not a secondary zone the message will also be ignored.
 | 
					
						
							| 
									
										
										
										
											2016-09-07 11:10:16 +01:00
										 |  |  | func (z *Zone) isNotify(state request.Request) bool {
 | 
					
						
							| 
									
										
										
										
											2016-04-05 10:53:23 +01:00
										 |  |  | 	if state.Req.Opcode != dns.OpcodeNotify {
 | 
					
						
							|  |  |  | 		return false
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | 	if len(z.TransferFrom) == 0 {
 | 
					
						
							|  |  |  | 		return false
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							| 
									
										
										
										
											2017-06-21 23:46:20 -07:00
										 |  |  | 	// If remote IP matches we accept.
 | 
					
						
							|  |  |  | 	remote := state.IP()
 | 
					
						
							|  |  |  | 	for _, f := range z.TransferFrom {
 | 
					
						
							|  |  |  | 		from, _, err := net.SplitHostPort(f)
 | 
					
						
							|  |  |  | 		if err != nil {
 | 
					
						
							|  |  |  | 			continue
 | 
					
						
							|  |  |  | 		}
 | 
					
						
							| 
									
										
										
										
											2016-04-05 10:53:23 +01:00
										 |  |  | 		if from == remote {
 | 
					
						
							|  |  |  | 			return true
 | 
					
						
							|  |  |  | 		}
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | 	return false
 | 
					
						
							|  |  |  | }
 |