client

package
v0.0.0-...-4718e07 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedObject = errors.New("unexpected object")

ErrUnexpectedObject represents an unexpected object type received

Functions

This section is empty.

Types

type Client

type Client struct {
	TrustAnchor TrustAnchors

	ObjectDir ObjectDirectory
	// contains filtered or unexported fields
}

Client is an object that will hold the required state to communicate with the registrar server

func (*Client) EndEPPRun

func (a *Client) EndEPPRun(id int64) (errs []error)

EndEPPRun is used to end an epp run. If the process of ending the run fails an error will be returned.

func (*Client) Get

func (a *Client) Get(path string) (data []byte, err error)

Get will send a request to the server using the current client and return a respose and error, similar to the response from http.Client.Get

func (*Client) GetAPIUser

func (a *Client) GetAPIUser(id int64) (outobj *lib.APIUserExportFull, errs []error)

GetAPIUser will try and retrieve a domain object from the server

func (*Client) GetAPIUserAt

func (a *Client) GetAPIUserAt(id int64, ts int64) (outobj *lib.APIUserExportFull, errs []error)

GetAPIUserAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetAPIUserRevision

func (a *Client) GetAPIUserRevision(id int64) (outobj *lib.APIUserRevisionExport, errs []error)

GetAPIUserRevision will try and retrieve a domain object from the server

func (*Client) GetAPIUserRevisionAt

func (a *Client) GetAPIUserRevisionAt(id int64, ts int64) (outobj *lib.APIUserRevisionExport, errs []error)

GetAPIUserRevisionAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetAll

func (a *Client) GetAll(objectType string) (ids []int64, hints map[int64]lib.APIRevisionHint, errs []error)

GetAll will try to retrieve a list of all IDs for objects that are in an active state or require work to be done

func (*Client) GetApproval

func (a *Client) GetApproval(approvalID int64, approverID int64, action string) (approvalObject []byte, errs []error)

GetApproval will try to retrieve an approval from the registrar server given the approval ID and the desired approver id

func (*Client) GetApprovalObject

func (a *Client) GetApprovalObject(id int64) (outobj *lib.ApprovalExport, errs []error)

GetApprovalObject will try and retrieve a domain object from the server

func (*Client) GetApprovalObjectAt

func (a *Client) GetApprovalObjectAt(id int64, ts int64) (outobj *lib.ApprovalExport, errs []error)

GetApprovalObjectAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetApprover

func (a *Client) GetApprover(id int64) (outobj *lib.ApproverExportFull, errs []error)

GetApprover will try and retrieve a domain object from the server

func (*Client) GetApproverAt

func (a *Client) GetApproverAt(id int64, ts int64) (outobj *lib.ApproverExportFull, errs []error)

GetApproverAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetApproverRevision

func (a *Client) GetApproverRevision(id int64) (outobj *lib.ApproverRevisionExport, errs []error)

GetApproverRevision will try and retrieve a domain object from the server

func (*Client) GetApproverRevisionAt

func (a *Client) GetApproverRevisionAt(id int64, ts int64) (outobj *lib.ApproverRevisionExport, errs []error)

GetApproverRevisionAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetApproverSet

func (a *Client) GetApproverSet(id int64) (outobj *lib.ApproverSetExportFull, errs []error)

GetApproverSet will try and retrieve a domain object from the server

func (*Client) GetApproverSetAt

func (a *Client) GetApproverSetAt(id int64, ts int64) (outobj *lib.ApproverSetExportFull, errs []error)

GetApproverSetAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetApproverSetRevision

func (a *Client) GetApproverSetRevision(id int64) (outobj *lib.ApproverSetRevisionExport, errs []error)

GetApproverSetRevision will try and retrieve a domain object from the server

func (*Client) GetApproverSetRevisionAt

func (a *Client) GetApproverSetRevisionAt(id int64, ts int64) (outobj *lib.ApproverSetRevisionExport, errs []error)

GetApproverSetRevisionAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetChangeRequest

func (a *Client) GetChangeRequest(id int64) (outobj *lib.ChangeRequestExport, errs []error)

GetChangeRequest will try and retrieve a change request object from the server

func (*Client) GetChangeRequestAt

