Coder Social home page Coder Social logo

miekgrrl's Introduction

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.

Copyright and License

miekgrrl is Copyright Šī¸ 2023 Mark Delany and is licensed under the BSD 2-Clause "Simplified" License.

miekgrrl's People

Contributors

markdingo avatar dependabot[bot] avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.