Skip to content

Commit

Permalink
Merge pull request #161 from AirportR/dev
Browse files Browse the repository at this point in the history
3.6.7
  • Loading branch information
AirportR authored Feb 20, 2024
2 parents 15acd11 + bfedde1 commit 2d68ca9
Show file tree
Hide file tree
Showing 25 changed files with 632 additions and 533 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build_meta_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: build_meta_image

on:
push:
paths:
- 'docker/Metafile'
- 'docker/Metafile.alpine'
- 'requirements.txt'
branches:
- "dev"

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Environment Variables
run: |
IMG=fulltclash
echo "IMG=${IMG}" >> $GITHUB_ENV
echo "IMAGE=${{ secrets.DOCKERHUB_USERNAME }}/${IMG}" >> $GITHUB_ENV
- name: Build Debian Image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Metafile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE }}:debian
- name: Build Alpine Image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Metafile.alpine
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE }}:alpine
40 changes: 30 additions & 10 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- ".github/ISSUE_TEMPLATE/**"
branches:
- "master"
- "dev"

jobs:
docker:
Expand All @@ -20,19 +21,21 @@ jobs:
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Environment Variables
run: |
IMG=fulltclash
OWNER="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
echo "IMG=${IMG}" >> $GITHUB_ENV
echo "IMAGE=ghcr.io/${OWNER}/${IMG}" >> $GITHUB_ENV
- name: Build and push
echo "IMAGE=${{ secrets.DOCKERHUB_USERNAME }}/${IMG}" >> $GITHUB_ENV
- name: Get version
id: get_version
run: echo "version=$(git describe --tags --always)" >> $GITHUB_OUTPUT
- name: Build Latest Image
if: ${{ github.ref_name == 'dev' }}
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
Expand All @@ -41,13 +44,30 @@ jobs:
push: true
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:dev
- name: Build alpine Docker
${{ env.IMAGE }}:debian-${{ github.ref_name }}
${{ env.IMAGE }}:${{ steps.get_version.outputs.version }}
build-args: |
GIT_Branch=${{ github.ref_name }}
- name: Build Debian Image
if: ${{ github.ref_name != 'dev' }}
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
file: ./docker/Dockerfile
push: true
tags: |
${{ env.IMAGE }}:debian-${{ github.ref_name }}
${{ env.IMAGE }}:${{ steps.get_version.outputs.version }}
- name: Build Alpine Image
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
file: ./docker/Dockerfile.alpine
push: true
tags: |
${{ env.IMAGE }}:alpine
${{ env.IMAGE }}:alpine-${{ github.ref_name }}
${{ env.IMAGE }}:${{ steps.get_version.outputs.version }}
build-args: |
GIT_Branch=${{ github.ref_name }}
71 changes: 25 additions & 46 deletions addons/builtin/netflix.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ async def fetch_netflix(Collector, session: aiohttp.ClientSession, flag=1, proxy
locate = text.find("preferredLocale") # 定位到关键标签
if locate > 0:
region = text[locate + 29:locate + 31]
Collector.info['netflix_new'] = f"解锁({region})"
Collector.info['netflix'] = f"解锁({region})"
else:
region = "未知"
Collector.info['netflix_new'] = f"解锁({region})"
Collector.info['netflix'] = f"解锁({region})"
except IndexError as e:
logger.error(e)
Collector.info['netflix_new'] = "N/A"
Collector.info['netflix'] = "N/A"
elif res.status == 403:
if reconnection == 0:
logger.info("不支持非自制剧,正在检测自制剧...")
Expand All @@ -66,38 +66,38 @@ async def fetch_netflix(Collector, session: aiohttp.ClientSession, flag=1, proxy
elif flag == 2:
async with session.get(netflix_url2, proxy=proxy, timeout=5) as res:
if res.status == 200: # 解锁自制
Collector.info['netflix_new'] = "自制"
Collector.info['netflix'] = "自制"
elif res.status == 403:
if reconnection == 0:
Collector.info['netflix_new'] = "失败"
Collector.info['netflix'] = "失败"
return
await fetch_netflix(Collector, session, flag=flag, proxy=proxy, reconnection=reconnection - 1)
elif res.status == 503:
Collector.info['netflix_new'] = "-"
Collector.info['netflix'] = "-"
return
else:
Collector.info['netflix_new'] = "失败"
Collector.info['netflix'] = "失败"
else:
return
except ClientConnectorError as c:
logger.warning("Netflix请求发生错误:" + str(c))
if reconnection != 0:
await fetch_netflix(Collector, session, flag=flag, proxy=proxy, reconnection=reconnection - 1)
else:
Collector.info['netflix_new'] = "连接错误"
Collector.info['netflix'] = "连接错误"
except ServerDisconnectedError as s:
logger.warning("Netflix请求发生错误:" + str(s))
if reconnection != 0:
await fetch_netflix(Collector, session, flag=flag, proxy=proxy, reconnection=reconnection - 1)
else:
Collector.info['netflix_new'] = "-"
Collector.info['netflix'] = "-"

except asyncio.exceptions.TimeoutError:
logger.warning("Netflix请求超时,正在重新发送请求......")
if reconnection != 0:
await fetch_netflix(Collector, session, flag=flag, proxy=proxy, reconnection=reconnection - 1)
else:
Collector.info['netflix_new'] = "超时"
Collector.info['netflix'] = "超时"
except ProxyConnectionError as p:
logger.warning("似乎目标端口未开启监听")
logger.warning(str(p))
Expand Down Expand Up @@ -133,63 +133,57 @@ async def fetch_netflix_new(Collector, session: aiohttp.ClientSession, flag=1, p
locate = text.find("preferredLocale") # 定位到关键标签
if locate > 0:
region = text[locate + 29:locate + 31]
Collector.info['netflix_new'] = f"解锁({region})"
Collector.info['netflix'] = f"解锁({region})"
else:
region = "未知"
Collector.info['netflix_new'] = f"解锁({region})"
Collector.info['netflix'] = f"解锁({region})"
except IndexError as e:
logger.error(e)
Collector.info['netflix_new'] = "N/A"
Collector.info['netflix'] = "N/A"
elif res.status == 403:
if reconnection == 0:
logger.info("不支持非自制剧,正在检测自制剧...")
await fetch_netflix_new(Collector, session, flag=flag + 1, proxy=proxy, reconnection=5)
return
await fetch_netflix_new(Collector, session, flag=flag, proxy=proxy, reconnection=reconnection - 1)
elif res.status == 503:
logger.info("非自制剧服务不可用(被banIP),正在检测自制剧...")
await fetch_netflix_new(Collector, session, flag=flag + 1, proxy=proxy, reconnection=5)
return
else:
logger.info("不支持非自制剧,正在检测自制剧...")
await fetch_netflix_new(Collector, session, flag=flag + 1, proxy=proxy, reconnection=reconnection)
elif flag == 2:
async with session.get(netflix_url2, proxy=proxy, timeout=5, ssl=_myssl) as res:
if res.status == 200: # 解锁自制
Collector.info['netflix_new'] = "自制"
Collector.info['netflix'] = "自制"
elif res.status == 403:
if reconnection == 0:
Collector.info['netflix_new'] = "失败"
Collector.info['netflix'] = "失败"
return
await fetch_netflix_new(Collector, session, flag=flag, proxy=proxy, reconnection=reconnection - 1)
elif res.status == 503:
Collector.info['netflix_new'] = "-"
Collector.info['netflix'] = "-"
return
else:
Collector.info['netflix_new'] = "失败"
Collector.info['netflix'] = "失败"
else:
return
except ClientConnectorError as c:
logger.warning("Netflix请求发生错误:" + str(c))
if reconnection != 0:
await fetch_netflix_new(Collector, session, flag=flag, proxy=proxy, reconnection=reconnection - 1)
else:
Collector.info['netflix_new'] = "连接错误"
except ServerDisconnectedError as s:
logger.warning("Netflix请求发生错误:" + str(s))
Collector.info['netflix'] = "连接错误"
except ServerDisconnectedError:
if reconnection != 0:
await fetch_netflix_new(Collector, session, flag=flag, proxy=proxy, reconnection=reconnection - 1)
else:
Collector.info['netflix_new'] = "-"
Collector.info['netflix'] = "-"

except asyncio.exceptions.TimeoutError:
logger.warning("Netflix请求超时,正在重新发送请求......")
if reconnection != 0:
await fetch_netflix_new(Collector, session, flag=flag, proxy=proxy, reconnection=reconnection - 1)
else:
Collector.info['netflix_new'] = "超时"
Collector.info['netflix'] = "超时"
except ProxyConnectionError as p:
logger.warning("似乎目标端口未开启监听")
logger.warning(str(p))


Expand All @@ -214,12 +208,12 @@ def get_netflix_info(ReCleaner):
:return: str: 解锁信息: [解锁(地区代码)、失败、N/A]
"""
try:
if 'netflix_new' not in ReCleaner.data:
if 'netflix' not in ReCleaner.data:
logger.warning("采集器内无数据")
return "N/A"
else:
logger.info("netflix解锁:" + str(ReCleaner.data.get('netflix_new', "N/A")))
return ReCleaner.data.get('netflix_new', "N/A")
logger.info("netflix解锁:" + str(ReCleaner.data.get('netflix', "N/A")))
return ReCleaner.data.get('netflix', "N/A")
except Exception as e:
logger.error(e)
return "N/A"
Expand Down Expand Up @@ -249,24 +243,9 @@ class FakeColl:
def __init__(self):
self.info = {}

CHECK_URL = "https://tls.browserleaks.com/json"
coll = FakeColl()
# proxies = {'http': 'http://localhost:1112', 'https': 'http://localhost:1112'} # 记得设置代理
# fetch_netflix_old(coll, proxy=proxies) # 这个是request请求客户端,正常访问
# print(coll.info)
# sc = ssl.create_default_context()
# connector = aiohttp.TCPConnector(ssl=myssl())

# 下面注释的这一个,将一个自定义的sslcontext传入,成功检测
# async with aiohttp.ClientSession(connector=connector) as session:
# 下面用aiohttp进行请求在某些系统将抛出 Server Disconnected 异常。
async with aiohttp.ClientSession(connector=None) as session:
# 注释的这个请求是查看ja3_hash的,它是一种TLS指纹算法
async with session.get(CHECK_URL, proxy="http://127.0.0.1:1112") as resp:
print(await resp.text())

await fetch_netflix(coll, session, proxy="http://127.0.0.1:1112") # 记得设置代理
# 2023-09-08 19:39:19.021 | WARNING | __main__:fetch_netflix:88 - Netflix请求发生错误:Server disconnected
await fetch_netflix(coll, session, proxy="http://127.0.0.1:11112")
print(coll.info)
await asyncio.sleep(2)

Expand Down
Loading

0 comments on commit 2d68ca9

Please sign in to comment.