Procházet zdrojové kódy

cache account.showBlockStats in redis

pull/43/head
Jonathan Cobb před 4 roky
rodič
revize
5227a9f112
3 změnil soubory, kde provedl 9 přidání a 3 odebrání
  1. +2
    -0
      bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java
  2. +1
    -3
      bubble-server/src/main/java/bubble/rule/bblock/BubbleBlockRuleDriver.java
  3. +6
    -0
      bubble-server/src/main/java/bubble/service/cloud/StandardDeviceIdService.java

+ 2
- 0
bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java Zobrazit soubor

@@ -15,6 +15,7 @@ import bubble.model.app.BubbleApp;
import bubble.model.device.Device;
import bubble.resources.stream.FilterHttpRequest;
import bubble.server.BubbleConfiguration;
import bubble.service.cloud.StandardDeviceIdService;
import bubble.service.stream.AppPrimerService;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.jknack.handlebars.Handlebars;
@@ -56,6 +57,7 @@ public abstract class AbstractAppRuleDriver implements AppRuleDriver {
@Autowired protected BubbleNetworkDAO networkDAO;
@Autowired protected DeviceDAO deviceDAO;
@Autowired protected AppPrimerService appPrimerService;
@Autowired protected StandardDeviceIdService deviceService;

@Getter @Setter private AppRuleDriver next;



+ 1
- 3
bubble-server/src/main/java/bubble/rule/bblock/BubbleBlockRuleDriver.java Zobrazit soubor

@@ -57,8 +57,7 @@ public class BubbleBlockRuleDriver extends TrafficAnalyticsRuleDriver implements

private final static Map<String, BlockListSource> blockListCache = new ConcurrentHashMap<>();

private Boolean showStats;
public boolean showStats() { return bool(showStats); }
public boolean showStats() { return deviceService.doShowBlockStats(account); }

@Override public <C> Class<C> getConfigClass() { return (Class<C>) BubbleBlockConfig.class; }

@@ -77,7 +76,6 @@ public class BubbleBlockRuleDriver extends TrafficAnalyticsRuleDriver implements
Account account,
Device device) {
super.init(config, userConfig, app, rule, matcher, account, device);
showStats = account.showBlockStats();
refreshBlockLists();
}



+ 6
- 0
bubble-server/src/main/java/bubble/service/cloud/StandardDeviceIdService.java Zobrazit soubor

@@ -51,6 +51,7 @@ public class StandardDeviceIdService implements DeviceIdService {
// used in dnscrypt-proxy and mitmproxy to check device security level
public static final String REDIS_KEY_DEVICE_SECURITY_LEVEL_PREFIX = "bubble_device_security_level_";
public static final String REDIS_KEY_DEVICE_SITE_MAX_SECURITY_LEVEL_PREFIX = "bubble_device_site_max_security_level_";
public static final String REDIS_KEY_ACCOUNT_SHOW_BLOCK_STATS = "bubble_account_showBlockStats_";

// used in dnscrypt-proxy to determine how to respond to blocked requests
public static final String REDIS_KEY_DEVICE_REJECT_WITH = "bubble_device_reject_with_";
@@ -152,6 +153,7 @@ public class StandardDeviceIdService implements DeviceIdService {
}

public void initBlockStats (Account account) {
redis.set_plaintext(REDIS_KEY_ACCOUNT_SHOW_BLOCK_STATS+account.getUuid(), Boolean.toString(account.showBlockStats()));
for (Device device : deviceDAO.findByAccount(account.getUuid())) {
if (account.showBlockStats()) {
showBlockStats(device);
@@ -161,6 +163,10 @@ public class StandardDeviceIdService implements DeviceIdService {
}
}

public boolean doShowBlockStats(Account account) {
return Boolean.parseBoolean(redis.get_plaintext(REDIS_KEY_ACCOUNT_SHOW_BLOCK_STATS + account.getUuid()));
}

public void showBlockStats (Device device) {
final Set<String> configuredIps = NetworkUtil.configuredIps();
final String privateIp = configuredIps.stream()


Načítá se…
Zrušit
Uložit