-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Media Proxy を実装 #5649
Media Proxy を実装 #5649
Conversation
👍 |
@@ -22,7 +23,11 @@ export class DriveFileRepository extends Repository<DriveFile> { | |||
} | |||
|
|||
public getPublicUrl(file: DriveFile, thumbnail = false): string | null { | |||
return thumbnail ? (file.thumbnailUrl || file.webpublicUrl || null) : (file.webpublicUrl || file.url); | |||
let url = thumbnail ? (file.thumbnailUrl || file.webpublicUrl || null) : (file.webpublicUrl || file.url); | |||
if (file.src !== null && file.userHost !== null && config.mediaProxy !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config.mediaProxy
がundefined
の時にtrue
になっちゃいそう
全ての演算子は!= null
でよさそう
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほど
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file.src
はローカルのURLからアップロードでも使用されそう
file.userHost
のチェックがあるから最終的には大丈夫かもしれないけどfile.uri
を検証した方がいいのかも
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そもそもこ関数、let使わずreturnを2回使う記法の方が好ましいと思います
return thumbnail ? (file.thumbnailUrl || file.webpublicUrl || null) : (file.webpublicUrl || file.url); | ||
let url = thumbnail ? (file.thumbnailUrl || file.webpublicUrl || null) : (file.webpublicUrl || file.url); | ||
if (file.src !== null && file.userHost !== null && config.mediaProxy !== null) { | ||
url = `${config.mediaProxy}/${thumbnail ? 'thumbnail' : ''}?url=${file.src}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
確認してないけどfile.src
URLエンコードが必要かも
設定があればリモート分はとりあえずメディアプロキシに振り分けるという実装だと |
外部のメディアプロキシサーバーを指定する方法ではなくて 特定のオプション有効時に これならインスタンスが認知してない未知のURLに対するアクセスが拒否できる。 インスタンス間でURLを共有する形にはならないけど |
1.misskey.local, 2.misskey.local, 3.misskey.local とあった場合にそれぞれでプロキシを行うって認識で大丈夫? |
Yes あまり「クライアントから見たURLを同じにする」を突き詰めると結局リモート直リンが最適解になっちゃう気がする。 1ユーザーが複数のインスタンスで同じリモート投稿を見るというのがあまりないパターンだから、インスタンスでキャッシュが別れていてもさほど不具合がない気がする。 |
リモート直リンだと結構遅いサーバーがある(キャッシュをオフにしたら結構違いが出る)のと、サムネイルの生成が行われないのでモバイル等の従量課金制とか格安SIMとかのネットワークだと直ぐに容量を使い切りそう Misskey側にリモートファイルのサムネイル(ビデオを含む)を生成するプログラムを組み込んでストレージに保存しないけどプロキシだけはするみたいなやつだと解決できそうな気がする |
たぶんm544がそんな実装 |
↑たぶんメディアプロキシと競合するわけでもないから近日入れる… |
なるほど |
統合すると メディアプロキシ設定ありでメディアなMINEだったらそっちに移譲(このメディアプロキシ機能) みたいなイメージ |
プロトコルや実装アプリの説明もなしにいきなり 複数の実装を切り替え出来るように増やしていくよりは ioはメディアサーバーから返るサムネイルにwebp変換される機能等があり ioが公式で公式はバニラで運用する前提があるのかどうかはわからないです。 |
ioのメディア関連は出力部分に外部プログラムを経由させているだけでMisskey自体は公式のDockerイメージを利用してます。 forkして利用すると公式リポジトリの追従にラグが出るというのは置いといて、そもそも意外とMisskey自体複数インスタンスを運用している管理者が多いような気がするので必要と感じPRだしました。 もうmergeされてますが、必要ないと考えるならrevertして頂いて大丈夫です。 ただ、画像については外部プログラムを利用しないにしても、 https://images.weserv.nl/ を使うような実装があったほうが良いと思います。 |
別に入れちゃったならいいかなというレベルです |
今見たら
と思いました |
クライアントが直接見るURLなので |
あくまでもURLなのでサンプルは パスに
とかがいいかなと |
* Media Proxy を実装 * サンプルを追加 * https://github.com/syuilo/misskey/pull/5649#discussion_r359967471 の修正 * https://github.com/syuilo/misskey/pull/5649#discussion_r359967966 の修正 * https://github.com/syuilo/misskey/pull/5649#discussion_r359968219 の修正 * 期限切れ/未保存リモートファイルのローカルプロキシ * 設定 * 説明 * comment out * fix Co-authored-by: 和風ドレッシング <37681609+CookieRamen@users.noreply.github.com>
同じ画像を何個ものインスタンスでストレージに保存するのは非効率なので、以下のメディアプロキシを使える機能を実装しました。
https://github.com/riku6460/media-proxy