ip_allow

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

README

IP Allow Plugin

The IP allow plugin is a straight forward plugin for micro which allows IP addresses that can allow the API.

Current implementation accepts individual IPs or a CIDR.

Usage

Register the plugin before building Micro

package main

import (
	"github.com/micro/micro/plugin"
	ip "github.com/micro/go-plugins/micro/ip_allow"
)

func init() {
	plugin.Register(ip.NewIPAllow())
}

It can then be applied on the command line like so.

micro --ip_allow=10.1.1.10,10.1.1.11,10.1.2.0/24 api
Scoped to API

If you like to only apply the plugin for a specific component you can register it with that specifically. For example, below you'll see the plugin registered with the API.

package main

import (
	"github.com/micro/micro/api"
	ip "github.com/micro/go-plugins/micro/ip_allow"
)

func init() {
	api.Register(ip.NewIPAllow())
}

Here's what the help displays when you do that.

$ go run main.go link.go api --help
NAME:
   main api - Run the micro API

USAGE:
   main api [command options] [arguments...]

OPTIONS:
   --ip_allow 	Comma separated list of allowed IP addresses [$MICRO_IP_ALLOW]

In this case the usage would be

micro api --ip_allow 10.0.0.0/8

Documentation

Overview

Package ip_allow is a micro plugin for allowing ip addresses

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIPAllow

func NewIPAllow(ips ...string) plugin.Plugin

func NewPlugin

func NewPlugin() plugin.Plugin

Types

This section is empty.

Jump to

Keyboard shortcuts

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