add config option to disable elasticsearch ssl validation

This commit is contained in:
Cyberes 2024-05-13 14:43:35 -06:00
parent 4f2fe0b015
commit eef9233137
4 changed files with 10 additions and 6 deletions

View File

@ -39,7 +39,7 @@ Use the Kibana Dev Console to easily run queries: [/app/dev_tools#/console](/app
**Create a new index with the custom filename analyzer:** **Create a new index with the custom filename analyzer:**
```json ```json
PUT /crazyfs_search PUT /crazyfs-search
{ {
"settings": { "settings": {
"analysis": { "analysis": {

BIN
Doc/memory usage.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View File

@ -42,6 +42,7 @@ type Config struct {
ElasticsearchFullSyncOnStart bool ElasticsearchFullSyncOnStart bool
ElasticsearchDefaultQueryField string ElasticsearchDefaultQueryField string
ElasticPrintChanges bool ElasticPrintChanges bool
ElasticDisableCertVerificaiton bool
HTTPRealIPHeader string HTTPRealIPHeader string
HTTPNoMimeSniffHeader bool HTTPNoMimeSniffHeader bool
HTTPAccessControlAllowOriginHeader string HTTPAccessControlAllowOriginHeader string
@ -82,7 +83,7 @@ func SetConfig(configFile string) (*Config, error) {
viper.SetDefault("elasticsearch_sync_interval", 1800) viper.SetDefault("elasticsearch_sync_interval", 1800)
viper.SetDefault("elasticsearch_full_sync_interval", 86400) viper.SetDefault("elasticsearch_full_sync_interval", 86400)
viper.SetDefault("elasticsearch_api_key", "") viper.SetDefault("elasticsearch_api_key", "")
viper.SetDefault("elasticsearch_index", "crazyfs_search") viper.SetDefault("elasticsearch_index", "crazyfs-search")
viper.SetDefault("elasticsearch_sync_workers", 50) viper.SetDefault("elasticsearch_sync_workers", 50)
viper.SetDefault("elasticsearch_exclude_patterns", []string{".git"}) viper.SetDefault("elasticsearch_exclude_patterns", []string{".git"})
viper.SetDefault("elasticsearch_allow_concurrent_syncs", false) viper.SetDefault("elasticsearch_allow_concurrent_syncs", false)
@ -90,6 +91,7 @@ func SetConfig(configFile string) (*Config, error) {
viper.SetDefault("elasticsearch_query_fields", []string{"extension", "name", "path", "type", "size", "isDir"}) viper.SetDefault("elasticsearch_query_fields", []string{"extension", "name", "path", "type", "size", "isDir"})
viper.SetDefault("elasticsearch_default_query_field", "name") viper.SetDefault("elasticsearch_default_query_field", "name")
viper.SetDefault("elasticsearch_print_changes", false) viper.SetDefault("elasticsearch_print_changes", false)
viper.SetDefault("elasticsearch_disable_cert_verification", false)
viper.SetDefault("http_real_ip_header", "X-Forwarded-For") viper.SetDefault("http_real_ip_header", "X-Forwarded-For")
viper.SetDefault("http_no_mime_sniff_header", false) viper.SetDefault("http_no_mime_sniff_header", false)
viper.SetDefault("http_access_control_allow_origin_header", "*") viper.SetDefault("http_access_control_allow_origin_header", "*")
@ -143,6 +145,7 @@ func SetConfig(configFile string) (*Config, error) {
ElasticsearchExcludePatterns: viper.GetStringSlice("elasticsearch_exclude_patterns"), ElasticsearchExcludePatterns: viper.GetStringSlice("elasticsearch_exclude_patterns"),
ElasticsearchFullSyncOnStart: viper.GetBool("elasticsearch_full_sync_on_start"), ElasticsearchFullSyncOnStart: viper.GetBool("elasticsearch_full_sync_on_start"),
ElasticsearchDefaultQueryField: viper.GetString("elasticsearch_default_query_field"), ElasticsearchDefaultQueryField: viper.GetString("elasticsearch_default_query_field"),
ElasticDisableCertVerificaiton: viper.GetBool("elasticsearch_disable_cert_verification"),
ElasticPrintChanges: viper.GetBool("elasticsearch_print_changes"), ElasticPrintChanges: viper.GetBool("elasticsearch_print_changes"),
HTTPRealIPHeader: viper.GetString("http_real_ip_header"), HTTPRealIPHeader: viper.GetString("http_real_ip_header"),
HTTPNoMimeSniffHeader: viper.GetBool("http_no_mime_sniff_header"), HTTPNoMimeSniffHeader: viper.GetBool("http_no_mime_sniff_header"),

View File

@ -8,6 +8,7 @@ import (
"crazyfs/elastic" "crazyfs/elastic"
"crazyfs/logging" "crazyfs/logging"
"crazyfs/sharedcache" "crazyfs/sharedcache"
"crypto/tls"
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
@ -121,10 +122,10 @@ func main() {
cfg.ElasticsearchEndpoint, cfg.ElasticsearchEndpoint,
}, },
APIKey: cfg.ElasticsearchAPIKey, APIKey: cfg.ElasticsearchAPIKey,
//Transport: &http.Transport{ Transport: &http.Transport{
// MaxIdleConnsPerHost: config.GetConfig().ElasticsearchSyncWorkers + 1, // Skip certificate verification
// IdleConnTimeout: 30 * time.Second, TLSClientConfig: &tls.Config{InsecureSkipVerify: cfg.ElasticDisableCertVerificaiton},
//}, },
} }
es, err := elasticsearch.NewClient(esCfg) es, err := elasticsearch.NewClient(esCfg)
if err != nil { if err != nil {