add tls option
This commit is contained in:
parent
3533ea4dfe
commit
71ce3bb90d
|
@ -5,6 +5,12 @@ import (
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type TlsConfig struct {
|
||||||
|
Enable bool `yaml:"enable"`
|
||||||
|
CertFile string `yaml:"certificate"`
|
||||||
|
CertKeyFile string `yaml:"certificate_key"`
|
||||||
|
}
|
||||||
|
|
||||||
type ServerAuthConfig struct {
|
type ServerAuthConfig struct {
|
||||||
Username string `yaml:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password"`
|
||||||
|
@ -13,6 +19,7 @@ type ServerAuthConfig struct {
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
Listen string `yaml:"listen"`
|
Listen string `yaml:"listen"`
|
||||||
Auth ServerAuthConfig `yaml:"auth"`
|
Auth ServerAuthConfig `yaml:"auth"`
|
||||||
|
Tls TlsConfig `yaml:tls`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RemoteItemConfigItem struct {
|
type RemoteItemConfigItem struct {
|
||||||
|
|
|
@ -3,6 +3,10 @@ server:
|
||||||
username: admin
|
username: admin
|
||||||
password: admin
|
password: admin
|
||||||
listen: 0.0.0.0:4000
|
listen: 0.0.0.0:4000
|
||||||
|
tls:
|
||||||
|
enable: false
|
||||||
|
certificate: /path/to/server.crt
|
||||||
|
certificate_key: /path/to/server.key
|
||||||
|
|
||||||
remote:
|
remote:
|
||||||
- label: Keyboard
|
- label: Keyboard
|
||||||
|
|
8
main.go
8
main.go
|
@ -62,5 +62,13 @@ func main() {
|
||||||
e.GET("/", homeController)
|
e.GET("/", homeController)
|
||||||
e.GET("/ws", wsController)
|
e.GET("/ws", wsController)
|
||||||
|
|
||||||
|
if config.Server.Tls.Enable == false {
|
||||||
e.Logger.Fatal(e.Start(config.Server.Listen))
|
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 isScreenshotWaiting = false;
|
||||||
|
|
||||||
var createWebSocketConnection = function() {
|
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) {
|
ws.onopen = function(event) {
|
||||||
$('#disconneced').fadeOut();
|
$('#disconneced').fadeOut();
|
||||||
|
|
Loading…
Reference in a new issue