🎨 桌面端内核进程使用随机端口 https://github.com/siyuan-note/siyuan/issues/4952

This commit is contained in:
Liang Ding 2022-10-25 10:21:14 +08:00
parent a20a19182b
commit bb90e72eee
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
10 changed files with 50 additions and 0 deletions

View file

@ -39,6 +39,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/system/getEmojiConf", model.CheckAuth, getEmojiConf)
ginServer.Handle("POST", "/api/system/setAccessAuthCode", model.CheckAuth, setAccessAuthCode)
ginServer.Handle("POST", "/api/system/setNetworkServe", model.CheckAuth, setNetworkServe)
ginServer.Handle("POST", "/api/system/setFixedPort", model.CheckAuth, setFixedPort)
ginServer.Handle("POST", "/api/system/setUploadErrLog", model.CheckAuth, setUploadErrLog)
ginServer.Handle("POST", "/api/system/setDownloadInstallPkg", model.CheckAuth, setDownloadInstallPkg)
ginServer.Handle("POST", "/api/system/setNetworkProxy", model.CheckAuth, setNetworkProxy)

View file

@ -285,6 +285,23 @@ func setNetworkServe(c *gin.Context) {
time.Sleep(time.Second * 3)
}
func setFixedPort(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
fixedPort := arg["fixedPort"].(bool)
model.Conf.FixedPort = fixedPort
model.Conf.Save()
util.PushMsg(model.Conf.Language(42), 1000*15)
time.Sleep(time.Second * 3)
}
func setUploadErrLog(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

View file

@ -60,6 +60,7 @@ type AppConf struct {
User *conf.User `json:"-"` // 社区用户内存结构,不持久化
Account *conf.Account `json:"account"` // 帐号配置
ReadOnly bool `json:"readonly"` // 是否是以只读模式运行
FixedPort bool `json:"fixedPort"` // 是否使用固定端口 6806
LocalIPs []string `json:"localIPs"` // 本地 IP 列表
AccessAuthCode string `json:"accessAuthCode"` // 访问授权码
System *conf.System `json:"system"` // 系统配置
@ -271,6 +272,10 @@ func InitConf() {
Conf.AccessAuthCode = util.AccessAuthCode
}
if util.ContainerStd != util.Container {
Conf.FixedPort = true
}
Conf.LocalIPs = util.GetLocalIPs()
Conf.Save()