mirror of
https://github.com/m1k1o/neko.git
synced 2025-04-30 19:06:21 +02:00
disable legacy mode if wanted.
This commit is contained in:
parent
db297d246d
commit
b3b31fba1f
3 changed files with 40 additions and 25 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"m1k1o/neko/internal/api"
|
"m1k1o/neko/internal/api"
|
||||||
"m1k1o/neko/internal/capture"
|
"m1k1o/neko/internal/capture"
|
||||||
|
@ -88,7 +89,7 @@ func (c *serve) Init(cmd *cobra.Command) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// V2 configuration
|
// V2 configuration
|
||||||
|
if viper.GetBool("legacy") {
|
||||||
if err := c.configs.Desktop.InitV2(cmd); err != nil {
|
if err := c.configs.Desktop.InitV2(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -107,6 +108,7 @@ func (c *serve) Init(cmd *cobra.Command) error {
|
||||||
if err := c.configs.Server.InitV2(cmd); err != nil {
|
if err := c.configs.Server.InitV2(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -122,6 +124,7 @@ func (c *serve) PreRun(cmd *cobra.Command, args []string) {
|
||||||
c.configs.Plugins.Set()
|
c.configs.Plugins.Set()
|
||||||
c.configs.Server.Set()
|
c.configs.Server.Set()
|
||||||
|
|
||||||
|
if viper.GetBool("legacy") {
|
||||||
c.configs.Desktop.SetV2()
|
c.configs.Desktop.SetV2()
|
||||||
c.configs.Capture.SetV2()
|
c.configs.Capture.SetV2()
|
||||||
c.configs.WebRTC.SetV2()
|
c.configs.WebRTC.SetV2()
|
||||||
|
@ -129,6 +132,7 @@ func (c *serve) PreRun(cmd *cobra.Command, args []string) {
|
||||||
c.configs.Session.SetV2()
|
c.configs.Session.SetV2()
|
||||||
c.configs.Server.SetV2()
|
c.configs.Server.SetV2()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *serve) Start(cmd *cobra.Command) {
|
func (c *serve) Start(cmd *cobra.Command) {
|
||||||
c.managers.session = session.New(
|
c.managers.session = session.New(
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
|
|
||||||
type Root struct {
|
type Root struct {
|
||||||
Config string
|
Config string
|
||||||
|
Legacy bool
|
||||||
|
|
||||||
LogLevel zerolog.Level
|
LogLevel zerolog.Level
|
||||||
LogTime string
|
LogTime string
|
||||||
|
@ -33,6 +34,12 @@ func (Root) Init(cmd *cobra.Command) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// whether legacy configs/api should be enabled (default: true, until v3.1)
|
||||||
|
cmd.PersistentFlags().BoolP("legacy", "l", true, "enable legacy mode")
|
||||||
|
if err := viper.BindPFlag("legacy", cmd.PersistentFlags().Lookup("legacy")); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
cmd.PersistentFlags().String("log.level", "info", "set log level (trace, debug, info, warn, error, fatal, panic, disabled)")
|
cmd.PersistentFlags().String("log.level", "info", "set log level (trace, debug, info, warn, error, fatal, panic, disabled)")
|
||||||
if err := viper.BindPFlag("log.level", cmd.PersistentFlags().Lookup("log.level")); err != nil {
|
if err := viper.BindPFlag("log.level", cmd.PersistentFlags().Lookup("log.level")); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -72,6 +79,7 @@ func (Root) InitV2(cmd *cobra.Command) error {
|
||||||
|
|
||||||
func (s *Root) Set() {
|
func (s *Root) Set() {
|
||||||
s.Config = viper.GetString("config")
|
s.Config = viper.GetString("config")
|
||||||
|
s.Legacy = viper.GetBool("legacy")
|
||||||
|
|
||||||
logLevel := viper.GetString("log.level")
|
logLevel := viper.GetString("log.level")
|
||||||
level, err := zerolog.ParseLevel(logLevel)
|
level, err := zerolog.ParseLevel(logLevel)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"m1k1o/neko/internal/config"
|
"m1k1o/neko/internal/config"
|
||||||
"m1k1o/neko/internal/http/legacy"
|
"m1k1o/neko/internal/http/legacy"
|
||||||
|
@ -56,7 +57,9 @@ func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, c
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// Legacy handler
|
// Legacy handler
|
||||||
|
if viper.GetBool("legacy") {
|
||||||
legacy.New().Route(router)
|
legacy.New().Route(router)
|
||||||
|
}
|
||||||
|
|
||||||
batch := batchHandler{
|
batch := batchHandler{
|
||||||
Router: router,
|
Router: router,
|
||||||
|
|
Loading…
Add table
Reference in a new issue