|
|
@ -33,6 +33,7 @@ import java.io.IOException;
|
|
|
|
import java.io.ObjectInputStream;
|
|
|
|
import java.io.ObjectInputStream;
|
|
|
|
import java.io.ObjectOutputStream;
|
|
|
|
import java.io.ObjectOutputStream;
|
|
|
|
import java.io.PrintWriter;
|
|
|
|
import java.io.PrintWriter;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
@ -256,17 +257,27 @@ public class Blacklist {
|
|
|
|
loadList(blFile, sep);
|
|
|
|
loadList(blFile, sep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public final void removeAll(final BlacklistType blacklistType, final String host) {
|
|
|
|
/**
|
|
|
|
getBlacklistMap(blacklistType, true).remove(host);
|
|
|
|
* remove the host/path from internal blacklist maps for given blacklistType
|
|
|
|
getBlacklistMap(blacklistType, false).remove(host);
|
|
|
|
* !! and removes the entry from source blacklist file !!
|
|
|
|
}
|
|
|
|
* @param blacklistType
|
|
|
|
|
|
|
|
* @param blacklistToUse
|
|
|
|
|
|
|
|
* @param host
|
|
|
|
|
|
|
|
* @param path
|
|
|
|
|
|
|
|
*/
|
|
|
|
public final void remove(final BlacklistType blacklistType, final String blacklistToUse, final String host, final String path) {
|
|
|
|
public final void remove(final BlacklistType blacklistType, final String blacklistToUse, final String host, final String path) {
|
|
|
|
|
|
|
|
|
|
|
|
final Map<String, Set<Pattern>> blacklistMap = getBlacklistMap(blacklistType, true);
|
|
|
|
final Map<String, Set<Pattern>> blacklistMap = getBlacklistMap(blacklistType, true);
|
|
|
|
Set<Pattern> hostList = blacklistMap.get(host);
|
|
|
|
Set<Pattern> hostList = blacklistMap.get(host);
|
|
|
|
if (hostList != null) {
|
|
|
|
if (hostList != null) {
|
|
|
|
hostList.remove(path);
|
|
|
|
// remove pattern from list (by comparing patternstring with path, remove(path) will not match path)
|
|
|
|
|
|
|
|
for (Pattern hp : hostList) {
|
|
|
|
|
|
|
|
String hpxs = hp.pattern();
|
|
|
|
|
|
|
|
if (hpxs.equals(path)) {
|
|
|
|
|
|
|
|
hostList.remove(hp);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (hostList.isEmpty()) {
|
|
|
|
if (hostList.isEmpty()) {
|
|
|
|
blacklistMap.remove(host);
|
|
|
|
blacklistMap.remove(host);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -275,12 +286,21 @@ public class Blacklist {
|
|
|
|
final Map<String, Set<Pattern>> blacklistMapNotMatch = getBlacklistMap(blacklistType, false);
|
|
|
|
final Map<String, Set<Pattern>> blacklistMapNotMatch = getBlacklistMap(blacklistType, false);
|
|
|
|
hostList = blacklistMapNotMatch.get(host);
|
|
|
|
hostList = blacklistMapNotMatch.get(host);
|
|
|
|
if (hostList != null) {
|
|
|
|
if (hostList != null) {
|
|
|
|
hostList.remove(path);
|
|
|
|
// remove pattern from list
|
|
|
|
|
|
|
|
for (Pattern hp : hostList) {
|
|
|
|
|
|
|
|
String hpxs = hp.pattern();
|
|
|
|
|
|
|
|
if (hpxs.equals(path)) {
|
|
|
|
|
|
|
|
hostList.remove(hp);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (hostList.isEmpty()) {
|
|
|
|
if (hostList.isEmpty()) {
|
|
|
|
blacklistMapNotMatch.remove(host);
|
|
|
|
blacklistMapNotMatch.remove(host);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: check if delete from blacklist is desired, on reload entry will not be available in any blacklist
|
|
|
|
|
|
|
|
// even if remove (above) from internal maps (at runtime) is only done for given blacklistType
|
|
|
|
// load blacklist data from file
|
|
|
|
// load blacklist data from file
|
|
|
|
final List<String> list = FileUtils.getListArray(new File(ListManager.listsPath, blacklistToUse));
|
|
|
|
final List<String> list = FileUtils.getListArray(new File(ListManager.listsPath, blacklistToUse));
|
|
|
|
|
|
|
|
|
|
|
|