Skip to content

Instantly share code, notes, and snippets.

@ninoseki
Created February 14, 2020 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninoseki/5f882ee7ec12cc4818a99f4641f2d96b to your computer and use it in GitHub Desktop.
Save ninoseki/5f882ee7ec12cc4818a99f4641f2d96b to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require "faye/websocket"
require "eventmachine"
require "json"
EM.run {
ws = Faye::WebSocket::Client.new("ws://127.0.0.1:4000", nil, ping: 10)
ws.on :message do |event|
message = JSON.parse(event.data)
all_domains = message.dig("data", "leaf_cert", "all_domains")
not_before = message.dig("data", "leaf_cert", "not_before")
if all_domains && not_before
puts({ all_domains: all_domains, not_before: Time.at(not_before) }.to_json)
end
end
ws.on :close do |event|
p [:close, event.code, event.reason]
ws = nil
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment