Skip to content

Commit bae68f8

Browse files
committed
Merge branch 'dev'
2 parents da833a3 + eb57fb5 commit bae68f8

File tree

8 files changed

+64
-6
lines changed

8 files changed

+64
-6
lines changed

.github_build/Build.alpine.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
OS_NAME=alpine
33
OS_VERSION=3.15
44
GOLANG_IMAGE=golang:1.18.6-alpine3.15
5-
CORE_VERSION=16.10.0
5+
CORE_VERSION=16.10.1

.github_build/Build.ubuntu.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
OS_NAME=ubuntu
33
OS_VERSION=20.04
44
GOLANG_IMAGE=golang:1.18.6-alpine3.15
5-
CORE_VERSION=16.10.0
5+
CORE_VERSION=16.10.1

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Core
22

3+
### Core v16.10.0 > v16.10.1
4+
5+
- Add email address in TLS config for Let's Encrypt
6+
- Fix use of Let's Encrypt production CA
7+
38
### Core v16.9.1 > v16.10.0
49

510
- Add HLS session middleware to diskfs

app/api/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,8 @@ func (a *api) start() error {
655655
}
656656

657657
certmagic.DefaultACME.Agreed = true
658-
certmagic.DefaultACME.Email = ""
659-
certmagic.DefaultACME.CA = certmagic.LetsEncryptStagingCA
658+
certmagic.DefaultACME.Email = cfg.TLS.Email
659+
certmagic.DefaultACME.CA = certmagic.LetsEncryptProductionCA
660660
certmagic.DefaultACME.DisableHTTPChallenge = false
661661
certmagic.DefaultACME.DisableTLSALPNChallenge = true
662662
certmagic.DefaultACME.Logger = nil

app/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (v versionInfo) MinorString() string {
3030
var Version = versionInfo{
3131
Major: 16,
3232
Minor: 10,
33-
Patch: 0,
33+
Patch: 1,
3434
}
3535

3636
// Commit is the git commit the app is build from. It should be filled in during compilation

config/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ func (d *Config) init() {
176176
d.val(newAddressValue(&d.TLS.Address, ":8181"), "tls.address", "CORE_TLS_ADDRESS", nil, "HTTPS listening address", false, false)
177177
d.val(newBoolValue(&d.TLS.Enable, false), "tls.enable", "CORE_TLS_ENABLE", nil, "Enable HTTPS", false, false)
178178
d.val(newBoolValue(&d.TLS.Auto, false), "tls.auto", "CORE_TLS_AUTO", nil, "Enable Let's Encrypt certificate", false, false)
179+
d.val(newEmailValue(&d.TLS.Email, "[email protected]"), "tls.email", "CORE_TLS_EMAIL", nil, "Email for Let's Encrypt registration", false, false)
179180
d.val(newFileValue(&d.TLS.CertFile, ""), "tls.cert_file", "CORE_TLS_CERTFILE", nil, "Path to certificate file in PEM format", false, false)
180181
d.val(newFileValue(&d.TLS.KeyFile, ""), "tls.key_file", "CORE_TLS_KEYFILE", nil, "Path to key file in PEM format", false, false)
181182

@@ -419,6 +420,14 @@ func (d *Config) Validate(resetLogs bool) {
419420
}
420421
}
421422

423+
// If TLS and Let's Encrypt certificate is enabled, we require a non-empty email address
424+
if d.TLS.Enable && d.TLS.Auto {
425+
if len(d.TLS.Email) == 0 {
426+
v := d.findVariable("tls.email")
427+
v.value.Set(v.defVal)
428+
}
429+
}
430+
422431
// If TLS for RTMP is enabled, TLS must be enabled
423432
if d.RTMP.EnableTLS {
424433
if !d.RTMP.Enable {

config/data.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type Data struct {
5454
Address string `json:"address"`
5555
Enable bool `json:"enable"`
5656
Auto bool `json:"auto"`
57+
Email string `json:"email"`
5758
CertFile string `json:"cert_file"`
5859
KeyFile string `json:"key_file"`
5960
} `json:"tls"`
@@ -174,7 +175,6 @@ func NewV3FromV2(d *dataV2) (*Data, error) {
174175
data.DB = d.DB
175176
data.Host = d.Host
176177
data.API = d.API
177-
data.TLS = d.TLS
178178
data.RTMP = d.RTMP
179179
data.SRT = d.SRT
180180
data.FFmpeg = d.FFmpeg
@@ -211,6 +211,13 @@ func NewV3FromV2(d *dataV2) (*Data, error) {
211211
data.Router.Routes = copyStringMap(d.Router.Routes)
212212

213213
// Actual changes
214+
data.TLS.Enable = d.TLS.Enable
215+
data.TLS.Address = d.TLS.Address
216+
data.TLS.Auto = d.TLS.Auto
217+
data.TLS.CertFile = d.TLS.CertFile
218+
data.TLS.KeyFile = d.TLS.KeyFile
219+
data.TLS.Email = "[email protected]"
220+
214221
data.Storage.MimeTypes = d.Storage.MimeTypes
215222

216223
data.Storage.CORS = d.Storage.CORS

config/types.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"net"
8+
"net/mail"
89
"net/url"
910
"os"
1011
"os/exec"
@@ -805,3 +806,39 @@ func (s *absolutePathValue) Validate() error {
805806
func (s *absolutePathValue) IsEmpty() bool {
806807
return len(string(*s)) == 0
807808
}
809+
810+
// email address
811+
812+
type emailValue string
813+
814+
func newEmailValue(p *string, val string) *emailValue {
815+
*p = val
816+
return (*emailValue)(p)
817+
}
818+
819+
func (s *emailValue) Set(val string) error {
820+
addr, err := mail.ParseAddress(val)
821+
if err != nil {
822+
return err
823+
}
824+
825+
*s = emailValue(addr.Address)
826+
return nil
827+
}
828+
829+
func (s *emailValue) String() string {
830+
return string(*s)
831+
}
832+
833+
func (s *emailValue) Validate() error {
834+
if len(s.String()) == 0 {
835+
return nil
836+
}
837+
838+
_, err := mail.ParseAddress(s.String())
839+
return err
840+
}
841+
842+
func (s *emailValue) IsEmpty() bool {
843+
return len(string(*s)) == 0
844+
}

0 commit comments

Comments
 (0)