add tls option
This commit is contained in:
parent
3533ea4dfe
commit
71ce3bb90d
|
@ -5,6 +5,12 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
type TlsConfig struct {
|
||||
Enable bool `yaml:"enable"`
|
||||
CertFile string `yaml:"certificate"`
|
||||
CertKeyFile string `yaml:"certificate_key"`
|
||||
}
|
||||
|
||||
type ServerAuthConfig struct {
|
||||
Username string `yaml:"username"`
|
||||
Password string `yaml:"password"`
|
||||
|
@ -13,6 +19,7 @@ type ServerAuthConfig struct {
|
|||
type ServerConfig struct {
|
||||
Listen string `yaml:"listen"`
|
||||
Auth ServerAuthConfig `yaml:"auth"`
|
||||
Tls TlsConfig `yaml:tls`
|
||||
}
|
||||
|
||||
type RemoteItemConfigItem struct {
|
||||
|
|
|
@ -3,6 +3,10 @@ server:
|
|||
username: admin
|
||||
password: admin
|
||||
listen: 0.0.0.0:4000
|
||||
tls:
|
||||
enable: false
|
||||
certificate: /path/to/server.crt
|
||||
certificate_key: /path/to/server.key
|
||||
|
||||
remote:
|
||||
- label: Keyboard
|
||||
|
|
10
main.go
10
main.go
|
@ -62,5 +62,13 @@ func main() {
|
|||
e.GET("/", homeController)
|
||||
e.GET("/ws", wsController)
|
||||
|
||||
e.Logger.Fatal(e.Start(config.Server.Listen))
|
||||
if config.Server.Tls.Enable == false {
|
||||
e.Logger.Fatal(e.Start(config.Server.Listen))
|
||||
} else {
|
||||
e.Logger.Fatal(e.StartTLS(
|
||||
config.Server.Listen,
|
||||
config.Server.Tls.CertFile,
|
||||
config.Server.Tls.CertKeyFile,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
18
rice-box.go
18
rice-box.go
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,8 @@ var isLive = false;
|
|||
var isScreenshotWaiting = false;
|
||||
|
||||
var createWebSocketConnection = function() {
|
||||
ws = new WebSocket(`ws://${window.location.hostname}:${window.location.port}/ws`);
|
||||
const protocol = location.protocol === 'https:' ? 'wss' : 'ws'
|
||||
ws = new WebSocket(`${protocol}://${window.location.hostname}:${window.location.port}/ws`);
|
||||
|
||||
ws.onopen = function(event) {
|
||||
$('#disconneced').fadeOut();
|
||||
|
|
Loading…
Reference in a new issue