func (a *Client) GetChangeRequestAt(id int64, ts int64) (outobj *lib.ChangeRequestExport, errs []error)

GetChangeRequestAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetContact

func (a *Client) GetContact(id int64) (outobj *lib.ContactExport, errs []error)

GetContact will try and retrieve a domain object from the server

func (*Client) GetContactAt

func (a *Client) GetContactAt(id int64, ts int64) (outobj *lib.ContactExport, errs []error)

GetContactAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetContactRevision

func (a *Client) GetContactRevision(id int64) (outobj *lib.ContactRevisionExport, errs []error)

GetContactRevision will try and retrieve a domain object from the server

func (*Client) GetContactRevisionAt

func (a *Client) GetContactRevisionAt(id int64, ts int64) (outobj *lib.ContactRevisionExport, errs []error)

GetContactRevisionAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetContactsWork

func (a *Client) GetContactsWork() (ids []int64, hints map[int64]lib.APIRevisionHint, errs []error)

GetContactsWork will try to retrieve a list of contacts IDs that have work to be done

func (*Client) GetDomain

func (a *Client) GetDomain(id int64) (outobj *lib.DomainExport, errs []error)

GetDomain will try and retrieve a domain object from the server

func (*Client) GetDomainAt

func (a *Client) GetDomainAt(id int64, ts int64) (outobj *lib.DomainExport, errs []error)

GetDomainAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetDomainIDFromName

func (a *Client) GetDomainIDFromName(domainName string) (id int64, errs []error)

GetDomainIDFromName will attempt to find the domain ID from the domain name provided. If a domain object is found, its id will be returned, otherwise an error will be returned

func (*Client) GetDomainRevision

func (a *Client) GetDomainRevision(id int64) (outobj *lib.DomainRevisionExport, errs []error)

GetDomainRevision will try and retrieve a domain object from the server

func (*Client) GetDomainRevisionAt

func (a *Client) GetDomainRevisionAt(id int64, ts int64) (outobj *lib.DomainRevisionExport, errs []error)

GetDomainRevisionAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetDomainsWork

func (a *Client) GetDomainsWork() (ids []int64, hints map[int64]lib.APIRevisionHint, errs []error)

GetDomainsWork will try to retrieve a list of domains IDs that have work to be done

func (*Client) GetEncryptedPassphrase

func (a *Client) GetEncryptedPassphrase(username string) (encryptedPassphrase string, errs []error)

GetEncryptedPassphrase will attempt to get the encrypted passphrase from the server based on the username provided. If errors occur when trying to locate the passphrase, they will be returned.

func (*Client) GetHost

func (a *Client) GetHost(id int64) (outobj *lib.HostExport, errs []error)

GetHost will try and retrieve a domain object from the server

func (*Client) GetHostAt

func (a *Client) GetHostAt(id int64, ts int64) (outobj *lib.HostExport, errs []error)

GetHostAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetHostIPAllowList

func (a *Client) GetHostIPAllowList() (ips []string, errs []error)

GetHostIPAllowList will retrieve the list of Host IPs that are allowlisted as they are trusted nameservers

func (*Client) GetHostRevision

func (a *Client) GetHostRevision(id int64) (outobj *lib.HostRevisionExport, errs []error)

GetHostRevision will try and retrieve a domain object from the server

func (*Client) GetHostRevisionAt

func (a *Client) GetHostRevisionAt(id int64, ts int64) (outobj *lib.HostRevisionExport, errs []error)

GetHostRevisionAt will try and retrieve a domain object from the server at the given timestamp

func (*Client) GetHostsWork

func (a *Client) GetHostsWork() (ids []int64, hints map[int64]lib.APIRevisionHint, errs []error)

GetHostsWork will try to retrieve a list of host IDs that have work to be done

func (*Client) GetIDList

func (a *Client) GetIDList(url string) (ids []int64, hints map[int64]lib.APIRevisionHint, errs []error)

GetIDList will try to retrieve a list of IDs for the provided object type using the url provided

func (*Client) GetObject

func (a *Client) GetObject(objectType string, id int64, lastUpdate *time.Time) (outObj lib.RegistrarObjectExport, errs []error)

GetObject will try to retrieve an object from the server

func (*Client) GetObjectAt

