miekgrrl

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2023 License: BSD-2-Clause Imports: 2 Imported by: 1

README

miekgrrl - Derive an rrl ResponseTuple from a miekg Msg

Introduction

miekgrrl is a tiny specialized adaptor package with a single Derive() function which converts a miekg/dns.Msg to a rrl.ResponseTuple suitable for passing to the rrl Debit() function.

By way of background, the rrl package is an agnostic implementation of the Response Rate Limiting algorithm as originally developed by ISC. You will need to be familiar with both the rrl and the miekg package prior to understanding the purpose of this package.

The sole reason for adaptor packages such as this is to keep markdingo/rrl agnostic.

Project Status

Build Status codecov CodeQL Go Report Card Go Reference

Sample Code

package main

import (
    "net"

    "github.com/markdingo/miekgrrl"
    "github.com/markdingo/rrl"
    "github.com/miekg/dns"
)

func main() {

  R := rrl.NewRRL(rrl.NewConfig())
  response := &dns.Msg{}
  ... populate response ...

  tuple := miekgrrl.Derive(response, "")   // Derive the RRL.ResponseTuple from dns.Msg

  action, _, _ := R.Debit(net.Addr, tuple) // Apply RRL rules to ResponseTuple
  switch action {
      case rrl.Drop:
      ...
      case rrl.Send:
      ..
      case rrl.Slip:
      ..

Alternatively, the Derive() function is designed such that it can be used directly as an argument to the rrl.Debit() function. E.g:

  ...
  R := rrl.NewRRL(rrl.NewConfig())
  response := &dns.Msg{}
  ... populate response ...

  action, _, _ := R.Debit(net.Addr, miekgrrl.Derive(response, ""))
  switch action {
  ...

Installation

miekgrrl requires go version 1.19 or later.

Once your application imports "github.com/markdingo/miekgrrl", then "go build" or "go mod tidy" should download and compile the miekgrrl package automatically.

Community

If you have any problems using miekgrrl or suggestions on how it can do a better job, don't hesitate to create an issue on the project home page. This package can only improve with your feedback.

miekgrrl is Copyright © 2023 Mark Delany and is licensed under the BSD 2-Clause "Simplified" License.

Documentation

Overview

Package miekgrrl is a tiny helper package which creates a github.com/markdingo/rrl.ResponseTuple from a github.com/miekg/dns.Msg.

A “ResponseTuple” is passed to the github.com/markdingo/rrl.Debit function for “Response Rate Limiting” analysis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Derive

func Derive(response *dns.Msg, wildcardOriginName string) (tuple *rrl.ResponseTuple)

Derive creates a github.com/markdingo/rrl.ResponseTuple from a github.com/miekg/dns response Msg for the purpose of passing to the github.com/markdingo/rrl.Debit “Response Rate Limiting” function.

If the response has been formulated from a wildcard the caller *must* supply the origin name of the owning zone in the wildcardOriginName argument. Normally that will be qName with the first label removed but the following is also a valid zone:

$ORIGIN example.net.
*.a.b.c IN TXT "my origin name is example.net."

thus one cannot blindly remove the first label and hope for the best.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL