File: config.go

package info (click to toggle)
go-exploitdb 0.0~git20181130.7c961e7-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 208 kB
  • sloc: makefile: 4
file content (55 lines) | stat: -rw-r--r-- 940 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package config

import (
	valid "github.com/asaskevich/govalidator"
	"github.com/inconshreveable/log15"
)

// CommonConfig :
type CommonConfig struct {
	Debug     bool
	DebugSQL  bool
	Quiet     bool
	Deep      bool
	DBPath    string
	DBType    string
	HTTPProxy string
}

// SearchConfig :
type SearchConfig struct {
	SearchType  string
	SearchParam string
}

// ServerConfig :
type ServerConfig struct {
	Bind string
	Port string
}

// CommonConf :
var CommonConf CommonConfig

// SearchConf :
var SearchConf SearchConfig

// ServerConf :
var ServerConf ServerConfig

// Validate :
func (p *CommonConfig) Validate() bool {
	if p.DBType == "sqlite3" {
		if ok, _ := valid.IsFilePath(p.DBPath); !ok {
			log15.Error("SQLite3 DB path must be a *Absolute* file path.", "dbpath", p.DBPath)
			return false
		}
	}

	_, err := valid.ValidateStruct(p)
	if err != nil {
		log15.Error("Invalid Struct", "err", err)
		return false
	}
	return true
}