func (a *Client) GetObjectAt(objectType string, id int64, ts int64) (outObj lib.RegistrarObjectExport, errs []error)

GetObjectAt will try to retrieve an object from the server at a given unix timestamp

func (*Client) GetProtectedDomainList

func (a *Client) GetProtectedDomainList() (domains []string, errs []error)

GetProtectedDomainList will retrieve the list of Protected domains that are stored in the registrar system. If an error is encountered, it will be returned

func (*Client) GetSig

func (a *Client) GetSig(approvalID int64) (sigBytes []byte, errs []error)

GetSig will try and retireve the signature associated with an approval given an approval ID. If the approval is not signed or another error occurs an error will be retured.

func (*Client) GetToken

func (a *Client) GetToken() (token string, errs []error)

GetToken will retrieve a CSRF token from the server for the user that is currently logged in

func (*Client) GetVerifiedApprover

func (a *Client) GetVerifiedApprover(approverID int64, timestamp int64) (verified bool, errs []error, obj *lib.ApproverExportFull)

GetVerifiedApprover will attempt to download and verify an approver with the given ID at the given time. A bool of if the Approver was verified or not, a list of errors and the resulting ApproverExportFull object will be returned. An empty object is returned if the object did not verify.

func (*Client) GetVerifiedApproverSet

func (a *Client) GetVerifiedApproverSet(approverSetID int64, timestamp int64) (verified bool, errs []error, obj *lib.ApproverSetExportFull)

GetVerifiedApproverSet will attempt to download and verify an approver set with the given ID at the given time. A bool of if the Approver Set was verified or not, a list of errors and the resulting ApproverSetExportFull object will be returned. An empty object is returned if the object did not verify

func (*Client) GetVerifiedContact

func (a *Client) GetVerifiedContact(contactID int64, timestamp int64) (verified bool, errs []error, obj *lib.ContactExport)

GetVerifiedContact will attempt to download and verify a Contact with the given ID at the given time. A bool of if the Contact was verified or not, a list of errors and the resulting ContactExport object will be returned. An empty object is returned if the object did not verify.

func (*Client) GetVerifiedDomain

func (a *Client) GetVerifiedDomain(domainID int64, timestamp int64) (verified bool, errs []error, obj *lib.DomainExport)

GetVerifiedDomain will attempt to download and verify a Domain with the given ID at the given time. A bool of if the Domain was verified or not, a list of errors and the resulting DomainExport object will be returned. An empty object is returned if the object did not verify.

func (*Client) GetVerifiedHost

func (a *Client) GetVerifiedHost(hostID int64, timestamp int64) (verified bool, errs []error, obj *lib.HostExport)

GetVerifiedHost will attempt to download and verify a Host with the given ID at the given time. A bool of if the Host was verified or not, a list of errors and the resulting HostExport object will be returned. An empty object is returned if the object did not verify.

func (*Client) GetWHOIS

func (a *Client) GetWHOIS(defaultContactID int64) (objects.WHOIS, []error)

GetWHOIS creates an objects.WHOIS object that can be serialized and installed on a WHOIS server

func (*Client) GetWork

func (a *Client) GetWork(objectType string) (ids []int64, hints map[int64]lib.APIRevisionHint, errs []error)

GetWork will try to retrieve a list of IDs for the provided object type that require work to be done

func (*Client) Post

func (a *Client) Post(path string, bodyType string, body io.Reader) (*http.Response, error)

Post will send a request to the server using the current client and return a respose and error, similar to the response from http.Client.Post

func (*Client) Prepare

func (a *Client) Prepare(base string, log *logging.Logger, dcc DiskCacheConfig)

Prepare will take the required information for the client and prepare it to send queries to the server

func (*Client) PrepareObjectDirectory

func (a *Client) PrepareObjectDirectory() (errs []error)

PrepareObjectDirectory will attempt to prepare the object directory for use. If any errors are encountered, they will be returned

func (*Client) PrepareSSL

func (a *Client) PrepareSSL(base, certFile, keyFile, caFile string, keychainConf keychain.Conf, log *logging.Logger, dcc DiskCacheConfig)

PrepareSSL will take the required infomration for the client and prepare it to send queries to the server using TLS

func (*Client) PushContactRegistryID

