RPSL Go is a Go library for parsing and handling RFC 2622: Routing Policy Specification Language (RPSL) attributes and objects.
Important
The goal of this library is to parse responses provided by the RIPE database. It is not a full implementation of the RPSL specification. See the Restrictions section for more information.
To install the library, use go get
:
go get github.com/frederic-arr/rpsl-go
package main
import (
"fmt"
"log"
"github.com/frederic-arr/rpsl-go"
)
func main() {
raw := "person: John Doe\n" +
"address: 1234 Elm Street Iceland\n" +
"phone: +1 555 123456\n" +
"nic-hdl: JD1234-RIPE\n" +
"mnt-by: FOO-MNT\n" +
"mnt-by: BAR-MNT\n" +
"source: RIPE"
obj, err := rpsl.Parse(raw)
if err != nil {
log.Fatalf("parseObject => %v", err)
}
address := obj.GetFirst("address")
fmt.Printf("--- Address ---\n")
fmt.Printf("%s\n\n", address.Value)
maintainers := obj.GetAll("mnt-by")
fmt.Printf("--- Maintainers ---\n")
for _, m := range maintainers {
fmt.Printf("%s\n", m.Value)
}
}
See the output by running go run examples/object.go
in this repository.
- No validation regarding the object is performed.
- No validation regarding the attribute values is performed.
This library is inspired by the RIPE Whois Database and it's RPSL Parser.
Copyright (c) The RPSL Go Authors. Apache 2.0 License.