Compare commits

..

8 Commits

Author SHA1 Message Date
david
849370e26a 优化docker 2020-12-22 00:14:52 +08:00
david
815156b252 修复重复注入拼接规则bug 2020-12-14 15:16:51 +08:00
david
d62be67927 修改docker定时 2020-12-14 11:47:59 +08:00
david
d513b1bedf 修改 Dockerfile 2020-12-14 02:36:38 +08:00
david
b566181968 优化辅种前置检查 2020-12-13 21:06:13 +08:00
david
60b4939aee fix 2020-12-12 15:47:08 +08:00
david
dad8afa8d4 fix 2020-12-12 15:16:54 +08:00
david
a60e5f859c 补充新规则的配置参数 2020-12-12 14:46:49 +08:00
7 changed files with 72 additions and 62 deletions

View File

@@ -1,4 +1,5 @@
#FROM alpine:latest
#FROM alpine:3.12
FROM alpine:3.8
#FROM swoft/alphp:base
#FROM swoft/alphp:cli
@@ -18,7 +19,7 @@ ARG app_env=prod
ENV APP_ENV=${app_env:-"prod"} \
TIMEZONE=${timezone:-"Asia/Shanghai"} \
cron="9 11 * * 0"
cron="3 11 * * *"
##
# ---------- building ----------
@@ -26,7 +27,7 @@ ENV APP_ENV=${app_env:-"prod"} \
RUN set -ex \
# change apk source repo
# && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories \
#&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories \
&& apk update \
&& apk add --no-cache \
# Install base packages ('ca-certificates' will install 'nghttp2-libs')
@@ -62,6 +63,7 @@ RUN set -ex \
# php7-pdo_mysql \
# php7-pdo_sqlite \
# php7-phar \
# php7-pcntl \
# php7-posix \
# php7-redis \
php7-simplexml \
@@ -76,9 +78,9 @@ RUN set -ex \
php7-zip \
# php7-zlib \
php7-xml \
&& git clone https://gitee.com/ledc/IYUUAutoReseed.git /var/www \
&& cp /var/www/config/config.sample.php /var/www/config/config.php \
&& ln -sf /var/www/config/config.php /config.php \
&& git clone https://gitee.com/ledc/IYUUAutoReseed.git /IYUU \
&& cp /IYUU/config/config.sample.php /IYUU/config/config.php \
&& ln -sf /IYUU/config/config.php /config.php \
&& apk del --purge *-dev \
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/share/php7 \
# ---------- some config,clear work ----------
@@ -93,7 +95,8 @@ RUN set -ex \
# - config timezone
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
&& echo "${TIMEZONE}" > /etc/timezone \
&& echo '2 */5 * * * cd /var/www && git fetch --all && git reset --hard origin/master' >> /etc/crontabs/root \
&& echo '2 */5 * * * cd /IYUU && git fetch --all && git reset --hard origin/master' >> /etc/crontabs/root \
#&& echo "${cron} /usr/bin/php /IYUU/iyuu.php &> /dev/null" >> /etc/crontabs/root \
# ---------- some config work ----------
# - ensure 'www-data' user exists(82 is the standard uid/gid for "www-data" in Alpine)
# && addgroup -g 82 -S ${add_user} \
@@ -103,8 +106,7 @@ RUN set -ex \
# && chown -R ${add_user}:${add_user} /data \
&& echo -e "\033[42;37m Build Completed :).\033[0m\n"
EXPOSE 9000
# VOLUME ["/var/www", "/data"]
WORKDIR /var/www
CMD ["sh", "-c", "/usr/bin/php /var/www/iyuu.php ; /usr/sbin/crond ; (crontab -l ;echo \"$cron /usr/bin/php /var/www/iyuu.php &> /dev/null\") | crontab - ; tail -f /dev/null"]
# EXPOSE 9000
# VOLUME ["/IYUU", "/data"]
WORKDIR /IYUU
ENTRYPOINT ["/IYUU/docker/entrypoint.sh"]

View File

