feat: add tls port for RESTful api and external controller

This commit is contained in:
Skyxim
2022-12-03 12:25:10 +08:00
parent cf5709aab1
commit 2fe271f19f
3 changed files with 53 additions and 5 deletions

View File

@ -1,6 +1,8 @@
package hub
import (
"errors"
"github.com/Dreamacro/clash/config"
"github.com/Dreamacro/clash/hub/executor"
"github.com/Dreamacro/clash/hub/route"
@ -42,7 +44,12 @@ func Parse(options ...Option) error {
}
if cfg.General.ExternalController != "" {
go route.Start(cfg.General.ExternalController, cfg.General.Secret)
if cfg.General.TLSPort != 0 && (len(cfg.General.PrivateKey) == 0 || len(cfg.General.Cert) == 0) {
return errors.New("Must be provided certificates and keys, for tls controller")
}
go route.Start(cfg.General.ExternalController, cfg.General.Secret, cfg.General.TLSPort,
cfg.General.Cert, cfg.General.PrivateKey)
}
executor.ApplyConfig(cfg, true)