mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-01 17:25:02 +00:00
Enhancements
Fix potential crash when parsing some stream nodes. Add support for some other types of stream/expiry time nodes. Update build scripts.
This commit is contained in:
6 files changed
+33
-27
No files matched your search
+3
-3
@@ -38,7 +38,7 @@ jobs:
|
|||||||
- name: "Linux x86_64 Build"
|
- name: "Linux x86_64 Build"
|
||||||
services: docker
|
services: docker
|
||||||
script:
|
script:
|
||||||
- docker run -v $TRAVIS_BUILD_DIR:/root/workdir alpine:latest /bin/sh -c "apk add bash git && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
- docker run -v $TRAVIS_BUILD_DIR:/root/workdir multiarch/alpine:amd64-edge /bin/sh -c "apk add bash git && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
||||||
deploy:
|
deploy:
|
||||||
provider: releases
|
provider: releases
|
||||||
token: "$GITHUB_OAUTH_TOKEN"
|
token: "$GITHUB_OAUTH_TOKEN"
|
||||||
@@ -49,8 +49,8 @@ jobs:
|
|||||||
tags: true
|
tags: true
|
||||||
- name: "Linux ARMHF Build"
|
- name: "Linux ARMHF Build"
|
||||||
services: docker
|
services: docker
|
||||||
|
arch: arm64
|
||||||
script:
|
script:
|
||||||
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
||||||
- docker run --rm -v $TRAVIS_BUILD_DIR:/root/workdir multiarch/alpine:armhf-edge /bin/sh -c "apk add bash git && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
- docker run --rm -v $TRAVIS_BUILD_DIR:/root/workdir multiarch/alpine:armhf-edge /bin/sh -c "apk add bash git && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- mv subconverter_linux64.tar.gz subconverter_armhf.tar.gz
|
- mv subconverter_linux64.tar.gz subconverter_armhf.tar.gz
|
||||||
@@ -66,7 +66,7 @@ jobs:
|
|||||||
services: docker
|
services: docker
|
||||||
arch: arm64
|
arch: arm64
|
||||||
script:
|
script:
|
||||||
- docker run -v $TRAVIS_BUILD_DIR:/root/workdir alpine:latest /bin/sh -c "apk add bash git && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
- docker run -v $TRAVIS_BUILD_DIR:/root/workdir multiarch/alpine:aarch64-edge /bin/sh -c "apk add bash git && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- mv subconverter_linux64.tar.gz subconverter_aarch64.tar.gz
|
- mv subconverter_linux64.tar.gz subconverter_aarch64.tar.gz
|
||||||
deploy:
|
deploy:
|
||||||
|
|||||||
+2
-1
@@ -19,13 +19,14 @@ common:
|
|||||||
|
|
||||||
userinfo:
|
userinfo:
|
||||||
stream_rule:
|
stream_rule:
|
||||||
|
- {match: "^剩余流量:(.*?)\\|总流量:(.*)$", replace: "total=$2&left=$1"}
|
||||||
- {match: "^剩余流量:(.*?) (.*)$", replace: "total=$1&left=$2"}
|
- {match: "^剩余流量:(.*?) (.*)$", replace: "total=$1&left=$2"}
|
||||||
- {match: "^Bandwidth: (.*?)/(.*)$", replace: "used=$1&total=$2"}
|
- {match: "^Bandwidth: (.*?)/(.*)$", replace: "used=$1&total=$2"}
|
||||||
- {match: "^.*剩余(.*?)(?:\\s*?)@(?:.*)$", replace: "total=$1"}
|
- {match: "^.*剩余(.*?)(?:\\s*?)@(?:.*)$", replace: "total=$1"}
|
||||||
- {match: "^.*?流量:(.*?) 剩:(?:.*)$", replace: "total=$1"}
|
- {match: "^.*?流量:(.*?) 剩:(?:.*)$", replace: "total=$1"}
|
||||||
time_rule:
|
time_rule:
|
||||||
- {match: "^过期时间:(\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)$", replace: "$1:$2:$3:$4:$5:$6"}
|
- {match: "^过期时间:(\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)$", replace: "$1:$2:$3:$4:$5:$6"}
|
||||||
- {match: "^到期时间:(\\d+)-(\\d+)-(\\d+)$", replace: "$1:$2:$3:0:0:0"}
|
- {match: "^到期时间(:|:)(\\d+)-(\\d+)-(\\d+)$", replace: "$1:$2:$3:0:0:0"}
|
||||||
- {match: "^Smart Access expire: (\\d+)/(\\d+)/(\\d+)$", replace: "$1:$2:$3:0:0:0"}
|
- {match: "^Smart Access expire: (\\d+)/(\\d+)/(\\d+)$", replace: "$1:$2:$3:0:0:0"}
|
||||||
- {match: "^.*?流量:(?:.*?) 剩:(.*?)天$", replace: "left=$1d"}
|
- {match: "^.*?流量:(?:.*?) 剩:(.*?)天$", replace: "left=$1d"}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -52,6 +52,7 @@ append_proxy_type=false
|
|||||||
;Rules to extract stream data from node
|
;Rules to extract stream data from node
|
||||||
;Format: full_match_regex|new_format_regex
|
;Format: full_match_regex|new_format_regex
|
||||||
;where new_format_regex should be like "total=$1&left=$2&used=$3"
|
;where new_format_regex should be like "total=$1&left=$2&used=$3"
|
||||||
|
stream_rule=^剩余流量:(.*?)\|总流量:(.*)$|total=$2&left=$1
|
||||||
stream_rule=^剩余流量:(.*?) (.*)$|total=$1&left=$2
|
stream_rule=^剩余流量:(.*?) (.*)$|total=$1&left=$2
|
||||||
stream_rule=^Bandwidth: (.*?)/(.*)$|used=$1&total=$2
|
stream_rule=^Bandwidth: (.*?)/(.*)$|used=$1&total=$2
|
||||||
stream_rule=^\[.*?\]剩余(.*?)@(?:.*)$|total=$1
|
stream_rule=^\[.*?\]剩余(.*?)@(?:.*)$|total=$1
|
||||||
@@ -61,7 +62,7 @@ stream_rule=^.*?流量:(.*?) 剩:(?:.*)$|total=$1
|
|||||||
;Format: full_match_regex|new_format_regex
|
;Format: full_match_regex|new_format_regex
|
||||||
;where new_format_regex should follow this example: yyyy:mm:dd:hh:mm:ss
|
;where new_format_regex should follow this example: yyyy:mm:dd:hh:mm:ss
|
||||||
time_rule=^过期时间:(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)$|$1:$2:$3:$4:$5:$6
|
time_rule=^过期时间:(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)$|$1:$2:$3:$4:$5:$6
|
||||||
time_rule=^到期时间:(\d+)-(\d+)-(\d+)$|$1:$2:$3:0:0:0
|
time_rule=^到期时间(:|:)(\d+)-(\d+)-(\d+)$|$1:$2:$3:0:0:0
|
||||||
time_rule=^Smart Access expire: (\d+)/(\d+)/(\d+)$|$1:$2:$3:0:0:0
|
time_rule=^Smart Access expire: (\d+)/(\d+)/(\d+)$|$1:$2:$3:0:0:0
|
||||||
time_rule=^.*?流量:(?:.*?) 剩:(.*)$|left=$1d
|
time_rule=^.*?流量:(?:.*?) 剩:(.*)$|left=$1d
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
mkdir obj
|
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
apk add gcc g++ build-base linux-headers cmake make autoconf automake libtool
|
apk add gcc g++ build-base linux-headers cmake make autoconf automake libtool
|
||||||
@@ -13,10 +12,13 @@ cd ..
|
|||||||
|
|
||||||
cmake .
|
cmake .
|
||||||
make -j2
|
make -j2
|
||||||
|
rm subconverter
|
||||||
g++ -o base/subconverter CMakeFiles/subconverter.dir/src/*.o -static -lpcre2-8 -levent -lyaml-cpp -lcurl -lnghttp2 -lssl -lcrypto -lz -lbz2 -ldl -lpthread -O3 -s
|
g++ -o base/subconverter CMakeFiles/subconverter.dir/src/*.o -static -lpcre2-8 -levent -lyaml-cpp -lcurl -lnghttp2 -lssl -lcrypto -lz -lbz2 -ldl -lpthread -O3 -s
|
||||||
|
|
||||||
cd base
|
cd base
|
||||||
chmod +rx subconverter
|
chmod +rx subconverter
|
||||||
chmod +r *
|
chmod +r *
|
||||||
|
cd ..
|
||||||
|
mv base subconverter
|
||||||
|
|
||||||
tar czf ../subconverter_linux64.tar.gz *
|
tar czf subconverter_linux64.tar.gz subconverter/
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
mkdir obj
|
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
brew reinstall yaml-cpp rapidjson libevent zlib pcre2 bzip2 pkgconfig
|
brew reinstall yaml-cpp rapidjson libevent zlib pcre2 bzip2 pkgconfig
|
||||||
|
|
||||||
git clone https://github.com/curl/curl
|
git clone https://github.com/curl/curl
|
||||||
cd curl
|
cd curl
|
||||||
./buildconf > /dev/null
|
#./buildconf > /dev/null
|
||||||
./configure --with-ssl=/usr/local/opt/openssl@1.1 --without-mbedtls --disable-ldap --disable-ldaps --disable-rtsp --without-libidn2 > /dev/null
|
#./configure --with-ssl=/usr/local/opt/openssl@1.1 --without-mbedtls --disable-ldap --disable-ldaps --disable-rtsp --without-libidn2 > /dev/null
|
||||||
|
cmake -DHTTP_ONLY=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 . > /dev/null
|
||||||
make -j8 > /dev/null
|
make -j8 > /dev/null
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
cp curl/lib/.libs/libcurl.a .
|
cp curl/lib/libcurl.a .
|
||||||
cp /usr/local/lib/libevent.a .
|
cp /usr/local/lib/libevent.a .
|
||||||
cp /usr/local/opt/zlib/lib/libz.a .
|
cp /usr/local/opt/zlib/lib/libz.a .
|
||||||
cp /usr/local/opt/openssl@1.1/lib/libssl.a .
|
cp /usr/local/opt/openssl@1.1/lib/libssl.a .
|
||||||
@@ -23,12 +23,14 @@ cp /usr/local/opt/bzip2/lib/libbz2.a .
|
|||||||
export CMAKE_CXX_FLAGS="-I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include"
|
export CMAKE_CXX_FLAGS="-I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include"
|
||||||
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 .
|
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 .
|
||||||
make -j8
|
make -j8
|
||||||
|
rm subconverter
|
||||||
c++ -Xlinker -unexported_symbol -Xlinker "*" -o base/subconverter CMakeFiles/subconverter.dir/src/*.o libpcre2-8.a libevent.a libcurl.a libz.a libssl.a libcrypto.a libyaml-cpp.a libbz2.a -ldl -lpthread -O3
|
c++ -Xlinker -unexported_symbol -Xlinker "*" -o base/subconverter CMakeFiles/subconverter.dir/src/*.o libpcre2-8.a libevent.a libcurl.a libz.a libssl.a libcrypto.a libyaml-cpp.a libbz2.a -ldl -lpthread -O3
|
||||||
|
|
||||||
cd base
|
cd base
|
||||||
chmod +rx subconverter
|
chmod +rx subconverter
|
||||||
chmod +r *
|
chmod +r *
|
||||||
tar czf ../subconverter_darwin64.tar.gz *
|
|
||||||
cd ..
|
cd ..
|
||||||
|
mv base subconverter
|
||||||
|
tar czf subconverter_darwin64.tar.gz subconverter
|
||||||
|
|
||||||
set +xe
|
set +xe
|
||||||
+15
-15
@@ -1694,17 +1694,17 @@ static inline unsigned long long streamToInt(std::string stream)
|
|||||||
return 0;
|
return 0;
|
||||||
double streamval = 1.0;
|
double streamval = 1.0;
|
||||||
if(stream.find("GB") != std::string::npos)
|
if(stream.find("GB") != std::string::npos)
|
||||||
streamval = std::pow(1024, 3) * stof(stream.substr(0, stream.size() - 2));
|
streamval = std::pow(1024, 3) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
||||||
else if(stream.find("TB") != std::string::npos)
|
else if(stream.find("TB") != std::string::npos)
|
||||||
streamval = std::pow(1024, 4) * stof(stream.substr(0, stream.size() - 2));
|
streamval = std::pow(1024, 4) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
||||||
else if(stream.find("PB") != std::string::npos)
|
else if(stream.find("PB") != std::string::npos)
|
||||||
streamval = std::pow(1024, 5) * stof(stream.substr(0, stream.size() - 2));
|
streamval = std::pow(1024, 5) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
||||||
else if(stream.find("MB") != std::string::npos)
|
else if(stream.find("MB") != std::string::npos)
|
||||||
streamval = std::pow(1024, 2) * stof(stream.substr(0, stream.size() - 2));
|
streamval = std::pow(1024, 2) * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
||||||
else if(stream.find("KB") != std::string::npos)
|
else if(stream.find("KB") != std::string::npos)
|
||||||
streamval = 1024.0 * stof(stream.substr(0, stream.size() - 2));
|
streamval = 1024.0 * to_number<float>(stream.substr(0, stream.size() - 2), 0.0);
|
||||||
else if(stream.find("B") != std::string::npos)
|
else if(stream.find("B") != std::string::npos)
|
||||||
streamval = 1.0 * stof(stream.substr(0, stream.size() - 1));
|
streamval = 1.0 * to_number<float>(stream.substr(0, stream.size() - 1), 0.0);
|
||||||
return (unsigned long long)streamval;
|
return (unsigned long long)streamval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1764,7 +1764,7 @@ bool getSubInfoFromHeader(std::string &header, std::string &result)
|
|||||||
bool getSubInfoFromNodes(std::vector<nodeInfo> &nodes, string_array &stream_rules, string_array &time_rules, std::string &result)
|
bool getSubInfoFromNodes(std::vector<nodeInfo> &nodes, string_array &stream_rules, string_array &time_rules, std::string &result)
|
||||||
{
|
{
|
||||||
std::string remarks, pattern, target, stream_info, time_info, retStr;
|
std::string remarks, pattern, target, stream_info, time_info, retStr;
|
||||||
string_array vArray;
|
string_size spos;
|
||||||
|
|
||||||
for(nodeInfo &x : nodes)
|
for(nodeInfo &x : nodes)
|
||||||
{
|
{
|
||||||
@@ -1773,11 +1773,11 @@ bool getSubInfoFromNodes(std::vector<nodeInfo> &nodes, string_array &stream_rule
|
|||||||
{
|
{
|
||||||
for(std::string &y : stream_rules)
|
for(std::string &y : stream_rules)
|
||||||
{
|
{
|
||||||
vArray = split(y, "|");
|
spos = y.rfind("|");
|
||||||
if(vArray.size() != 2)
|
if(spos == y.npos)
|
||||||
continue;
|
continue;
|
||||||
pattern = vArray[0];
|
pattern = y.substr(0, spos);
|
||||||
target = vArray[1];
|
target = y.substr(spos + 1);
|
||||||
if(regMatch(remarks, pattern))
|
if(regMatch(remarks, pattern))
|
||||||
{
|
{
|
||||||
retStr = regReplace(remarks, pattern, target);
|
retStr = regReplace(remarks, pattern, target);
|
||||||
@@ -1797,11 +1797,11 @@ bool getSubInfoFromNodes(std::vector<nodeInfo> &nodes, string_array &stream_rule
|
|||||||
{
|
{
|
||||||
for(std::string &y : time_rules)
|
for(std::string &y : time_rules)
|
||||||
{
|
{
|
||||||
vArray = split(y, "|");
|
spos = y.rfind("|");
|
||||||
if(vArray.size() != 2)
|
if(spos == y.npos)
|
||||||
continue;
|
continue;
|
||||||
pattern = vArray[0];
|
pattern = y.substr(0, spos);
|
||||||
target = vArray[1];
|
target = y.substr(spos + 1);
|
||||||
if(regMatch(remarks, pattern))
|
if(regMatch(remarks, pattern))
|
||||||
{
|
{
|
||||||
retStr = regReplace(remarks, pattern, target);
|
retStr = regReplace(remarks, pattern, target);
|
||||||
|
|||||||
Reference in new issue
Block a user