@@ -13,7 +13,7 @@ use IYUU\Library\Table;
class AutoReseed
{
// 版本号
const VER = '1.10.12';
const VER = '1.10.16';
// RPC连接
private static $links = [];
// 客户端配置
@@ -22,10 +22,8 @@ class AutoReseed
private static $sites = [];
// 推荐的合作站点
private static $recommend = [];
// 不辅种的站点 'pt','hdchina'
// 不辅种的站点
private static $noReseed = [];
// cookie检查
private static $cookieCheck = [];
// 缓存路径
public static $cacheDir = TORRENT_PATH.'cache'.DS;
public static $cacheHash = TORRENT_PATH.'cachehash'.DS;
@@ -371,7 +369,7 @@ class AutoReseed
// 初始化
if (!empty(self::$sites[$sid]['reseed_check'])) {
$reseed_check = explode(',', self::$sites[$sid]['reseed_check']);
array_walk($reseed_check, function (&$v, $k){
array_walk($reseed_check, function (&$v, $k) {
$v = trim($v);
});
self::$sites[$sid]['reseed_check'] = $reseed_check;
@@ -747,11 +745,6 @@ class AutoReseed
if (empty($configALL[$siteName]) || empty($configALL[$siteName][$item])) {
$msg = '-------因当前' .$siteName. "站点未设置".$item.",已跳过!!".PHP_EOL.PHP_EOL;
echo $msg;
// 调试代码begin
if ($siteName == 'pthome') {
sleepIYUU(10, $msg);
}
// 调试代码end
self::$wechatMsg['reseedSkip']++;
return false;
}
@@ -953,15 +946,6 @@ class AutoReseed
if (empty($configALL[$site]['url_replace'])) {
$configALL[$site]['url_replace'] = array('{passkey}' => trim($configALL[$site]['passkey']));
}
if (empty($configALL[$site]['url_join'])) {
$configALL[$site]['url_join'] = array();
if (in_array($site, array('m-team','hdbd'))) {
if (isset($configALL[$site]['ip_type'])) {
$configALL[$site]['url_join'][] = $configALL[$site]['ip_type'].'=1';
}
$configALL[$site]['url_join'][] = 'https=1';
}
}
}
// 通用操作:替换
if (isset($configALL[$site]['url_replace']) && $configALL[$site]['url_replace']) {
@@ -987,8 +971,9 @@ class AutoReseed
$now = time();
$uid = isset($configALL[$site]['id']) ? $configALL[$site]['id'] : $now;
$pk = isset($configALL[$site]['passkey']) ? trim($configALL[$site]['passkey']) : $now;
$hash = md5(trim($pk));
$signString = self::getDownloadTorrentSign($site);
$signString = self::getDownloadTorrentSign($site); // 检查签名有效期,如果过期获取新的签名
switch ($site) {
case 'pthome':
case 'hdhome':
@@ -996,11 +981,11 @@ class AutoReseed
//兼容性处理:新旧规则
if (isset($configALL[$site]['rss']) && $configALL[$site]['rss']) {
$url = str_replace('passkey={passkey}', 'uid={uid}&hash={hash}', $url);
$pk = $configALL[$site]['rss']; // 专用下载hash
$hash = $configALL[$site]['rss']; // 直接提交专用下载hash
}
break;
case 'ourbits':
// 兼容性处理:新旧规则
// 兼容旧版本的IYUU
if (isset($configALL[$site]['id']) && $configALL[$site]['id']) {
$url = str_replace('passkey={passkey}', 'uid={uid}&hash={hash}', $url);
}
@@ -1009,29 +994,36 @@ class AutoReseed
default:
break;
}
// 兼容性处理:新旧规则
if (isset($configALL[$site]['new']) && $configALL[$site]['new']) {
$url = str_replace('passkey={passkey}', 'uid={uid}&hash={hash}', $url);
}
// 注入替换规则
$replace = [
'{uid}' => $uid,
'{hash}'=> md5(trim($pk)),
'{passkey}' => $pk, // 兼容性处理
'{hash}'=> $hash,
'{passkey}' => $pk, // 兼容旧版本的IYUU
];
$configALL[$site]['url_replace'] = $replace;
// 注入拼接规则
if (empty($configALL[$site]['url_join'])) {
$configALL[$site]['url_join'] = array();
$configALL[$site]['runtime_url_join'] = []; //保存用户配置规则
$configALL[$site]['url_join'] = array($signString);
} else {
// 用户已配置过url_join 1.先保存用户原来的规则2.恢复规则3.注入签名规则
if (!isset($configALL[$site]['runtime_url_join'])) {
$configALL[$site]['runtime_url_join'] = $configALL[$site]['url_join']; //保存用户配置规则
} else {
$configALL[$site]['url_join'] = $configALL[$site]['runtime_url_join']; //恢复用户配置规则
}
$configALL[$site]['url_join'][] = $signString;
}
}
return $url;
}
/**
* 获取下载合作站种子的签名
* @descr 检查签名有效期,如果过期将获取新的签名
* @param string $site
* @return string
*/
@@ -1050,7 +1042,7 @@ class AutoReseed
'timestamp' => time(),
'version' => self::VER,
'site' => $site,
'uid' => $configALL[$site]['id']
'uid' => isset($configALL[$site]['id']) ? $configALL[$site]['id'] : 0,
];
$res = self::$curl->get(self::$apiUrl . self::$endpoints['getSign'], $data);
$ret = json_decode($res->response, true);
@@ -1063,7 +1055,7 @@ class AutoReseed
$configALL[$site][$expireKEY] = time() + $expire - 60; // 提前60秒过期
}
} else {
echo $site.' 很抱歉请求IYUU辅种签名时失败啦请稍后重新尝试辅种'.PHP_EOL;
echo $site.' 很抱歉请求IYUU辅种签名时失败啦请稍后重新尝试辅种详情:'.$ret['msg'].PHP_EOL;
}
return $signString;

View File

