mmdbserver

package module
v0.0.0-...-1853235 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 14 Imported by: 0

README

MMDB Server

The MMDB Server is geoipupdate server-side implementation, ability to help you implement delivery using geoipupdate for 3rd-party ip database.

References

LICENSE

MIT LICENSE

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidEditionID  = &Error{StatusCode: http.StatusBadRequest, Message: "Invalid Edition ID"}
	ErrInvalidAccountID  = &Error{StatusCode: http.StatusBadRequest, Message: "Invalid Account ID"}
	ErrInvalidSuffix     = &Error{StatusCode: http.StatusBadRequest, Message: "Invalid Suffix Name"}
	ErrInvalidDate       = &Error{StatusCode: http.StatusBadRequest, Message: "Invalid Date"}
	ErrInvalidMD5Hash    = &Error{StatusCode: http.StatusBadRequest, Message: "Invalid MD5 Hash"}
	ErrInvalidLicenseKey = &Error{StatusCode: http.StatusUnauthorized, Message: "Invalid License Key"}
	ErrMethodNotAllowed  = &Error{StatusCode: http.StatusMethodNotAllowed}
	ErrDatabaseNotFound  = &Error{StatusCode: http.StatusNotFound, Message: "Database not found"}
	ErrDatabaseLatest    = &Error{StatusCode: http.StatusNotModified, Message: "Database is latest"}
)

Functions

func WriteError

func WriteError(rw http.ResponseWriter, err error)

Types

type DownloadHandler

type DownloadHandler func(rw http.ResponseWriter, r *DownloadRequest) error

func (DownloadHandler) ServeHTTP

func (h DownloadHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type DownloadRequest

type DownloadRequest struct {
	EditionID  string
	Date       time.Time
	Suffix     string
	LicenseKey string
}

type Error

type Error struct {
	StatusCode int
	Message    string
}

func (*Error) Error

func (e *Error) Error() string

type MMDBHandler

type MMDBHandler interface {
	ServeMMDB(*Response, *Request) error
}

type MMDBHandlerFunc

type MMDBHandlerFunc func(*Response, *Request) error

func (MMDBHandlerFunc) ServeMMDB

func (h MMDBHandlerFunc) ServeMMDB(resp *Response, r *Request) error

type MMDBUpdateHandler

type MMDBUpdateHandler struct {
	HomePage string
	MMDBHandler
}

func (*MMDBUpdateHandler) ServeHTTP

func (h *MMDBUpdateHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Request

type Request struct {
	AccountID  string `json:"account_id"`
	LicenseKey string `json:"license_key"`
	EditionID  string `json:"edition_id"`
	MD5Hash    []byte `json:"md5_hash"`
}

func NewRequest

func NewRequest(r *http.Request) (request *Request, err error)

func (*Request) EqualHash

func (r *Request) EqualHash(md5Hash []byte) bool

func (*Request) NewDeploy

func (r *Request) NewDeploy() bool

type Response

type Response struct {
	ModTime time.Time
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse() (response *Response)

func (*Response) MD5Hash

func (r *Response) MD5Hash() []byte

func (*Response) ReadFile

func (r *Response) ReadFile(file fs.File) (n int64, err error)

func (*Response) ReadFrom

func (r *Response) ReadFrom(file io.Reader) (n int64, err error)

func (*Response) Valid

func (r *Response) Valid() bool

func (*Response) WriteTo

func (r *Response) WriteTo(w io.Writer) (n int64, err error)

Directories

Path Synopsis
cmd
serve command

Jump to

Keyboard shortcuts

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