mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Enhancements
Fix crash when using WireGuard as type filter rule. Fix support for compiler older than gcc-10 or clang-10. Optimize codes.
This commit is contained in:
parent
7ea43f9c01
commit
b71cd1e668
@ -116,7 +116,7 @@ bool applyMatcher(const std::string &rule, std::string &real_rule, const Proxy &
|
||||
std::string target, ret_real_rule;
|
||||
static const std::string groupid_regex = R"(^!!(?:GROUPID|INSERT)=([\d\-+!,]+)(?:!!(.*))?$)", group_regex = R"(^!!(?:GROUP)=(.+?)(?:!!(.*))?$)";
|
||||
static const std::string type_regex = R"(^!!(?:TYPE)=(.+?)(?:!!(.*))?$)", port_regex = R"(^!!(?:PORT)=(.+?)(?:!!(.*))?$)", server_regex = R"(^!!(?:SERVER)=(.+?)(?:!!(.*))?$)";
|
||||
static const string_array types = {"", "SS", "SSR", "VMESS", "TROJAN", "SNELL", "HTTP", "HTTPS", "SOCKS5"};
|
||||
static const string_array types = {"", "SS", "SSR", "VMESS", "TROJAN", "SNELL", "HTTP", "HTTPS", "SOCKS5", "WIREGUARD"};
|
||||
if(startsWith(rule, "!!GROUP="))
|
||||
{
|
||||
regGetMatch(rule, group_regex, 3, 0, &target, &ret_real_rule);
|
||||
@ -155,7 +155,7 @@ bool applyMatcher(const std::string &rule, std::string &real_rule, const Proxy &
|
||||
return true;
|
||||
}
|
||||
|
||||
void processRemark(std::string &remark, string_array &remarks_list, bool proc_comma = true)
|
||||
void processRemark(std::string &remark, const string_array &remarks_list, bool proc_comma = true)
|
||||
{
|
||||
// Replace every '=' with '-' in the remark string to avoid parse errors from the clients.
|
||||
// Surge is tested to yield an error when handling '=' in the remark string,
|
||||
@ -172,7 +172,7 @@ void processRemark(std::string &remark, string_array &remarks_list, bool proc_co
|
||||
}
|
||||
std::string tempRemark = remark;
|
||||
int cnt = 2;
|
||||
while(std::find(remarks_list.begin(), remarks_list.end(), tempRemark) != remarks_list.end())
|
||||
while(std::find(remarks_list.cbegin(), remarks_list.cend(), tempRemark) != remarks_list.cbegin())
|
||||
{
|
||||
tempRemark = remark + " " + std::to_string(cnt);
|
||||
cnt++;
|
||||
|
||||
@ -93,6 +93,16 @@ namespace rapidjson_ext {
|
||||
{
|
||||
return (*this)(root);
|
||||
};
|
||||
|
||||
friend ReturnType operator| (rapidjson::Value &root, const ExtensionFunction<ReturnType> &func)
|
||||
{
|
||||
return func(root);
|
||||
}
|
||||
|
||||
friend ReturnType operator| (rapidjson::Value &&root, const ExtensionFunction<ReturnType> &func)
|
||||
{
|
||||
return func(root);
|
||||
}
|
||||
};
|
||||
|
||||
struct AddMemberOrReplace : public ExtensionFunction<rapidjson::Value &> {
|
||||
@ -165,18 +175,6 @@ namespace rapidjson_ext {
|
||||
return buffer.GetString();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ReturnType>
|
||||
inline ReturnType operator| (rapidjson::Value &root, const ExtensionFunction<ReturnType> &func)
|
||||
{
|
||||
return func(root);
|
||||
}
|
||||
|
||||
template <typename ReturnType>
|
||||
inline ReturnType operator| (rapidjson::Value &&root, const ExtensionFunction<ReturnType> &func)
|
||||
{
|
||||
return func(root);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -14,25 +14,37 @@ template <typename T> inline void eraseElements(T &target)
|
||||
T().swap(target);
|
||||
}
|
||||
|
||||
template <typename Container, typename Element>
|
||||
concept ConstIterable = requires(Container a, Element b) {
|
||||
#if __cpp_concepts >= 201907L // C++20 concepts supported (g++-10 or clang++-10)
|
||||
|
||||
template <typename Container>
|
||||
concept ConstIterable = requires(Container a) {
|
||||
{ a.cbegin() } -> std::same_as<typename Container::const_iterator>;
|
||||
{ a.cend() } -> std::same_as<typename Container::const_iterator>;
|
||||
typename Container::const_reference;
|
||||
};
|
||||
|
||||
template <typename Container, typename Element>
|
||||
concept Iterable = requires(Container a, Element b) {
|
||||
template <typename Container>
|
||||
concept Iterable = requires(Container a) {
|
||||
{ a.begin() } -> std::same_as<typename Container::iterator>;
|
||||
{ a.end() } -> std::same_as<typename Container::iterator>;
|
||||
typename Container::reference;
|
||||
};
|
||||
|
||||
template <typename ConstIterableContainer>
|
||||
requires ConstIterable<ConstIterableContainer, typename ConstIterableContainer::value_type>
|
||||
inline bool none_of(ConstIterableContainer &container, std::function<bool(typename ConstIterableContainer::const_reference)> func)
|
||||
requires ConstIterable<ConstIterableContainer>
|
||||
inline bool none_of(const ConstIterableContainer &container, std::function<bool(typename ConstIterableContainer::const_reference)> func)
|
||||
{
|
||||
return std::none_of(container.cbegin(), container.cend(), func);
|
||||
}
|
||||
|
||||
#else // __cpp_concepts >= 201907L
|
||||
|
||||
template <typename Container>
|
||||
inline bool none_of(const Container &container, std::function<bool(typename Container::const_reference)> func)
|
||||
{
|
||||
return std::none_of(container.cbegin(), container.cend(), func);
|
||||
}
|
||||
|
||||
#endif // __cpp_concepts >= 201907L
|
||||
|
||||
#endif // STL_EXTRA_H_INCLUDED
|
||||
|
||||
Loading…
Reference in New Issue
Block a user