LoginSignup
2
1

More than 3 years have passed since last update.

Mastodon用irbコードメモ

Last updated at Posted at 2019-10-11

自分用メモです。

tootctlを介さずにいろいろします。

危険です。

カッコ内は動作を確認したバージョンです。

irbの起動のしかた

$ su - mastodon
$ cd ~/live
$ RAILS_ENV=production bundle exec rails console
irb(main):001:0>

domain系

認知しているサーバに接続できるか調べる [v3.0.0]

サーバにHEADを投げてみて、何らかの異常があれば表示する

Account.select(:domain).where.not(domain: nil).where(suspended_at: nil).distinct.order(:domain).each do |record|
    code = 0
    begin
        code = Request.new(:head, 'https://' + record.domain).perform(&:code)
    rescue => e
        printf("%s\n", e)
    end; 0
    unless[0, 200].include?(code)
        printf("Server Returns HTTP %s on %s\n", code, record.domain)
    end; 0
end; 0
エラー 説明
Connect timed out after 5 seconds 一定時間内に接続が確立しなかった
failed to connect: Connection refused サーバへの接続が拒否された
failed to connect: No address ドメインに対するA/AAAAレコードがない
failed to connect: No route to host 宛先ホストへの送信経路が存在しない。あるいはファイアウォールで弾かれた
Server Returns HTTP XXX 200以外のHTTPステータスコードが返された
Mastodon::HostValidationError サーバがプライベートIPアドレスを使っている。このへん参照
Read timed out after 10 seconds 一定時間内に応答が返ってこなかった
certificate verify failed (self signed certificate) 自己署名証明書が使われている
certificate verify failed (unable to get local issuer certificate) クライアント証明書のCA情報がサーバ側で確認できなかった
certificate verify failed (unspecified certificate verification error) 証明書の検証時にエラーが発生した
state=SSLv3/TLS write client hello: tlsv1 alert internal error 問い合わせ側の証明書に問題がある?
SYSCALL returned=5 errno=0 state=SSLv3/TLS write client hello 問い合わせ側のRubyに問題がある?

HTTP 4xxが返ってくるやつ、Aレコードが無いやつは閉じた可能性が高いと思われる

Wikipedia - List of HTTP status codes

あとがき

  • 使用は自己責任でお願いします。何か不具合が起こっても責任取れません。
  • こうしたほうがいいよ的なアドバイス、誤記や記載漏れ、動作の違い等の指摘を頂けると大変助かります。
  • 連絡先: Mastodon1, Mastodon2

以上

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1