hosts

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

README

hosts

import "github.com/imarsman/certcheck/pkg/hosts"

Index

Constants

const (
    timeFormat     = "2006-01-02T15:04:05Z"
    tlsDefaultPort = "443"
)

Variables

Semaphore is for all requests to Process

var (
    sem    = semaphore.NewWeighted(int64(6)) // Set semaphore with capacity
    semCtx = context.Background()            // ctx for semaphore
)

func getDomainAndPort

func getDomainAndPort(input string) (host string, port string, err error)

Extract host and port from incoming host string

type CertData

CertData values for a TLS certificate

type CertData struct {
    ExpiryWarning bool   `json:"expirywarning" yaml:"expirywarning"`
    HostError     bool   `json:"hosterror" yaml:"hosterror"`
    Message       string `json:"message" yaml:"message"`
    Host          string `json:"host" yaml:"host"`
    Issuer        string `json:"issuer" yaml:"issuer"`
    Port          string `json:"port" yaml:"port"`
    TotalDays     int    `json:"totaldays" yaml:"totaldays"`
    DaysToExpiry  int    `json:"daystoexpiry" yaml:"daystoexpiry"`
    WarnAtDays    int    `json:"warnatdays" yaml:"warnatdays"`
    CheckTime     string `json:"checktime" yaml:"checktime"`
    NotBefore     string `json:"notbefore" yaml:"notbefore"`
    NotAfter      string `json:"notafter" yaml:"notafter"`
    FetchTime     string `json:"fetchtime" yaml:"fetchtime"`
}
func getCertData
func getCertData(host, port string, warnAtDays int, timeout int) CertData

Do check of cert from remote host and populate CertData

func newCertData
func newCertData() CertData

Get new CertData instance with default values

func (*CertData) JSON
func (certData *CertData) JSON() (bytes []byte, err error)

JSON get JSON representation of data for a host certificate

func (*CertData) YAML
func (certData *CertData) YAML() (bytes []byte, err error)

YAML get YAML representation of data for a host certificate

type CertDataSet

CertDataSet a set of TLS certificate data for a list of hosts plus summary

type CertDataSet struct {
    Total           int        `json:"total" yaml:"total"`
    HostErrors      int        `json:"hosterrors" yaml:"hosterrors"`
    ExpiredWarnings int        `json:"expirywarnings" yaml:"expirywarnings"`
    CertData        []CertData `json:"certdata" yaml:"certdata"`
}
func NewCertDataSet
func NewCertDataSet() *CertDataSet

NewCertDataSet new cert data set

func (*CertDataSet) JSON
func (certDataSet *CertDataSet) JSON() (bytes []byte, err error)

JSON get JSON representation of data for a set of host certificates

func (*CertDataSet) YAML
func (certDataSet *CertDataSet) YAML() (bytes []byte, err error)

YAML get YAML representation of data for a set of host certificates

func (*CertDataSet) finalize
func (certDataSet *CertDataSet) finalize()

finalize metadata about the cert data set and sort

type HostSet

HostSet hosts to process into cert value set

type HostSet struct {
    Hosts []string
}
func NewHostSet
func NewHostSet() *HostSet

NewHostSet hosts struct containing a list of hosts

func (*HostSet) AddHosts
func (hostSet *HostSet) AddHosts(items ...string)

AddHosts add hosts to HostDataSet

func (*HostSet) Process
func (hostSet *HostSet) Process(warnAtDays, timeout int) *CertDataSet

Process process list of hosts and for each get back cert values

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertData

type CertData struct {
	// ID            int    `json:"-" yaml:"-"`
	Host          string `json:"host" yaml:"host"`
	HostError     bool   `json:"hosterror" yaml:"hosterror"`
	Message       string `json:"message" yaml:"message"`
	ExpiryWarning bool   `json:"expirywarning" yaml:"expirywarning"`
	Issuer        string `json:"issuer" yaml:"issuer"`
	Port          string `json:"port" yaml:"port"`
	TotalDays     int    `json:"totaldays" yaml:"totaldays"`
	DaysToExpiry  int    `json:"daystoexpiry" yaml:"daystoexpiry"`
	WarnAtDays    int    `json:"warnatdays" yaml:"warnatdays"`
	CheckTime     string `json:"checktime" yaml:"checktime"`
	NotBefore     string `json:"notbefore" yaml:"notbefore"`
	NotAfter      string `json:"notafter" yaml:"notafter"`
	FetchTime     string `json:"fetchtime" yaml:"fetchtime"`
}

CertData values for a TLS certificate

func (*CertData) JSON

func (certData *CertData) JSON() (bytes []byte, err error)

JSON get JSON representation of data for a host certificate

func (*CertData) YAML

func (certData *CertData) YAML() (bytes []byte, err error)

YAML get YAML representation of data for a host certificate

type CertDataSet

type CertDataSet struct {
	Total           int        `json:"total" yaml:"total"`
	HostErrors      int        `json:"hosterrors" yaml:"hosterrors"`
	ExpiredWarnings int        `json:"expirywarnings" yaml:"expirywarnings"`
	CertData        []CertData `json:"certdata" yaml:"certdata"`
}

CertDataSet a set of TLS certificate data for a list of hosts plus summary

func NewCertDataSet

func NewCertDataSet() *CertDataSet

NewCertDataSet new cert data set

func (*CertDataSet) JSON

func (certDataSet *CertDataSet) JSON() (bytes []byte, err error)

JSON get JSON representation of data for a set of host certificates

func (*CertDataSet) YAML

func (certDataSet *CertDataSet) YAML() (bytes []byte, err error)

YAML get YAML representation of data for a set of host certificates

type HostSet

type HostSet struct {
	Hosts []string
}

HostSet hosts to process into cert value set

func NewHostSet

func NewHostSet() *HostSet

NewHostSet hosts struct containing a list of hosts

func (*HostSet) Add

func (hostSet *HostSet) Add(items ...string)

Add add hosts to HostDataSet

func (*HostSet) Process

func (hostSet *HostSet) Process(warnAtDays int, timeout time.Duration) *CertDataSet

Process process list of hosts and for each get back cert values

func (*HostSet) ProcessCertFile added in v0.1.1

func (hostSet *HostSet) ProcessCertFile(bytes []byte, warnAtDays int, timeout time.Duration) *CertDataSet

ProcessCertFile process a certificate file

func (*HostSet) ProcessFuture

func (hostSet *HostSet) ProcessFuture(warnAtDays int, timeout time.Duration) *CertDataSet

ProcessFuture process list of hosts and for each get back cert values

Jump to

Keyboard shortcuts

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