forked from drk1wi/Modlishka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
85 lines (59 loc) · 1.61 KB
/
main.go
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
"Modlishka" Reverse Proxy.
Copyright 2018 (C) Piotr Duszyński piotr[at]duszynski.eu. All rights reserved.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the Modlishka License along with this program.
**/
package main
import (
"github.com/drk1wi/Modlishka/config"
"github.com/drk1wi/Modlishka/core"
"github.com/drk1wi/Modlishka/log"
"github.com/drk1wi/Modlishka/plugin"
"github.com/drk1wi/Modlishka/runtime"
)
type Configuration struct{ config.Options }
// Initializes the logging object
func (c *Configuration) initLogging() {
//
// Logger
//
log.WithColors = true
if *c.Debug == true {
log.MinLevel = log.DEBUG
} else {
log.MinLevel = log.INFO
}
logGET := true
if *c.LogPostOnly {
logGET = false
}
log.Options = log.LoggingOptions{
GET: logGET,
POST: *c.LogPostOnly,
LogRequestPath: *c.LogRequestFile,
}
}
func main() {
conf := Configuration{
config.ParseConfiguration(),
}
// Initialize log
conf.initLogging()
// Set up runtime plugin config
plugin.SetPluginRuntimeConfig(conf.Options)
// Initialize plugins
plugin.Enable(conf.Options)
//Check if we have all of the required information to start proxy'ing requests.
conf.VerifyConfiguration()
// Set up runtime core config
runtime.SetCoreRuntimeConfig(conf.Options)
// Set up runtime server config
core.SetServerRuntimeConfig(conf.Options)
// Set up regexp upfront
runtime.MakeRegexes()
// go go go
core.RunServer()
}