void isAncient(x0::HttpRequest *r, const x0::FlowParams& args, x0::FlowValue& result) { x0::BufferRef userAgent(r->requestHeader("User-Agent")); for (auto& ancient: ancients_) { if (userAgent.find(ancient.c_str()) != x0::BufferRef::npos) { result.set(true); return; } } result.set(false); }
// ssl.listener(BINDADDR_PORT); void add_listener(const x0::FlowParams& args, x0::FlowValue& result) { x0::SocketSpec socketSpec; socketSpec << args; if (!socketSpec.isValid()) { result.set(false); } else { x0::ServerSocket* listener = server().setupListener(socketSpec); if (listener) { SslDriver *driver = new SslDriver(this); listener->setSocketDriver(driver); } result.set(listener != nullptr); } }
void setup_filename(const x0::FlowParams& args, x0::FlowValue& result) { if (args.empty()) { result.set(filename_.c_str()); return; } args[0].load(filename_); checkStart(); }
void setup_step(const x0::FlowParams& args, x0::FlowValue& result) { if (args.empty()) { result.set(step_); return; } args[0].load(step_); if (step_) evTimer_.set(step_, step_); checkStart(); }
void isModern(x0::HttpRequest *r, const x0::FlowParams& args, x0::FlowValue& result) { x0::BufferRef userAgent(r->requestHeader("User-Agent")); for (auto& modern: modern_) { std::size_t i = userAgent.find(modern.first.c_str()); if (i == x0::BufferRef::npos) continue; i += modern.first.size(); if (userAgent[i] != '/') // expecting '/' as delimiter continue; float version = userAgent.ref(++i).toFloat(); if (version < modern.second) continue; result.set(true); return; } result.set(false); }