clients

package
v0.0.0-...-9dcd7e1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(ctx context.Context, url string, logger *log.Logger) (io.ReadCloser, error)

DownloadFile fetches the specified URL and returns the body wrapped in a limiter

func OAuthInit

func OAuthInit(ctx context.Context, endpoint, userTokenName string, scopes []string, logger *log.Logger) (string, error)

OAuthInit goes through an OAuth authentication cycle, returning an admin-scoped bearer token for use with a GTS or AkkomaDB client

Types

type AkkomaConfig

type AkkomaConfig struct {
	Configs    []AkkomaEntry `json:"configs"`
	NeedReboot bool          `json:"need_reboot"`
}

type AkkomaDB

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

func (*AkkomaDB) Connect

func (g *AkkomaDB) Connect(ctx context.Context) error

Connect confirms that we are able to access the instance

func (*AkkomaDB) List

func (g *AkkomaDB) List(ctx context.Context) ([]ServerEntry, Stringable, error)

List fetches the list of allowed domains from the server

func (*AkkomaDB) Update

func (g *AkkomaDB) Update(ctx context.Context, plan Plan, fromList Stringable) error

Update applies the provided Plan of allowlist changes to the server

type AkkomaEntry

type AkkomaEntry struct {
	Group string      `json:"group"`
	Key   string      `json:"key"`
	Value interface{} `json:"value"`
	DB    []string    `json:"db"`
}

type AkkomaUpdates

type AkkomaUpdates struct {
	Configs []AkkomaEntry `json:"configs"`
}

func (*AkkomaUpdates) String

func (u *AkkomaUpdates) String() string

type Client

type Client interface {
	// Connect confirms that we are able to access the instance
	Connect(ctx context.Context) error

	// List fetches the list of allowed domains from the server
	List(ctx context.Context) ([]ServerEntry, Stringable, error)

	// Update applies the provided Plan of allowlist changes to the server
	Update(ctx context.Context, plan Plan, fromList Stringable) error
}

func NewAkkomaDB

func NewAkkomaDB(endpoint string, bearerToken string, logger *log.Logger) Client

func NewGTS

func NewGTS(endpoint string, bearerToken string, logger *log.Logger) Client

type GTS

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

func (*GTS) Connect

func (g *GTS) Connect(ctx context.Context) error

Connect confirms that we are able to access the instance

func (*GTS) List

func (g *GTS) List(ctx context.Context) ([]ServerEntry, Stringable, error)

List fetches the list of allowed domains from the server

func (*GTS) Update

func (g *GTS) Update(ctx context.Context, plan Plan, fromList Stringable) error

Update applies the provided Plan of allowlist changes to the server

type Plan

type Plan struct {
	// ToAdd contains new allowlist entries to be added at the server
	ToAdd []data.Domain
	// ToRemove contains old allowlist entries to be removed from the server
	ToRemove []ServerEntry
	// NoChange contains current allowlist entries which already exist at the server
	NoChange []data.Domain
}

func (*Plan) String

func (p *Plan) String() string

type ServerEntry

type ServerEntry struct {
	// ID is an implementation-specific unique ID, for use in Remove()
	ID string
	// Domain is the domain name of the entry
	Domain string
}

type Stringable

type Stringable interface {
	String() string
}

Jump to

Keyboard shortcuts

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