diff --git a/cmd/rdpgw/config/configuration.go b/cmd/rdpgw/config/configuration.go index 2e5026bf7d65d37caae8a2cd108e7786633dc333..dad3a438d0ee98c368647729e34e791c0d53edca 100644 --- a/cmd/rdpgw/config/configuration.go +++ b/cmd/rdpgw/config/configuration.go @@ -45,6 +45,7 @@ type ServerConfig struct { SessionKey string `koanf:"sessionkey"` SessionEncryptionKey string `koanf:"sessionencryptionkey"` SessionStore string `koanf:"sessionstore"` + MaxSessionLength int `koanf:"maxsessionlength"` SendBuf int `koanf:"sendbuf"` ReceiveBuf int `koanf:"receivebuf"` Tls string `koanf:"tls"` diff --git a/cmd/rdpgw/main.go b/cmd/rdpgw/main.go index 42b0e5f6146f31e59cf312f0382200c393333ec3..66e8c6edcd4410c7a234614d3eefb8ba6d931649 100644 --- a/cmd/rdpgw/main.go +++ b/cmd/rdpgw/main.go @@ -94,7 +94,11 @@ func main() { security.Hosts = conf.Server.Hosts // init session store - web.InitStore([]byte(conf.Server.SessionKey), []byte(conf.Server.SessionEncryptionKey), conf.Server.SessionStore) + web.InitStore([]byte(conf.Server.SessionKey), + []byte(conf.Server.SessionEncryptionKey), + conf.Server.SessionStore, + conf.Server.MaxSessionLength, + ) // configure web backend w := &web.Config{ diff --git a/cmd/rdpgw/web/session.go b/cmd/rdpgw/web/session.go index be79db76e2099c4146647605de0289f1742e42f4..9114ed825c52f5c359ada97fcc7775d9c3b57939 100644 --- a/cmd/rdpgw/web/session.go +++ b/cmd/rdpgw/web/session.go @@ -17,7 +17,7 @@ const ( var sessionStore sessions.Store -func InitStore(sessionKey []byte, encryptionKey []byte, storeType string) { +func InitStore(sessionKey []byte, encryptionKey []byte, storeType string, maxLength int) { if len(sessionKey) < 32 { log.Fatal("Session key too small") } @@ -30,8 +30,11 @@ func InitStore(sessionKey []byte, encryptionKey []byte, storeType string) { fs := sessions.NewFilesystemStore(os.TempDir(), sessionKey, encryptionKey) // set max length - log.Printf("Setting maximum session storage to %d bytes", maxSessionLength) - fs.MaxLength(maxSessionLength) + if maxLength == 0 { + maxLength = maxSessionLength + } + log.Printf("Setting maximum session storage to %d bytes", maxLength) + fs.MaxLength(maxLength) sessionStore = fs } else {