#pragma once #include "include/global/NekoGui.hpp" namespace NekoGui { enum inputType {trufalse, select, text}; const int IranBypassChainID = 111111111; const int ChinaBypassChainID = 222222222; class RouteRule : public JsonStore { public: RouteRule(); RouteRule(const RouteRule& other); QString name = ""; QString ip_version; QString network; QString protocol; QList inbound; QList domain; QList domain_suffix; QList domain_keyword; QList domain_regex; QList source_ip_cidr; bool source_ip_is_private = false; QList ip_cidr; bool ip_is_private = false; QList source_port; QList source_port_range; QList port; QList port_range; QList process_name; QList process_path; QList process_path_regex; QList rule_set; bool invert = false; int outboundID = -2; // -1 is proxy -2 is direct -3 is block -4 is dns_out [[nodiscard]] QJsonObject get_rule_json(bool forView = false, const QString& outboundTag = "") const; static QStringList get_attributes(); static inputType get_input_type(const QString& fieldName); static QStringList get_values_for_field(const QString& fieldName); QStringList get_current_value_string(const QString& fieldName); [[nodiscard]] QString get_current_value_bool(const QString& fieldName) const; void set_field_value(const QString& fieldName, const QStringList& value); [[nodiscard]] bool isEmpty() const; }; class RoutingChain : public JsonStore { public: int id = -1; QString name = ""; QList> Rules; QList castedRules; RoutingChain(); RoutingChain(const RoutingChain& other); static QList> parseJsonArray(const QJsonArray& arr, QString* parseError); bool Save() override; void FromJson(QJsonObject object); QJsonArray get_route_rules(bool forView = false, std::map outboundMap = {}); bool isViewOnly() const; static std::shared_ptr GetDefaultChain(); static std::shared_ptr GetIranDefaultChain(); static std::shared_ptr GetChinaDefaultChain(); std::shared_ptr> get_used_outbounds(); std::shared_ptr get_used_rule_sets(); QStringList get_direct_sites(); }; } // namespace NekoGui