@@ -131,6 +131,8 @@ return array(
'cookie' => '',
// 如果需要自动辅种,必须配置
'passkey' => '',
// 如果需要辅种,必须配置
'rss' => '',
'id' => 0, // 用户ID(不是用户名)
'url_replace' => array(),
'url_join' => array(),
@@ -145,6 +147,8 @@ return array(
'cookie' => '',
// 如果需要自动辅种,必须配置
'passkey' => '',
// 如果需要辅种,必须配置
'rss' => '',
'id' => 0, // 用户ID(不是用户名)
'url_replace' => array(),
'url_join' => array(),
@@ -159,6 +163,8 @@ return array(
'cookie' => '',
// 如果需要自动辅种,必须配置
'passkey' => '',
// 如果需要辅种,必须配置
'rss' => '',
'id' => 0, // 用户ID(不是用户名)
'url_replace' => array(),
'url_join' => array(),

View File

@@ -19,7 +19,7 @@ ARG app_env=prod
ENV APP_ENV=${app_env:-"prod"} \
TIMEZONE=${timezone:-"Asia/Shanghai"} \
cron="0 10 * * 0"
cron="3 11 * * *"
##
# ---------- building ----------
@@ -27,7 +27,7 @@ ENV APP_ENV=${app_env:-"prod"} \
RUN set -ex \
# change apk source repo
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories \
#&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories \
&& apk update \
&& apk add --no-cache \
# Install base packages ('ca-certificates' will install 'nghttp2-libs')
@@ -78,9 +78,9 @@ RUN set -ex \
php7-zip \
# php7-zlib \
php7-xml \
&& git clone https://gitee.com/ledc/IYUUAutoReseed.git /var/www \
&& cp /var/www/config/config.sample.php /var/www/config/config.php \
&& ln -sf /var/www/config/config.php /config.php \
&& git clone https://gitee.com/ledc/IYUUAutoReseed.git /IYUU \
&& cp /IYUU/config/config.sample.php /IYUU/config/config.php \
&& ln -sf /IYUU/config/config.php /config.php \
&& apk del --purge *-dev \
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/share/php7 \
# ---------- some config,clear work ----------
@@ -95,7 +95,8 @@ RUN set -ex \
# - config timezone
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
&& echo "${TIMEZONE}" > /etc/timezone \
&& echo '2 */5 * * * cd /var/www && git fetch --all && git reset --hard origin/master' >> /etc/crontabs/root \
&& echo '2 */5 * * * cd /IYUU && git fetch --all && git reset --hard origin/master' >> /etc/crontabs/root \
#&& echo "${cron} /usr/bin/php /IYUU/iyuu.php &> /dev/null" >> /etc/crontabs/root \
# ---------- some config work ----------
# - ensure 'www-data' user exists(82 is the standard uid/gid for "www-data" in Alpine)
# && addgroup -g 82 -S ${add_user} \
@@ -105,8 +106,7 @@ RUN set -ex \
# && chown -R ${add_user}:${add_user} /data \
&& echo -e "\033[42;37m Build Completed :).\033[0m\n"
EXPOSE 9000
# VOLUME ["/var/www", "/data"]
WORKDIR /var/www
CMD ["sh", "-c", "/usr/bin/php /var/www/iyuu.php ; /usr/sbin/crond ; (crontab -l ;echo \"$cron /usr/bin/php /var/www/iyuu.php &> /dev/null\") | crontab - ; tail -f /dev/null"]
# EXPOSE 9000
# VOLUME ["/IYUU", "/data"]
WORKDIR /IYUU
ENTRYPOINT ["/IYUU/docker/entrypoint.sh"]

View File

@@ -1,9 +1,10 @@
# FROM arm64v8/alpine
# FROM arm64v8/alpine:latest
FROM arm64v8/alpine:3.12
ENV TZ Asia/Shanghai
ENV cron="0 9 * * 0"
ENV cron="3 15 * * *"
RUN set -ex \
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories \
@@ -20,8 +21,10 @@ RUN set -ex \
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
&& echo "${TZ}" > /etc/timezone \
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo '2 */6 * * * cd /IYUU && git fetch --all && git reset --hard origin/master' >> /etc/crontabs/root
# && echo '* * * * * echo "iyuu.cn" >/dev/null 2>&1' >> /etc/crontabs/root \
&& echo '3 */6 * * * cd /IYUU && git fetch --all && git reset --hard origin/master' >> /etc/crontabs/root \
# && echo "${cron} /usr/bin/php /IYUU/iyuu.php >/dev/null 2>&1" >> /etc/crontabs/root \
&& echo -e "\033[42;37m Build Completed :).\033[0m\n"
WORKDIR /IYUU
CMD ["sh", "-c", "/usr/bin/php /IYUU/iyuu.php ; /usr/sbin/crond ; (crontab -l ;echo \"$cron /usr/bin/php /IYUU/iyuu.php &> /dev/null\") | crontab - ; tail -f /dev/null"]
ENTRYPOINT ["/IYUU/docker/entrypoint.sh"]

7
docker/entrypoint.sh Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
DEFAULT_CRON="9 */6 * * *"
cron=${cron:-$DEFAULT_CRON}
set -e
echo "$cron /usr/bin/php /IYUU/iyuu.php" | crontab -
/usr/bin/php /IYUU/iyuu.php
/usr/sbin/crond -f