Updated deps, go.19 migration, nginx template work

This commit is contained in:
Jamie Curnow
2022-11-08 10:03:45 +10:00
parent 8d37f5df8d
commit c00b690ed3
23 changed files with 375 additions and 376 deletions

View File

@ -264,3 +264,38 @@ func (m *Model) Request() error {
logger.Info("Request for certificate for: #%d %v was completed", m.ID, m.Name)
return nil
}
// GetTemplate will convert the Model to a Template
func (m *Model) GetTemplate() Template {
domainNames, _ := m.DomainNames.AsStringArray()
t := Template{
ID: m.ID,
CreatedOn: m.CreatedOn.Time.String(),
ModifiedOn: m.ModifiedOn.Time.String(),
ExpiresOn: m.ExpiresOn.AsString(),
Type: m.Type,
UserID: m.UserID,
CertificateAuthorityID: m.CertificateAuthorityID,
DNSProviderID: m.DNSProviderID,
Name: m.Name,
DomainNames: domainNames,
Status: m.Status,
IsECC: m.IsECC,
// These are helpers for template generation
IsCustom: m.Type == TypeCustom,
IsAcme: m.Type != TypeCustom,
IsProvided: m.ID > 0 && m.Status == StatusProvided,
Folder: m.GetFolder(),
}
return t
}
// GetFolder returns the folder where these certs should exist
func (m *Model) GetFolder() string {
if m.Type == TypeCustom {
return fmt.Sprintf("%s/custom_ssl/npm-%d", config.Configuration.DataFolder, m.ID)
}
return fmt.Sprintf("%s/npm-%d", config.Configuration.Acmesh.CertHome, m.ID)
}

View File

@ -0,0 +1,22 @@
package certificate
// Template is the model given to the template parser, converted from the Model
type Template struct {
ID int
CreatedOn string
ModifiedOn string
ExpiresOn string
Type string
UserID int
CertificateAuthorityID int
DNSProviderID int
Name string
DomainNames []string
Status string
IsECC int
// These are helpers for template generation
IsCustom bool
IsAcme bool // non-custom
IsProvided bool
Folder string
}

View File

@ -139,3 +139,37 @@ func (m *Model) Expand(items []string) error {
return err
}
// GetTemplate will convert the Model to a Template
func (m *Model) GetTemplate() Template {
domainNames, _ := m.DomainNames.AsStringArray()
t := Template{
ID: m.ID,
CreatedOn: m.CreatedOn.Time.String(),
ModifiedOn: m.ModifiedOn.Time.String(),
UserID: m.UserID,
Type: m.Type,
HostTemplateID: m.HostTemplateID,
ListenInterface: m.ListenInterface,
DomainNames: domainNames,
UpstreamID: m.UpstreamID,
CertificateID: m.CertificateID,
AccessListID: m.AccessListID,
SSLForced: m.SSLForced,
CachingEnabled: m.CachingEnabled,
BlockExploits: m.BlockExploits,
AllowWebsocketUpgrade: m.AllowWebsocketUpgrade,
HTTP2Support: m.HTTP2Support,
HSTSEnabled: m.HSTSEnabled,
HSTSSubdomains: m.HSTSSubdomains,
Paths: m.Paths,
UpstreamOptions: m.UpstreamOptions,
AdvancedConfig: m.AdvancedConfig,
Status: m.Status,
ErrorMessage: m.ErrorMessage,
IsDisabled: m.IsDisabled,
}
return t
}

View File

@ -0,0 +1,29 @@
package host
// Template is the model given to the template parser, converted from the Model
type Template struct {
ID int
CreatedOn string
ModifiedOn string
UserID int
Type string
HostTemplateID int
ListenInterface string
DomainNames []string
UpstreamID int
CertificateID int
AccessListID int
SSLForced bool
CachingEnabled bool
BlockExploits bool
AllowWebsocketUpgrade bool
HTTP2Support bool
HSTSEnabled bool
HSTSSubdomains bool
IsDisabled bool
Paths string
UpstreamOptions string
AdvancedConfig string
Status string
ErrorMessage string
}