mirror of
https://github.com/alice-lg/alice-lg.git
synced 2024-05-11 05:55:03 +00:00
21 lines
361 B
Go
21 lines
361 B
Go
![]() |
package gobgp;
|
||
|
|
||
|
import (
|
||
|
// Standard imports
|
||
|
"crypto/sha1"
|
||
|
"io"
|
||
|
"fmt"
|
||
|
|
||
|
// External imports
|
||
|
api "github.com/osrg/gobgp/api"
|
||
|
|
||
|
// Internal imports
|
||
|
)
|
||
|
|
||
|
func PeerHash(peer *api.Peer) (string) {
|
||
|
h := sha1.New()
|
||
|
io.WriteString(h, string(peer.State.PeerAs))
|
||
|
io.WriteString(h, peer.State.NeighborAddress)
|
||
|
sum := h.Sum(nil)
|
||
|
return fmt.Sprintf("%x",sum[0:5])
|
||
|
}
|