Skip to content

Commit

Permalink
add tls profile config
Browse files Browse the repository at this point in the history
  • Loading branch information
acoshift committed Jul 20, 2018
1 parent ba62338 commit a8af87e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type App struct {
gracefulShutdown *gracefulShutdown

certFile, keyFile string
tlsProfile string
}

var (
Expand Down Expand Up @@ -110,6 +111,17 @@ func (app *App) configServer() {
app.srv.ConnState = app.ConnState
app.srv.ErrorLog = app.ErrorLog
app.srv.Handler = app

if app.srv.TLSConfig == nil {
switch app.tlsProfile {
case "restricted":
app.srv.TLSConfig = &Restricted
case "modern":
app.srv.TLSConfig = &Modern
case "compatible":
app.srv.TLSConfig = &Compatible
}
}
}

func (app *App) listenAndServe() error {
Expand Down
9 changes: 7 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package hime

import (
"io/ioutil"
"strings"
"time"

yaml "gopkg.in/yaml.v2"
Expand All @@ -22,8 +23,9 @@ type AppConfig struct {
Timeout string `yaml:"timeout" json:"timeout"`
Wait string `yaml:"wait" json:"wait"`
} `yaml:"gracefulShutdown" json:"gracefulShutdown"`
CertFile string `yaml:"certFile" json:"certFile"`
KeyFile string `yaml:"keyFile" json:"keyFile"`
CertFile string `yaml:"certFile" json:"certFile"`
KeyFile string `yaml:"keyFile" json:"keyFile"`
TLSProfile string `yaml:"tlsProfile" json:"tlsProfile"`
} `yaml:"server" json:"server"`
}

Expand Down Expand Up @@ -91,6 +93,9 @@ func (app *App) Config(config AppConfig) *App {
if config.Server.KeyFile != "" {
app.keyFile = config.Server.KeyFile
}
if config.Server.TLSProfile != "" {
app.tlsProfile = strings.ToLower(config.Server.TLSProfile)
}

// load graceful config
if config.Server.GracefulShutdown != nil {
Expand Down

0 comments on commit a8af87e

Please sign in to comment.