Skip to content

Commit

Permalink
Add TLS support
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamCurtisVT committed Oct 6, 2023
1 parent cffd002 commit 3aee543
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/podsync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ func main() {

group.Go(func() error {
log.Infof("running listener at %s", srv.Addr)
return srv.ListenAndServe()
if cfg.Server.TLS {
return srv.ListenAndServeTLS(cfg.Server.CertificatePath, cfg.Server.KeyFilePath)
} else {
return srv.ListenAndServe()
}
})

group.Go(func() error {
Expand Down
4 changes: 4 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ hostname = "https://my.test.host:4443"
bind_address = "172.20.10.2"
# Specify path for reverse proxy and only [A-Za-z0-9]
path = "test"
# Optional. If you want to use TLS you must set the TLS flag and path to the certificate file and private key file.
tls = true
certificate_path = "/var/www/cert.pem"
key_file_path = "/var/www/priv.pem"

# Configure where to store the episode data
[storage]
Expand Down
6 changes: 6 additions & 0 deletions services/web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ type Config struct {
// "*": bind all IP addresses which is default option
// localhost or 127.0.0.1 bind a single IPv4 address
BindAddress string `toml:"bind_address"`
// Flag indicating if the server will use TLS
TLS bool `toml:"tls"`
// Path to a certificate file for TLS connections
CertificatePath string `toml:"certificate_path"`
// Path to a private key file for TLS connections
KeyFilePath string `toml:"key_file_path"`
// Specify path for reverse proxy and only [A-Za-z0-9]
Path string `toml:"path"`
// DataDir is a path to a directory to keep XML feeds and downloaded episodes,
Expand Down

0 comments on commit 3aee543

Please sign in to comment.