Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better generalize base client package #11

Open
Ulexus opened this issue Mar 28, 2020 · 0 comments
Open

Better generalize base client package #11

Ulexus opened this issue Mar 28, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Ulexus
Copy link
Contributor

Ulexus commented Mar 28, 2020

It would be useful to generalize an interface for an apiban store so as to facilitate more clients and intermediate caching and storage.

Proposing the following definitions:

// Store defines and interface for storing and retrieving entries in the APIBan database, local or remote
type Store interface {

	// Add inserts the given Listing into the store.  Listing may be sparse, requiring only the IP.  Returned value will be fully populated.
	Add(ip *Listing) (*Listing, error)

	// Exists checks to see whether the given IP matches a Listing in the store, returning the first matching Listing, if one exists.
	Exists(ip net.IP) (*Listing, error)

	// List retrieves the contents of the store
	List() ([]*Listing, error)

	// ListFromTime retrieves the contents of the store from the given timestamp
	ListFromTime(t time.Time) ([]*Listing, error)

	// Remove deletes the given Listing from the store
	Remove(ip *Listing) error

	// Reset empties the store
	Reset() error
}

// Listing is an individually-listed IP address or subnet
type Listing struct {

	// ID is the unique identifier for this Listing
	ID string

	// Timestamp is the time at which this Listing was added to the apiban.org database
	Timestamp time.Time

	// IP is the IP address or IP network which is in the apiban.org database
	IP net.IPNet
}

This will set us up to have a pluggable system of stores by which we can make an extensible, pluggable set of client functions.

Ulexus added a commit to CyCoreSystems/apiban that referenced this issue Mar 28, 2020
Define and use a standard Store interface for the client library.  This
will allow us to extend the client to greater uses later.

Fixes palner#11

Signed-off-by: Seán C McCord <[email protected]>
Ulexus added a commit to CyCoreSystems/apiban that referenced this issue Mar 28, 2020
Define and use a standard Store interface for the client library.  This
will allow us to extend the client to greater uses later.

As an example, a RAM-based caching store has been implemented.

Fixes palner#11

Signed-off-by: Seán C McCord <[email protected]>
Ulexus added a commit to CyCoreSystems/apiban that referenced this issue Mar 30, 2020
Define and use a standard Store interface for the client library.  This
will allow us to extend the client to greater uses later.

As an example, a RAM-based caching store has been implemented.

Fixes palner#11

Signed-off-by: Seán C McCord <[email protected]>
Ulexus added a commit to CyCoreSystems/apiban that referenced this issue Mar 30, 2020
Define and use a standard Store interface for the client library.  This
will allow us to extend the client to greater uses later.

As an example, a RAM-based caching store has been implemented.

Fixes palner#11

Signed-off-by: Seán C McCord <[email protected]>
@fredposner fredposner added the enhancement New feature or request label Nov 2, 2021
@fredposner fredposner self-assigned this Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants