🎨 Fix network serving TLS on mobile devices (#17119)

* Until now, the TLS would only work via the fixed port proxy, which
   isn't used on mobile devices.
 * Move the logic for the multiplexer out of the fixed port logic
 * Use the newly moved multiplexer logic for the regular server as well,
   whenever the fixed port and the server port match.
This commit is contained in:
Davide Garberi 2026-03-02 09:43:27 +01:00 committed by GitHub
parent 7912100136
commit 0cc061dec8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 71 additions and 32 deletions

View file

@ -47,6 +47,7 @@ import (
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/server/proxy"
"github.com/siyuan-note/siyuan/kernel/util"
"github.com/soheilhy/cmux"
"golang.org/x/net/webdav"
)
@ -244,6 +245,20 @@ func Serve(fastMode bool, cookieKey string) {
Handler: ginServer,
}
if useTLS && (util.FixedPort == util.ServerPort || util.IsPortOpen(util.FixedPort)) {
if err = util.ServeMultiplexed(ln, ginServer, certPath, keyPath, util.HttpServer); err != nil {
if errors.Is(err, http.ErrServerClosed) || err == cmux.ErrListenerClosed {
return
}
if !fastMode {
logging.LogErrorf("boot kernel failed: %s", err)
os.Exit(logging.ExitCodeUnavailablePort)
}
}
return
}
if err = util.HttpServer.Serve(ln); err != nil {
if errors.Is(err, http.ErrServerClosed) {
return