diff --git a/.github/labeler.yml b/.github/labeler.yml index 11d08ebc..5589330c 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -18,9 +18,6 @@ ats: - any: - "backend/ats/**" - "!backend/ats/spec/**" -multicaster: - - any: - - "backend/multicaster/**" site: - any: - "frontend/site/**" diff --git a/.github/workflows/code-test.yml b/.github/workflows/code-test.yml index 4798c0f2..b75ac6cc 100644 --- a/.github/workflows/code-test.yml +++ b/.github/workflows/code-test.yml @@ -112,23 +112,6 @@ jobs: run: |- make test - backend-multicaster: - defaults: - run: - working-directory: ./backend/multicaster - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version-file: ./backend/multicaster/.python-version - cache: pip - cache-dependency-path: ./backend/multicaster/requirements-dev.txt - - run: pip install -r requirements-dev.txt - - name: Type check - run: mypy . - backend-positioning: defaults: run: diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 763c36da..d1764616 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -43,25 +43,4 @@ jobs: - uses: EndBug/add-and-commit@v9 with: message: format by black - default_author: github_actions - - black-multicaster: - runs-on: ubuntu-latest - defaults: - run: - working-directory: "backend/multicaster" - steps: - - name: checkout - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version-file: ./backend/multicaster/.python-version - cache: pip - cache-dependency-path: ./backend/multicaster/requirements-dev.txt - - run: pip install -r requirements-dev.txt - - run: black . - - uses: EndBug/add-and-commit@v9 - with: - author_name: format BOT - author_email: bot@example.com - message: format by black + default_author: github_actions \ No newline at end of file diff --git a/backend/multicaster/.gitignore b/backend/multicaster/.gitignore deleted file mode 100644 index e72a96da..00000000 --- a/backend/multicaster/.gitignore +++ /dev/null @@ -1,166 +0,0 @@ -# Created by https://www.toptal.com/developers/gitignore/api/python -# Edit at https://www.toptal.com/developers/gitignore?templates=python - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - -# End of https://www.toptal.com/developers/gitignore/api/python diff --git a/backend/multicaster/.python-version b/backend/multicaster/.python-version deleted file mode 100644 index afad8186..00000000 --- a/backend/multicaster/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.11.0 diff --git a/backend/multicaster/Dockerfile b/backend/multicaster/Dockerfile deleted file mode 100644 index c1bc1d2c..00000000 --- a/backend/multicaster/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM python:3.11.0-buster - -WORKDIR /app -COPY requirements.txt /app/ -RUN pip install -r requirements.txt - -COPY ./one_to_multiple_cast_skyway.py /app/ - -CMD ["python3", "/app/one_to_multiple_cast_skyway.py"] diff --git a/backend/multicaster/mypy.ini b/backend/multicaster/mypy.ini deleted file mode 100644 index 45d8df0d..00000000 --- a/backend/multicaster/mypy.ini +++ /dev/null @@ -1,9 +0,0 @@ -[mypy] -strict = True -disallow_any_expr = True -disallow_any_unimported = True -disallow_any_explicit = True -disallow_incomplete_defs = True -warn_unreachable = True -warn_incomplete_stub = True -pretty = True diff --git a/backend/multicaster/one_to_multiple_cast_skyway.py b/backend/multicaster/one_to_multiple_cast_skyway.py deleted file mode 100644 index 74fb635e..00000000 --- a/backend/multicaster/one_to_multiple_cast_skyway.py +++ /dev/null @@ -1,236 +0,0 @@ -# WebRTCで1->複数に配信する -# 1人がsender - -import asyncio -from websockets.server import serve -from websockets.exceptions import ConnectionClosedError -from websockets.server import WebSocketServerProtocol -import json -import ssl -import os -from typing import Literal, Optional, TypedDict, Union, cast - -ADDRESS = "0.0.0.0" -PORT = 8081 -MAX_CUMULATIVE_ACTIVATED_CONNECT_NUM = 980 -# CERT = "C://Users/asika/OneDrive/ドキュメント/webRTC/vscode_live_server.cert.pem" -# KEY = "C://Users/asika/OneDrive/ドキュメント/webRTC/vscode_live_server.key.pem" -SENDER_TOKEN = os.environ.get("SENDER_TOKEN") # ["127.0.0.1"] -print(SENDER_TOKEN) - - -connections: set[WebSocketServerProtocol] = set() - - -class ConnectSenderMessage(TypedDict): - msg_type: Literal["connect_sender"] - room_id: str - peer_id: str - skyway_room_id: str - sender_token: str - - -class ConnectReceiverMessage(TypedDict): - msg_type: Literal["connect_receiver"] - room_id: str - - -class ExitRoomMessage(TypedDict): - msg_type: Literal["exit_room"] - room_id: str - - -class RequestReconnectSenderMessage(TypedDict): - msg_type: Literal["request_reconnect_sender"] - room_id: str - - -class ConnectReceiverReplyMessage(TypedDict): - msg_type: Literal["connect_receiver"] - room_id: str - peer_id: str - skyway_room_id: str - - -Message = Union[ - ConnectSenderMessage, - ConnectReceiverMessage, - ExitRoomMessage, - RequestReconnectSenderMessage, - ConnectReceiverReplyMessage, -] - - -class Room(TypedDict): - sender_socket: Optional[WebSocketServerProtocol] - peer_id: Optional[str] - skyway_room_id: Optional[str] - connections: set[WebSocketServerProtocol] - cumulative_activated_connect_num: int - - -RemoteAddress = Optional[tuple[str, int]] -"""ref: https://github.com/aaugustin/websockets/blob/10.3/src/websockets/legacy/protocol.py#L392-L399 -""" - -rooms: dict[str, Room] = {} -# keyが部屋id, valueが{"sender_socket", "peer_id", "connections"} -print("a") -# 後で通信している個人が本物か見分けるのもじっそうしないといけないきがする - - -# offerer == receiver -# answerer == sender - -# idで判別して複数動画同時配信したい -lock = asyncio.Lock() - - -async def handler(websocket: WebSocketServerProtocol, path: str) -> None: - global connections, rooms, lock - remote_address = cast(RemoteAddress, websocket.remote_address) - print(remote_address) - async with lock: - connections.add(websocket) - - try: - async for raw_message in websocket: # 受信 - message: Message = json.loads(raw_message) - # msg_type, room_idで構成 - # connect_senderの時のみ+peer_id - promises = [] - room_id = message["room_id"] - - if room_id not in rooms: - room = Room( - sender_socket=None, - peer_id=None, - skyway_room_id=None, - connections={websocket}, - cumulative_activated_connect_num=0, - # ルームの累積接続数が1000行くと通信が弾かれるのでその前にルームを切り替え - ) - async with lock: - rooms[room_id] = room - else: - room = rooms[room_id] - if websocket not in room["connections"]: - async with lock: - room["connections"].add(websocket) - # 現在の通信のwebsocketが入ったroom_idのroomが存在することを保証 - - if message["msg_type"] == "connect_sender": - if SENDER_TOKEN is None or SENDER_TOKEN == message["sender_token"]: - async with lock: # if room["sender_socket"] is None: - print("sender_connect") - room["sender_socket"] = websocket - room["skyway_room_id"] = message["skyway_room_id"] - room["cumulative_activated_connect_num"] = 0 - # senderは上書き - room["peer_id"] = message["peer_id"] - if room["skyway_room_id"] is None or room["peer_id"] is None: - continue - for connection in room["connections"]: - if connection is websocket: - continue - print("send") - promise = connection.send( - json.dumps( - ConnectReceiverReplyMessage( - msg_type="connect_receiver", - room_id=room_id, - skyway_room_id=room["skyway_room_id"], - peer_id=room["peer_id"], - ) - ) - ) - room["cumulative_activated_connect_num"] += 1 - promises.append(promise) - elif message["msg_type"] == "connect_receiver": - print("connect_receiver") - if room["sender_socket"] is not None: - if room["skyway_room_id"] is None or room["peer_id"] is None: - continue - print("send") - if ( - room["cumulative_activated_connect_num"] - < MAX_CUMULATIVE_ACTIVATED_CONNECT_NUM - ): - promise = websocket.send( - json.dumps( - ConnectReceiverReplyMessage( - msg_type="connect_receiver", - room_id=room_id, - skyway_room_id=room["skyway_room_id"], - peer_id=room["peer_id"], - ) - ) - ) - - async with lock: - room["cumulative_activated_connect_num"] += 1 - promises.append(promise) - else: - # ルームの累積接続数が溢れそうだったら新しい部屋をsenderに作ってもらう - promise = room["sender_socket"].send( - json.dumps( - RequestReconnectSenderMessage( - msg_type="request_reconnect_sender", room_id=room_id - ) - ) - ) - promises.append(promise) - async with lock: - room["cumulative_activated_connect_num"] = 0 - elif message["msg_type"] == "exit_room": - if websocket in room["connections"]: - async with lock: - room["connections"].remove(websocket) - if room["sender_socket"] is websocket: - async with lock: - room["sender_socket"] = None - room["peer_id"] = None - room["skyway_room_id"] = None - room["cumulative_activated_connect_num"] = 0 - print("{}: {}".format(path, message)) - for p in promises: - try: - await p - except: - pass - except ConnectionClosedError: - pass - - # 接続が切れたらその接続を削除 - for room_id, room in rooms.items(): - print(room) - async with lock: - room["connections"].discard(websocket) - if room["sender_socket"] is websocket: - async with lock: - room["sender_socket"] = None - room["peer_id"] = None - - async with lock: - rooms = { - room_id: room - for room_id, room in rooms.items() - if len(room["connections"]) != 0 - } - # ルームに人がいなくなったら削除 - - async with lock: - connections.remove(websocket) - - -# ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) -# ssl_context.load_cert_chain(CERT, keyfile=KEY) - -# サーバー立ち上げ -async def main() -> None: - async with serve(handler, ADDRESS, PORT): # , ssl=ssl_context) - await asyncio.Future() # run forever - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/backend/multicaster/requirements-dev.txt b/backend/multicaster/requirements-dev.txt deleted file mode 100644 index ab49d6a6..00000000 --- a/backend/multicaster/requirements-dev.txt +++ /dev/null @@ -1,3 +0,0 @@ --r requirements.txt -black==22.10.0 -mypy==0.982 \ No newline at end of file diff --git a/backend/multicaster/requirements.txt b/backend/multicaster/requirements.txt deleted file mode 100644 index 707d0d3d..00000000 --- a/backend/multicaster/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -websockets==10.4 \ No newline at end of file diff --git a/docker-bake.hcl b/docker-bake.hcl index c1e115a8..b366c1d3 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -4,7 +4,6 @@ group "default" { "external", "internal", "json2grpc", - "multicaster", "positioning", "camera_sender", "frontend", @@ -52,13 +51,6 @@ target "json2grpc" { ] } -target "multicaster" { - context = "./backend/multicaster" - tags = [ - GET_TAG("frontend-python") - ] -} - target "positioning" { context = "./backend/positioning" tags = [ diff --git a/docs/endpoints.md b/docs/endpoints.md index 3a1e18d1..b2e71343 100644 --- a/docs/endpoints.md +++ b/docs/endpoints.md @@ -10,8 +10,6 @@ `./backend/external`が動いています。クライアントはここにむけてwebsocketを張ってください。`/ws`にwebsocketのエンドポイントがあります。 - "chofufes2022.ueckoken.club" `./frontend/site`が動いています。ここにメインのページがデプロイされます。 -- "webrtc.chofufes2022.ueckoken.club" -`./backend/multicaster/one_to_multiple_cast_skyway.py`が動いています。webrtcのピアリングを行います。 - "auth.chofufes2022.ueckoken.club" 認証画面です。認証が必要なページに入るには先にここを通ってください。 diff --git a/manifests/imageautomation/frontend-python/imagepolicy.yaml b/manifests/imageautomation/frontend-python/imagepolicy.yaml deleted file mode 100644 index 42dcf95c..00000000 --- a/manifests/imageautomation/frontend-python/imagepolicy.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: image.toolkit.fluxcd.io/v1beta1 -kind: ImagePolicy -metadata: - name: frontend-python - namespace: plarail2021 -spec: - imageRepositoryRef: - name: frontend-python - filterTags: - pattern: '[a-f0-9]+-(?P[0-9]+)' - extract: '$ts' - policy: - numerical: - order: asc diff --git a/manifests/imageautomation/frontend-python/kustomization.yaml b/manifests/imageautomation/frontend-python/kustomization.yaml deleted file mode 100644 index 473a6b48..00000000 --- a/manifests/imageautomation/frontend-python/kustomization.yaml +++ /dev/null @@ -1,3 +0,0 @@ -resources: - - ./repository.yaml - - ./imagepolicy.yaml diff --git a/manifests/imageautomation/frontend-python/repository.yaml b/manifests/imageautomation/frontend-python/repository.yaml deleted file mode 100644 index 26d6476b..00000000 --- a/manifests/imageautomation/frontend-python/repository.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: image.toolkit.fluxcd.io/v1beta1 -kind: ImageRepository -metadata: - name: frontend-python - namespace: plarail2021 -spec: - image: ghcr.io/ueckoken/plarail2022-frontend-python - interval: 1m0s diff --git a/manifests/imageautomation/kustomization.yaml b/manifests/imageautomation/kustomization.yaml index 5cfb3046..fc563e53 100644 --- a/manifests/imageautomation/kustomization.yaml +++ b/manifests/imageautomation/kustomization.yaml @@ -1,7 +1,6 @@ resources: - ./external - ./frontend - - ./frontend-python - ./internal - ./json2grpc - ./automation.yaml diff --git a/manifests/manifests/kustomization.yaml b/manifests/manifests/kustomization.yaml index d256ef47..aadb89f3 100644 --- a/manifests/manifests/kustomization.yaml +++ b/manifests/manifests/kustomization.yaml @@ -1,6 +1,5 @@ resources: - ./frontend - - ./python-webrtc-server - ./external # internalは学内サーバで管理 # - ./internal/ diff --git a/manifests/manifests/python-webrtc-server/deployment.yaml b/manifests/manifests/python-webrtc-server/deployment.yaml deleted file mode 100644 index 08db86e1..00000000 --- a/manifests/manifests/python-webrtc-server/deployment.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: soft-python - namespace: plarail2021 -spec: - selector: - matchLabels: - app: soft-python - template: - metadata: - labels: - app: soft-python - spec: - containers: - - name: soft-python - image: ghcr.io/ueckoken/plarail2022-frontend-python:b1e097a-1668799336 # {"$imagepolicy": "plarail2021:frontend-python"} - imagePullPolicy: Always - ports: - - containerPort: 80 - envFrom: - - secretRef: - name: videocast diff --git a/manifests/manifests/python-webrtc-server/ingressroute.yaml b/manifests/manifests/python-webrtc-server/ingressroute.yaml deleted file mode 100644 index 897f2659..00000000 --- a/manifests/manifests/python-webrtc-server/ingressroute.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: traefik.containo.us/v1alpha1 -kind: IngressRoute -metadata: - name: webrtc - namespace: plarail2021 -spec: - routes: - - kind: Rule - match: Host(`webrtc.chofufes2022.ueckoken.club`) - services: - - name: soft-python - port: 80 - tls: - secretName: cloudflare-cert diff --git a/manifests/manifests/python-webrtc-server/kustomization.yaml b/manifests/manifests/python-webrtc-server/kustomization.yaml deleted file mode 100644 index dcc8644b..00000000 --- a/manifests/manifests/python-webrtc-server/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -resources: - - ./deployment.yaml - - ./service.yaml - - ./ingressroute.yaml diff --git a/manifests/manifests/python-webrtc-server/service.yaml b/manifests/manifests/python-webrtc-server/service.yaml deleted file mode 100644 index adfaca8c..00000000 --- a/manifests/manifests/python-webrtc-server/service.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: soft-python - namespace: plarail2021 -spec: - type: NodePort - selector: - app: soft-python - ports: - - port: 80 - protocol: TCP - targetPort: 8081