func (a *Client) PushContactRegistryID(objectID int64, token string, registryID string) (errs []error)

PushContactRegistryID will try to push the RegistryID selected for the contact to the server.

func (*Client) PushEPPActionLog

func (a *Client) PushEPPActionLog(action lib.EPPAction) (errs []error)

PushEPPActionLog will attempt to push an epp action to the server and if it fails, the errors will be returned

func (*Client) PushHostIPAllowList

func (a *Client) PushHostIPAllowList(ips []string, token string) (errs []error)

PushHostIPAllowList will attempt to uplaod the IP allow list provided to the registrar server. If an error occurs, it will be returned

func (*Client) PushInfoEPP

func (a *Client) PushInfoEPP(objectType string, objectID int64, info *epp.Response) (errs []error)

PushInfoEPP will try to push the EPP Info response associated with a registry object

func (*Client) PushProtectedDomainList

func (a *Client) PushProtectedDomainList(domains []string, token string) (errs []error)

PushProtectedDomainList will attempt to uplaod the protected domain list provided to the registrar server. If an error occurs, it will be returned

func (*Client) PushSig

func (a *Client) PushSig(approvalID int64, sigData []byte, token string) (errs []error)

PushSig will try to push a signature associated with an approval to the server.

func (*Client) RequestNewEPPRunID

func (a *Client) RequestNewEPPRunID() (id int64, errs []error)

RequestNewEPPRunID will request a new EPP Run ID from he registrar server and return it. If an error occurs getting a new ID, it will be returned

func (*Client) SetEncryptedPassphrase

func (a *Client) SetEncryptedPassphrase(username string, encryptedPassphrase string) (errs []error)

SetEncryptedPassphrase will attempt to se the encrypted passphrase for the username provided. If the process results in errors, they will be returned

func (*Client) SetLogger

func (a *Client) SetLogger(logger *logging.Logger)

SetLogger is used to set or reset the logger that the Client object will call

func (*Client) SpoofCertificateForTesting

func (a *Client) SpoofCertificateForTesting(cert string, headername string)

SpoofCertificateForTesting is used to spoof a client certificate that is used to authenticatea client to the testing server

func (*Client) UnsetEPPCheck

func (a *Client) UnsetEPPCheck(objectType string, objectID int64) (errs []error)

UnsetEPPCheck will try to unset the check_required field for the registry object

func (*Client) VerifyApproverSet

func (a *Client) VerifyApproverSet(as *lib.ApproverSetExportFull) (verified bool, obj lib.ApproverSetRevisionExport, errs []error)

VerifyApproverSet will attempt to verify that the approver set provided has been signed by one of the trust anchors or has a chain of signatures and revisions back to a trust anchor. A bool indicating if the object was verified, a list of errors and a ApproverSetRevisionExport object are returned. If the Approver set was not verified an empty object is returned. If only some of the approvers of the current approver set were verified then only the verifable approvers are returned. If no valid approvers were found verified will be set to false, an error will be added and the object will be just the Approver set.

func (*Client) VerifyChangeRequest

func (a *Client) VerifyChangeRequest(id int64, revision lib.RegistrarObjectExport) (verified bool, errs []error, signedData []byte)

VerifyChangeRequest will attempt to verify that the change request was signed by one of the trust anchors an approver that has a chain of approvals leading back to a trust anchor. A bool indicating if the verification succeeded, a list of errors and the signed data are returned. If the object was not signed no data is returned.

type DiskCache

type DiskCache struct {
	Enabled  bool
	BasePath string
	UseHints bool
	// contains filtered or unexported fields
}

DiskCache is used to handle the storage and reterival of objects stored on the local disk

func NewDiskCache

func NewDiskCache(dcc DiskCacheConfig, log *logging.Logger) (DiskCache, error)

NewDiskCache will generate an initialize a disk cache using the DiskCacheConfig passed

func (*DiskCache) GetObject

func (d *DiskCache) GetObject(objType string, id int64, lastUpdate *time.Time) (outObj lib.RegistrarObjectExport, errs []error)

GetObject will attempt to reterive the object of the type passed with the id pass from disk otherwise an error will be returned

func (*DiskCache) GetObjectAt

