@@ -7,14 +7,15 @@ import (
77 "strings"
88
99 "github.com/karust/openserp/core"
10+ browserprofile "github.com/karust/openserp/core/browser"
1011 "github.com/sirupsen/logrus"
1112 "github.com/spf13/cobra"
1213 "github.com/spf13/pflag"
1314 "github.com/spf13/viper"
1415)
1516
1617const (
17- version = "0.6.5 "
18+ version = "0.6.6 "
1819 defaultConfigFilename = "config"
1920 envPrefix = "OPENSERP"
2021)
@@ -53,10 +54,10 @@ type ServerConfig struct {
5354type AppConfig struct {
5455 Timeout int `mapstructure:"timeout"`
5556 BrowserPath string `mapstructure:"browser_path"`
57+ ProfilesJSON string `mapstructure:"profiles"`
5658 IsBrowserHead bool `mapstructure:"head"`
5759 IsLeaveHead bool `mapstructure:"leave_head"`
5860 IsLeakless bool `mapstructure:"leakless"`
59- IsStealth bool `mapstructure:"stealth"`
6061 DebugEndpoints bool `mapstructure:"debug_endpoints"`
6162 LogFormat string `mapstructure:"log_format"`
6263}
@@ -102,6 +103,7 @@ var flagToConfigKey = map[string]string{
102103 "timeout" : "app.timeout" ,
103104 "config" : "server.config_path" ,
104105 "browser-path" : "app.browser_path" ,
106+ "profiles-json" : "app.profiles" ,
105107 "verbose" : "server.verbose" ,
106108 "debug" : "server.debug" ,
107109 "head" : "app.head" ,
@@ -110,7 +112,6 @@ var flagToConfigKey = map[string]string{
110112 "leave" : "app.leave_head" ,
111113 "2captcha_key" : "2captcha.apikey" ,
112114 "proxy" : "proxies.global" ,
113- "stealth" : "app.stealth" ,
114115 "debug-endpoints" : "app.debug_endpoints" ,
115116 "insecure" : "server.insecure" ,
116117 "cache_ttl" : "cache.ttl_seconds" ,
@@ -134,6 +135,9 @@ var RootCmd = &cobra.Command{
134135 if err != nil {
135136 return err
136137 }
138+ if err := browserprofile .LoadProfilesFromJSON (config .App .ProfilesJSON ); err != nil {
139+ return fmt .Errorf ("load app.profiles: %w" , err )
140+ }
137141
138142 logFormat , err := core .NormalizeLogFormat (config .App .LogFormat )
139143 if err != nil {
@@ -316,10 +320,10 @@ func setConfigDefaults(v *viper.Viper) {
316320
317321 v .SetDefault ("app.timeout" , 30 )
318322 v .SetDefault ("app.browser_path" , "" )
323+ v .SetDefault ("app.profiles" , "" )
319324 v .SetDefault ("app.head" , false )
320325 v .SetDefault ("app.leave_head" , false )
321326 v .SetDefault ("app.leakless" , false )
322- v .SetDefault ("app.stealth" , false )
323327 v .SetDefault ("app.debug_endpoints" , false )
324328
325329 v .SetDefault ("proxies.entries" , []interface {}{})
@@ -348,6 +352,7 @@ func init() {
348352 RootCmd .PersistentFlags ().IntVarP (& config .App .Timeout , "timeout" , "t" , 30 , "Timeout to fail request" )
349353 RootCmd .PersistentFlags ().StringVarP (& config .Server .ConfigPath , "config" , "c" , "" , "Configuration file path" )
350354 RootCmd .PersistentFlags ().StringVarP (& config .App .BrowserPath , "browser-path" , "" , "" , "Custom browser binary path (Chrome/Chromium/Edge/Brave..)" )
355+ RootCmd .PersistentFlags ().StringVar (& config .App .ProfilesJSON , "profiles" , "" , "Path to browser profile catalog JSON" )
351356 RootCmd .PersistentFlags ().BoolVarP (& config .Server .IsVerbose , "verbose" , "v" , false , "Use verbose output" )
352357 RootCmd .PersistentFlags ().BoolVarP (& config .Server .IsDebug , "debug" , "d" , false , "Use debug output. Disable headless browser" )
353358 RootCmd .PersistentFlags ().BoolVarP (& config .App .IsBrowserHead , "head" , "" , false , "Enable browser UI" )
@@ -356,7 +361,6 @@ func init() {
356361 RootCmd .PersistentFlags ().BoolVarP (& config .App .IsLeaveHead , "leave" , "" , false , "Leave browser and tabs opened after search is made" )
357362 RootCmd .PersistentFlags ().StringVarP (& config .Config2Capcha .ApiKey , "2captcha_key" , "" , "" , "2 captcha api key" )
358363 RootCmd .PersistentFlags ().StringVarP (& config .Proxies .Global , "proxy" , "x" , "" , "Force a single proxy for all engines (same as proxies.global)" )
359- RootCmd .PersistentFlags ().BoolVarP (& config .App .IsStealth , "stealth" , "s" , false , "Use stealth browser plugin" )
360364 RootCmd .PersistentFlags ().BoolVar (& config .App .DebugEndpoints , "debug-endpoints" , false , "Enable debug-only HTTP endpoints" )
361365 RootCmd .PersistentFlags ().BoolVarP (& config .Server .Insecure , "insecure" , "k" , false , "Allow insecure TLS connections" )
362366 RootCmd .PersistentFlags ().IntVar (& config .Cache .TTLSeconds , "cache_ttl" , 300 , "Cache TTL in seconds (0 to disable)" )
0 commit comments