CoreBGP 是一款用 Go 编写的 BGP 库,它采用基于事件的可插拔模型来实现 BGP FSM。
CoreBGP is a BGP library written in Go that implements the BGP FSM with an event-driven, pluggable model. It exposes an API that empowers the user to:
CoreBGP provides optional, composable UPDATE message decoding facilities via UpdateDecoder. CoreBGP does not manage a routing table or send its own UPDATE messages. Those responsibilities are passed down to the user. Therefore, the intended user is someone who wants that responsibility.
See this blog post for the background and reasoning behind the development of CoreBGP.
The primary building block of CoreBGP is a Plugin, defined by the following interface:
…Here's an example Plugin that logs when a peer enters/leaves an established state and when an UPDATE message is received:
…Plugins are attached to peers when they are added to the Server, which manages their lifetime:
routerID := netip.MustParseAddr("192.0.2.1")
srv, err := corebgp.NewServer(routerID)
if err != nil {
log.Fatalf("error constructing server: %v", err)
}
p := &plugin{}
err = srv.AddPeer(corebgp.PeerConfig{
RemoteAddress: netip.MustParseAddr("198.51.100.10"),
LocalAS: 65001,
RemoteAS: 65010,
}, p, corebgp.WithLocalAddress(routerID))
if err != nil {
log.Fatalf("error adding peer: %v", err)
}For more examples check out the examples directory and pkg.go.dev for the complete API.
CoreBGP follows semver as closely as it can. Seeing as we are still major version zero (0.y.z), the public API should not be considered stable. You are encouraged to pin CoreBGP's version with your dependency management solution of choice.
暂无开放 Issues,或尚未同步最近议题。