GithubHelp home page GithubHelp logo

ivwsigemq / go-radius Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blind-oracle/go-radius

0.0 0.0 0.0 35 KB

Golang RADIUS library with server/client support

License: Mozilla Public License 2.0

Go 100.00%

go-radius's Introduction

go-radius

GoDoc cover.run Go Report Card

It's quite heavily rewritten fork of another Go RADIUS library

Significant changes are:

  • Common

    • Encoding/Decoding of attribute 26 (Vendor-Specific)
    • RFC2866 & RFC2869 (Accounting)
  • Server

    • Request throttling (maximum requests per second) support
    • Supports limiting the number of requests in processing queue
    • Multiple RADIUS Secrets based on packet's source IP with a fallback default
    • Request/Response packet replication (useful for logging, IDS etc)
    • Configurable UDP buffer size
  • Client

    • Lots of vendor-specific (Cisco, Juniper, Mikrotik) functions and constants
    • Support for generating CoA/Disconnect-Message packets

Installation

go get -u github.com/blind-oracle/go-radius

Server example

import (
    "github.com/blind-oracle/go-radius"
    "log"
)

func main() {
    handler := func (w radius.ResponseWriter, p *radius.Packet) {
        w.AccessAccept()
    }

    server := radius.Server{
        Addr:           "0.0.0.0:1812",
        Handler:        radius.HandlerFunc(handler),
        Secret:         []byte(o.RADIUSSecret),
        Dictionary:     radius.Builtin,
    }

    if err := server.ListenAndServe(); err != nil {
        log.Fatal(err)
    }
}

Client example

import (
    "github.com/blind-oracle/go-radius"
    "log"
)

func main() {
    client := radius.Client{}
    packet := radius.New(radius.CodeAccessRequest, []byte("VerySecret"))
    packet.Add("Calling-Station-Id", "NAS-Fake")

    reply, err := client.Exchange(packet, "1.2.3.4:1812")
    if err != nil {
        log.Fatalf(err)
    }

    switch reply.Code {
        case radius.CodeAccessAccept:
        log.Println("Accept")
        case radius.CodeAccessReject:
        log.Println("Reject")
    }
}

Authors

go-radius's People

Contributors

blind-oracle 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.