peer_whitelist

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCIDRs

func ParseCIDRs(cidrs []string) ([]*net.IPNet, error)

ParseCIDRs shortcut for easy converting CIDR(s) string slice to net.IPNet slice

func ServerPeerWhitelist

func ServerPeerWhitelist(whitelist []*net.IPNet) grpc.UnaryServerInterceptor

ServerPeerWhitelist provides server client whitelist by CIDR(s)

Example
whitelistNetworks, err := ParseCIDRs([]string{
	"127.0.0.1/24",
})

if err != nil {
	log.Fatalln("")
}

grpcServer := grpc.NewServer(
	grpc.ChainUnaryInterceptor(
		ServerPeerWhitelist(whitelistNetworks), // nil for log.Default() as logger
	),
)
fmt.Println(grpcServer)
// ...
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL