-
Notifications
You must be signed in to change notification settings - Fork 0
/
mIRCd_confCheck.mrc
146 lines (141 loc) · 6.53 KB
/
mIRCd_confCheck.mrc
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
; mIRCd_confCheck.mrc
;
; Note: This script needs to be loaded all the time. However, if you want to run this once just to make sure your config is okay,
; then unload it, you will need to add (without the ; obv.)...
;
; alias mIRCd.check { return 0 }
;
; ...to mIRCd.mrc. But I will _not_ be accountable for your config being wrong if you modify it post that.
;
; Also, I'm not entirely happy with this script. Don't get me wrong, it works. I just wish it was slightly more condensed.
alias mIRCd.check {
; /mIRCd.check
if ($lines($mIRCd.fileConf) == 0) {
mIRCd.echo /mIRCd.check: config is empty, missing or has been renamed
return 1
}
var %this.section = Server
if ($readini($mIRCd.fileConf, %this.section, CLIENT_PORTS) == $null) {
mIRCd.echo $+($bracket(%this.section),:) CLIENT_PORTS cannot be blank.
return 1
}
var %this.item = $v1
if ($count($regsubex($str(.,$numtok(%this.item,44)),/./g,$iif($gettok(%this.item,\n,44) isnum 1-65535,1,0)),0) > 0) {
mIRCd.echo $+($bracket(%this.section),:) CLIENT_PORTS must contain a port with a numerical value between 1 and 65535. (Standard plaintext port is 6667.)
return 1
}
if ($readini($mIRCd.fileConf, %this.section, NETWORK_INFO) == $null) {
mIRCd.echo $+($bracket(%this.section),:) NETWORK_INFO cannot be blank.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, NETWORK_NAME) == $null) {
mIRCd.echo $+($bracket(%this.section),:) NETWORK_NAME cannot be blank.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, SERVER_NAME) == $null) {
mIRCd.echo $+($bracket(%this.section),:) SERVER_NAME cannot be blank.
return 1
}
var %this.serverName = $v1
if ($is_valid(%this.serverName).server == $false) {
mIRCd.echo $+($bracket(%this.section),:) SERVER_NAME is invalid. It must conform the rules of a domain.tld.
return 1
}
var %this.section = Mechanics
if ($readini($mIRCd.fileConf, %this.section, AWAYLEN) !isnum 1-) {
mIRCd.echo $+($bracket(%this.section),:) AWAYLEN must be a numerical value greater than 1.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, DEFAULT_SNOMASK) !isnum 1-65535) {
mIRCd.echo $+($bracket(%this.section),:) DEFAULT_SNOMASK must be a numerical value between 1 and 65535.
return 1
}
if (($readini($mIRCd.fileConf, %this.section, FLOOD_LIMIT) != $null) && ($readini($mIRCd.fileConf, %this.section, FLOOD_LIMIT) < 1024)) {
mIRCd.echo $+($bracket(%this.section),:) FLOOD_LIMIT must be a numerical value greater than 1024 bytes.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, KEYLEN) !isnum 1-23) {
mIRCd.echo $+($bracket(%this.section),:) KEYLEN must be a numerical value between 1 and 23.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, KICKLEN) !isnum 1-) {
mIRCd.echo $+($bracket(%this.section),:) KICKLEN must be a numerical value greater than 1.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, MAXBANS) !isnum 1-) {
mIRCd.echo $+($bracket(%this.section),:) MAXBANS must be a numerical value greater than 1.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, MAXACCEPT) !isnum 1-) {
mIRCd.echo $+($bracket(%this.section),:) MAXACCEPT must be a numerical value greater than 1.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, MAXBLOCKS) !isnum 1-) {
mIRCd.echo $+($bracket(%this.section),:) MAXBLOCKS must be a numerical value greater than 1.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, MAXCHANNELS) !isnum 1-) {
mIRCd.echo $+($bracket(%this.section),:) MAXCHANNELS must be a numerical value greater than 1.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, MAXCHANNELLEN) !isnum 2-200) {
mIRCd.echo $+($bracket(%this.section),:) MAXCHANNELLEN must be a numerical value between 2 and 200.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, MAXNICKLEN) !isnum 1-32) {
mIRCd.echo $+($bracket(%this.section),:) MAXNICKLEN must be a numerical value between 1 and 32.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, MAXSILENCE) !isnum 1-) {
mIRCd.echo $+($bracket(%this.section),:) MAXSILENCE must be a numerical value greater than 1.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, MODESPL) !isnum 3-) {
mIRCd.echo $+($bracket(%this.section),:) MODESPL must be a numerical value three or greater.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, NICK_CHANGE_THROTTLE) !isnum 1-) {
mIRCd.echo $+($bracket(%this.section),:) NICK_CHANGE_THROTTLE must be a numerical value greater than 1.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, PING_DURATION) !isnum 60-) {
mIRCd.echo $+($bracket(%this.section),:) PING_DURATION must be a numerical value greater than 60 seconds.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, PING_TIMEOUT_DURATION) !isnum 60-) {
mIRCd.echo $+($bracket(%this.section),:) PING_TIMEOUT_DURATION must be a numerical value greater than 60 seconds.
return 1
}
var %this.timeDuration = $v1
if ($calc(%this.timeDuration - $readini($mIRCd.fileConf, %this.section, PING_DURATION)) < 5) {
mIRCd.echo $+($bracket(%this.section),:) PING_TIMEOUT_DURATION must be at least five seconds higher than PING_DURATION.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, REGISTRATION_DURATION) !isnum 60-) {
mIRCd.echo $+($bracket(%this.section),:) REGISTRATION_DURATION must be a numerical value greater than 60 seconds.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, REGISTRATION_TIMEOUT_DURATION) !isnum 60-) {
mIRCd.echo $+($bracket(%this.section),:) REGISTRATION_TIMEOUT_DURATION must be a numerical value greater than 60 seconds.
return 1
}
if ($readini($mIRCd.fileConf, n, %this.section, SALT) == $null) {
mIRCd.echo $+($bracket(%this.section),:) SALT cannot be blank.
return 1
}
if ($readini($mIRCd.fileConf, %this.section, TOPICLEN) !isnum 1-) {
mIRCd.echo $+($bracket(%this.section),:) TOPICLEN must be a numerical value greater than 1.
return 1
}
var %this.section = Admin
if ($ini($mIRCd.fileConf, %this.section) == $null) { return 0 }
; `-> Admin itself is entirely optional.
if ($readini($mIRCd.fileConf, %this.section, ADMIN_LOC1) == $null) {
mIRCd.echo $+($bracket(%this.section),:) ADMIN_LOC1 cannot be blank.
return 1
}
return 0
}
; Commands and Functions
alias bool_check { return $iif($istok(FALSE TRUE,$1,32) == $true,$true,$false) }
; EOF