|
@@ -203,6 +203,17 @@ func (set *UserMaskSet) Add(mask string) bool {
|
203
|
203
|
return true
|
204
|
204
|
}
|
205
|
205
|
|
|
206
|
+func (set *UserMaskSet) AddAll(masks []string) (added bool) {
|
|
207
|
+ for _, mask := range masks {
|
|
208
|
+ if !added && !set.masks[mask] {
|
|
209
|
+ added = true
|
|
210
|
+ }
|
|
211
|
+ set.masks[mask] = true
|
|
212
|
+ }
|
|
213
|
+ set.setRegexp()
|
|
214
|
+ return
|
|
215
|
+}
|
|
216
|
+
|
206
|
217
|
func (set *UserMaskSet) Remove(mask string) bool {
|
207
|
218
|
if !set.masks[mask] {
|
208
|
219
|
return false
|
|
@@ -229,6 +240,12 @@ func (set *UserMaskSet) String() string {
|
229
|
240
|
return strings.Join(masks, " ")
|
230
|
241
|
}
|
231
|
242
|
|
|
243
|
+// Generate a regular expression from the set of user mask
|
|
244
|
+// strings. Masks are split at the two types of wildcards, `*` and
|
|
245
|
+// `?`. All the pieces are meta-escaped. `*` is replaced with `.*`,
|
|
246
|
+// the regexp equivalent. Likewise, `?` is replaced with `.`. The
|
|
247
|
+// parts are re-joined and finally all masks are joined into a big
|
|
248
|
+// or-expression.
|
232
|
249
|
func (set *UserMaskSet) setRegexp() {
|
233
|
250
|
if len(set.masks) == 0 {
|
234
|
251
|
set.regexp = nil
|