return true;
}
-AppId HostTracker::get_appid(Port port, IpProtocol proto, bool inferred_only)
+AppId HostTracker::get_appid(Port port, IpProtocol proto, bool inferred_only, bool allow_port_wildcard)
{
host_tracker_stats.service_finds++;
std::lock_guard<std::mutex> lck(host_tracker_lock);
for ( const auto& s : services )
{
- if ( s.port == port and s.proto == proto and
- (!inferred_only or s.inferred_appid == inferred_only) )
+ bool matched = (s.port == port and s.proto == proto and (!inferred_only or s.inferred_appid == inferred_only));
+ if ( matched or ( allow_port_wildcard and s.inferred_appid ) )
return s.appid;
}
bool add_service(Port port, IpProtocol proto,
AppId appid = APP_ID_NONE, bool inferred_appid = false);
- AppId get_appid(Port port, IpProtocol proto, bool inferred_only = false);
+ AppId get_appid(Port port, IpProtocol proto, bool inferred_only = false, bool allow_port_wildcard = false);
// This should be updated whenever HostTracker data members are changed
void stringify(std::string& str);
config->is_host_port_app_cache_runtime = true;
}
}
+ else if (!(strcasecmp(conf_key, "allow_port_wildcard_host_cache")))
+ {
+ if (!(strcasecmp(conf_val, "enabled")))
+ {
+ config->allow_port_wildcard_host_cache = true;
+ }
+ }
+ else if (!(strcasecmp(conf_key, "bittorrent_aggressiveness")))
+ {
+ int aggressiveness = atoi(conf_val);
+ LogMessage("AppId: bittorrent_aggressiveness %d\n", aggressiveness);
+ if (aggressiveness >= 50)
+ {
+ config->host_port_app_cache_lookup_interval = 5;
+ set_app_info_flags(APP_ID_BITTORRENT, APPINFO_FLAG_DEFER);
+ set_app_info_flags(APP_ID_BITTORRENT, APPINFO_FLAG_DEFER_PAYLOAD);
+ config->max_tp_flow_depth = 25;
+ LogMessage("AppId: host_port_app_cache_lookup_interval %d\n", config->host_port_app_cache_lookup_interval);
+ LogMessage("AppId: defer_to_thirdparty %d\n", APP_ID_BITTORRENT);
+ LogMessage("AppId: defer_payload_to_thirdparty %d\n", APP_ID_BITTORRENT);
+ LogMessage("AppId: max_tp_flow_depth %d\n", config->max_tp_flow_depth);
+ }
+ if (aggressiveness >= 80)
+ {
+ config->allow_port_wildcard_host_cache = true;
+ LogMessage("AppId: allow_port_wildcard_host_cache enabled\n");
+ }
+ }
else if (!(strcasecmp(conf_key, "tp_allow_probes")))
{
if (!(strcasecmp(conf_val, "enabled")))
uint32_t host_port_app_cache_lookup_interval = 10;
uint32_t host_port_app_cache_lookup_range = 100000;
uint32_t http_response_version_enabled = 0;
+ bool allow_port_wildcard_host_cache = false;
};
typedef std::array<SF_LIST*, APP_ID_PORT_ARRAY_SIZE> AppIdPortExclusions;
auto ht = host_cache.find(*ip);
if (ht)
{
- AppId appid = ht->get_appid(port, protocol, true);
+ AppId appid = ht->get_appid(port, protocol, true, asd.config->mod_config->allow_port_wildcard_host_cache);
if (appid > APP_ID_NONE)
{
// FIXIT-L: Make this more generic to support service and payload IDs
}
HostCacheIp host_cache(50);
-AppId HostTracker::get_appid(Port, IpProtocol, bool)
+AppId HostTracker::get_appid(Port, IpProtocol, bool, bool)
{
return APP_ID_NONE;
}