code: func (rule *edns0SubnetRule) fillEcsData(w dns.ResponseWriter, r *dns.Msg,
  	ecs *dns.EDNS0_SUBNET) error {
  
  	req := request.Request{W: w, Req: r}
  	family := req.Family()
  	if (family != 1) && (family != 2) {
  		return fmt.Errorf("unable to fill data for EDNS0 subnet due to invalid IP family")
  	}
  
  	ecs.Family = uint16(family)
  	ecs.SourceScope = 0
  
  	ipAddr := req.IP()
  	switch family {
  	case 1:
  		ipv4Mask := net.CIDRMask(int(rule.v4BitMaskLen), 32)
  		ipv4Addr := net.ParseIP(ipAddr)
  		ecs.SourceNetmask = rule.v4BitMaskLen
  		ecs.Address = ipv4Addr.Mask(ipv4Mask).To4()
  	case 2:
  		ipv6Mask := net.CIDRMask(int(rule.v6BitMaskLen), 128)
  		ipv6Addr := net.ParseIP(ipAddr)
  		ecs.SourceNetmask = rule.v6BitMaskLen
  		ecs.Address = ipv6Addr.Mask(ipv6Mask).To16()
  	}
  	return nil
  }
docs: // fillEcsData sets the subnet data into the ecs option