|
@@ -168,7 +168,7 @@ func (dm *DLineManager) CheckIP(addr net.IP) (isBanned bool, info *IPBanInfo) {
|
168
|
168
|
return false, nil
|
169
|
169
|
}
|
170
|
170
|
|
171
|
|
-// DLINE [duration] <ip>/<net> [ON <server>] [reason [| oper reason]]
|
|
171
|
+// DLINE [MYSELF] [duration] <ip>/<net> [ON <server>] [reason [| oper reason]]
|
172
|
172
|
func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
173
|
173
|
// check oper permissions
|
174
|
174
|
if !client.class.Capabilities["oper:local_ban"] {
|
|
@@ -178,6 +178,14 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
178
|
178
|
|
179
|
179
|
currentArg := 0
|
180
|
180
|
|
|
181
|
+ // when setting a ban that covers the oper's current connection, we require them to say
|
|
182
|
+ // "DLINE MYSELF" so that we're sure they really mean it.
|
|
183
|
+ var dlineMyself bool
|
|
184
|
+ if len(msg.Params) > currentArg+1 && strings.ToLower(msg.Params[currentArg]) == "myself" {
|
|
185
|
+ dlineMyself = true
|
|
186
|
+ currentArg++
|
|
187
|
+ }
|
|
188
|
+
|
181
|
189
|
// duration
|
182
|
190
|
duration, err := time.ParseDuration(msg.Params[currentArg])
|
183
|
191
|
durationIsUsed := err == nil
|
|
@@ -209,8 +217,16 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
209
|
217
|
|
210
|
218
|
if hostNet == nil {
|
211
|
219
|
hostString = hostAddr.String()
|
|
220
|
+ if !dlineMyself && hostAddr.Equal(net.ParseIP(IPString(client.socket.conn.RemoteAddr()))) {
|
|
221
|
+ client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, "This ban matches you. To DLINE yourself, you must pass use the command: /DLINE MYSELF <arguments>")
|
|
222
|
+ return false
|
|
223
|
+ }
|
212
|
224
|
} else {
|
213
|
225
|
hostString = hostNet.String()
|
|
226
|
+ if !dlineMyself && hostNet.Contains(net.ParseIP(IPString(client.socket.conn.RemoteAddr()))) {
|
|
227
|
+ client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, "This ban matches you. To DLINE yourself, you must pass use the command: /DLINE MYSELF <arguments>")
|
|
228
|
+ return false
|
|
229
|
+ }
|
214
|
230
|
}
|
215
|
231
|
|
216
|
232
|
// check remote
|