-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwizard.go
116 lines (88 loc) · 3 KB
/
wizard.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package main
import (
"fmt"
"os"
"strconv"
)
func setupWizard() {
makeDefaultConfigFile()
fmt.Println("Pressing enter on a question will accept the default value.")
fmt.Println("Community or server name: (Used to skip ourselves in the server list)")
var communityName string
fmt.Scanln(&communityName)
if communityName == "" {
communityName = defaultCommunityName
}
serverConfig.CommunityName = communityName
fmt.Println("You will need a certificate and key file for HTTPS.")
fmt.Println("Run a rate-limited, cached HTTPS (SSL) webserver, to provide server-banlist.json? (y/N)")
var runSSLWebServer string
fmt.Scanln(&runSSLWebServer)
if runSSLWebServer == "y" || runSSLWebServer == "Y" {
serverConfig.WebServer.RunWebServer = true
fmt.Println("HTTPS Web server port (8443): ")
var webPort string
fmt.Scanln(&webPort)
if webPort == "" {
serverConfig.WebServer.SSLWebPort = defaultSSLWebPort
} else {
serverConfig.WebServer.SSLWebPort, _ = strconv.Atoi(webPort)
}
fmt.Println("Domain name (REQUIRED): ")
var domainName string
fmt.Scanln(&domainName)
if domainName == "" {
domainName = "test.com"
}
serverConfig.WebServer.DomainName = domainName
} else {
serverConfig.WebServer.SSLWebPort = 0
serverConfig.WebServer.RunWebServer = false
}
fmt.Println("Auto-subscribe to new servers? (Y/n)")
var autoSubscribe string
fmt.Scanln(&autoSubscribe)
if autoSubscribe == "N" || autoSubscribe == "n" {
serverConfig.ServerPrefs.AutoSubscribe = false
} else {
serverConfig.ServerPrefs.AutoSubscribe = true
}
fmt.Println("Require reason for bans? (y/N)")
var requireReason string
fmt.Scanln(&requireReason)
if requireReason == "Y" || requireReason == "y" {
serverConfig.ServerPrefs.RequireReason = true
} else {
serverConfig.ServerPrefs.RequireReason = false
}
fmt.Println("Strip ban reasons from public ban list? (y/N)")
var stripReasons string
fmt.Scanln(&stripReasons)
if stripReasons == "Y" || stripReasons == "y" {
serverConfig.ServerPrefs.StripReasons = true
} else {
serverConfig.ServerPrefs.StripReasons = false
}
fmt.Println("How often do you want to refresh the list of servers (in hours)? (12)")
var refreshListHours string
fmt.Scanln(&refreshListHours)
if refreshListHours == "" {
serverConfig.ServerPrefs.RefreshListHours = defaultRefreshListHours
} else {
serverConfig.ServerPrefs.RefreshListHours, _ = strconv.Atoi(refreshListHours)
}
fmt.Println("How often do you want to fetch ban lists from server (in minutes)? (15)")
var fetchBansMinutes string
fmt.Scanln(&fetchBansMinutes)
if fetchBansMinutes == "" {
serverConfig.ServerPrefs.FetchBansMinutes = defaultFetchBansMinutes
} else {
serverConfig.ServerPrefs.FetchBansMinutes, _ = strconv.Atoi(fetchBansMinutes)
}
writeConfigFile()
fmt.Println("Config file written to : " + configPath + ", please add paths to your banlist file (and HTTPS cert/key if needed) and check over the settings.")
fmt.Println("Press enter to exit.")
var exit string
fmt.Scanln(&exit)
os.Exit(1)
}