firewall

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package firewall wraps the DigitalOcean Cloud Firewalls API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOptions

type CreateOptions struct {
	Name          string
	InboundRules  []RuleSpec
	OutboundRules []RuleSpec
	DropletIDs    []int
	Tags          []string
}

CreateOptions holds parameters for creating a firewall.

type RuleSpec

type RuleSpec struct {
	Protocol  string
	PortRange string
	Addresses []string // "any" expands to "0.0.0.0/0,::/0"
}

RuleSpec is a human-friendly rule definition. Format: "proto:ports:addresses" Examples:

"tcp:443:any"           -> allow TCP 443 from anywhere
"tcp:22:203.0.113.1"    -> allow TCP 22 from a specific IP
"tcp:8080-8090:10.0.0.0/8" -> allow TCP range from CIDR
"icmp:0:any"            -> allow ICMP from anywhere

func ParseRuleSpec

func ParseRuleSpec(s string) (RuleSpec, error)

ParseRuleSpec parses a "proto:ports:addr1,addr2" string into a RuleSpec.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service exposes firewall operations against the DigitalOcean API.

func New

func New(client *godo.Client) *Service

New returns a new Firewall Service.

func (*Service) AddInboundRules

func (s *Service) AddInboundRules(ctx context.Context, id string, rules []RuleSpec) error

AddInboundRules appends inbound rules to an existing firewall.

func (*Service) AddOutboundRules

func (s *Service) AddOutboundRules(ctx context.Context, id string, rules []RuleSpec) error

AddOutboundRules appends outbound rules to an existing firewall.

func (*Service) AttachDroplets

func (s *Service) AttachDroplets(ctx context.Context, id string, dropletIDs ...int) error

AttachDroplets adds Droplet IDs to an existing firewall.

func (*Service) Create

func (s *Service) Create(ctx context.Context, opts CreateOptions) (*godo.Firewall, error)

Create creates a new firewall.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

Delete deletes a firewall by ID.

func (*Service) DetachDroplets

func (s *Service) DetachDroplets(ctx context.Context, id string, dropletIDs ...int) error

DetachDroplets removes Droplet IDs from an existing firewall.

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (*godo.Firewall, error)

Get returns a single firewall by ID.

func (*Service) List

func (s *Service) List(ctx context.Context) ([]godo.Firewall, error)

List returns all firewalls in the account.

func (*Service) ListByDroplet

func (s *Service) ListByDroplet(ctx context.Context, dropletID int) ([]godo.Firewall, error)

ListByDroplet returns all firewalls attached to a given Droplet.

Jump to

Keyboard shortcuts

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