func (d *DiskCache) GetObjectAt(objectType string, id int64, timestamp int64, od ObjectDirectory) (outObj lib.RegistrarObjectExport, errs []error)

GetObjectAt will attempt to retrieve the object type with the id passed at the timestamp given. If no object is caches for that timestamp, an error is returned

func (*DiskCache) SaveObject

func (d *DiskCache) SaveObject(resp lib.APIResponse) error

SaveObject will take the given object and save it to disk in the cache

func (*DiskCache) SaveObjectAt

func (d *DiskCache) SaveObjectAt(resp lib.APIResponse, id int64, timestamp int64) error

SaveObjectAt will save the given object to disk for the given ID and add the timestamp to the date rage for the object revision table

func (*DiskCache) UpdateRevisionList

func (d *DiskCache) UpdateRevisionList(objectType string, objectID int64, revisionID int64, ts int64) error

UpdateRevisionList will attempt to read in a object from cache and add a revision at a timestamp to the object infomration and then write the object back to disk

type DiskCacheConfig

type DiskCacheConfig struct {
	CacheDirectory string
	Enabled        bool
	UseHints       bool
}

DiskCacheConfig is used to include in configruations files to handle the initialization of Disk Caches

type ObjectCache

type ObjectCache struct {
	Response lib.APIResponse
}

ObjectCache is used to serialize and object into the disk cache

type ObjectDirectory

type ObjectDirectory struct {
	DomainIDs   []int64
	DomainHints map[int64]lib.APIRevisionHint

	HostIDs   []int64
	HostHints map[int64]lib.APIRevisionHint

	ContactIDs   []int64
	ContactHints map[int64]lib.APIRevisionHint
}

ObjectDirectory handles a list of IDs and revision hints for the client to allow quick lookups in the disk cache if used

func NewObjectDirectory

func NewObjectDirectory() ObjectDirectory

NewObjectDirectory will initialize a new object directory object and return it

func (*ObjectDirectory) LoadObjectDirectory

func (od *ObjectDirectory) LoadObjectDirectory(cli *Client) (errs []error)

LoadObjectDirectory will attempt to load the list of active objects and the current hints for all objects. If any errors are returned when trying to load the objects, the errors will be returned

type ObjectInfo

type ObjectInfo struct {
	ObjectID  int64
	Revisions []RevisionValidity
}

ObjectInfo is used to store multiple revision validity windows for objects of the same ID. Object info is what will be serialized to disk

type RevisionValidity

type RevisionValidity struct {
	RevisionID int64
	MinTime    int64
	MaxTime    int64
}

RevisionValidity is used to store information about which revisions were active for given times

type TrustAnchors

type TrustAnchors struct {
	Keys []*openpgp.Entity
}

TrustAnchors are used to pin GPG keys that are trusted, often the set of trust anchors will be the bootstrap key or possibly the members of the default (first) approver set. Trust anchors can be added to reduce the amount of work required to verify a change set. At least one trust anchor will be required for verification to work correctly.

func (*TrustAnchors) AddKey

func (t *TrustAnchors) AddKey(key string) error

AddKey is used to add a new key to a trust anchor set

func (TrustAnchors) DecryptionKeys

func (t TrustAnchors) DecryptionKeys() (keys []openpgp.Key)

DecryptionKeys returns all private keys that are valid for decryption. No private keys are stored by the system so it is always a noop. This method is part of the interface for []openpgp.Entities

func (TrustAnchors) IsSignedBy

func (t TrustAnchors) IsSignedBy(sig []byte) (valid bool, signedBody []byte)

IsSignedBy will return true if the object is signed by one of the members of the TrustAnchors list

func (TrustAnchors) KeysById

func (t TrustAnchors) KeysById(id uint64) (keys []openpgp.Key)

KeysById returns the set of keys that have the given key id. This method is part of the interface for []openpgp.Entities

func (TrustAnchors) KeysByIdUsage

func (t TrustAnchors) KeysByIdUsage(id uint64, requiredUsage byte) (keys []openpgp.Key)

KeysByIdUsage returns the set of keys with the given id that also meet the key usage given by requiredUsage. The requiredUsage is expressed as the bitwise-OR of packet.KeyFlag* values. This method is part of the interface for []openpgp.Entities

Jump to

Keyboard shortcuts

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