mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-29 12:30:11 +00:00
add optional tls/http2 support
Allows for http2 server push, see the advanced section.
This commit is contained in:
parent
781047058f
commit
75796a3981
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,3 +9,6 @@ docs/*
|
|||||||
lang/langtostruct.py
|
lang/langtostruct.py
|
||||||
config-payload.json
|
config-payload.json
|
||||||
!docs/go.mod
|
!docs/go.mod
|
||||||
|
server.key
|
||||||
|
server.pem
|
||||||
|
server.crt
|
||||||
|
@ -219,6 +219,50 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"advanced": {
|
||||||
|
"order": [],
|
||||||
|
"meta": {
|
||||||
|
"name": "Advanced",
|
||||||
|
"description": "Advanced settings."
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"tls": {
|
||||||
|
"name": "TLS/HTTP2",
|
||||||
|
"required": false,
|
||||||
|
"requires_restart": true,
|
||||||
|
"type": "bool",
|
||||||
|
"value": false,
|
||||||
|
"description": "Enable TLS, and by extension HTTP2. This enables server push, where required files are pushed to the web browser before they request them, allowing quicker page loads."
|
||||||
|
},
|
||||||
|
"tls_port": {
|
||||||
|
"name": "TLS Port",
|
||||||
|
"depends_true": "tls",
|
||||||
|
"required": false,
|
||||||
|
"requires_restart": true,
|
||||||
|
"type": "number",
|
||||||
|
"value": 8057,
|
||||||
|
"description": "Port to run TLS server on"
|
||||||
|
},
|
||||||
|
"tls_cert": {
|
||||||
|
"name": "Path to TLS Certificate",
|
||||||
|
"depends_true": "tls",
|
||||||
|
"required": false,
|
||||||
|
"requires_restart": true,
|
||||||
|
"type": "text",
|
||||||
|
"value": "",
|
||||||
|
"description": "Path to .crt file. See jfa-go wiki for more info."
|
||||||
|
},
|
||||||
|
"tls_key": {
|
||||||
|
"name": "Path to TLS Key file",
|
||||||
|
"depends_true": "tls",
|
||||||
|
"required": false,
|
||||||
|
"requires_restart": true,
|
||||||
|
"type": "text",
|
||||||
|
"value": "",
|
||||||
|
"description": "Path to .key file. See jfa-go wiki for more info."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"password_validation": {
|
"password_validation": {
|
||||||
"order": [],
|
"order": [],
|
||||||
"meta": {
|
"meta": {
|
||||||
|
20
main.go
20
main.go
@ -331,7 +331,12 @@ func start(asDaemon, firstCall bool) {
|
|||||||
|
|
||||||
if !firstRun {
|
if !firstRun {
|
||||||
app.host = app.config.Section("ui").Key("host").String()
|
app.host = app.config.Section("ui").Key("host").String()
|
||||||
app.port = app.config.Section("ui").Key("port").MustInt(8056)
|
if app.config.Section("advanced").Key("tls").MustBool(false) {
|
||||||
|
app.info.Println("Using TLS/HTTP2")
|
||||||
|
app.port = app.config.Section("advanced").Key("tls_port").MustInt(8057)
|
||||||
|
} else {
|
||||||
|
app.port = app.config.Section("ui").Key("port").MustInt(8056)
|
||||||
|
}
|
||||||
|
|
||||||
if *HOST != app.host && *HOST != "" {
|
if *HOST != app.host && *HOST != "" {
|
||||||
app.host = *HOST
|
app.host = *HOST
|
||||||
@ -350,7 +355,6 @@ func start(asDaemon, firstCall bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
address = fmt.Sprintf("%s:%d", app.host, app.port)
|
address = fmt.Sprintf("%s:%d", app.host, app.port)
|
||||||
|
|
||||||
app.debug.Printf("Loaded config file \"%s\"", app.configPath)
|
app.debug.Printf("Loaded config file \"%s\"", app.configPath)
|
||||||
@ -625,8 +629,16 @@ func start(asDaemon, firstCall bool) {
|
|||||||
Handler: router,
|
Handler: router,
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
if err := SRV.ListenAndServe(); err != nil {
|
if app.config.Section("advanced").Key("tls").MustBool(false) {
|
||||||
app.err.Printf("Failure serving: %s", err)
|
cert := app.config.Section("advanced").Key("tls_cert").MustString("")
|
||||||
|
key := app.config.Section("advanced").Key("tls_key").MustString("")
|
||||||
|
if err := SRV.ListenAndServeTLS(cert, key); err != nil {
|
||||||
|
app.err.Printf("Failure serving: %s", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := SRV.ListenAndServe(); err != nil {
|
||||||
|
app.err.Printf("Failure serving: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
app.quit = make(chan os.Signal)
|
app.quit = make(chan os.Signal)
|
||||||
|
Loading…
Reference in New Issue
Block a user