This repository has been archived by the owner on Jan 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 343
/
iphone.rb
49 lines (40 loc) · 1.43 KB
/
iphone.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'resolv'
#####
# This is the connection to the iPhone
#####
class SiriProxy::Connection::Iphone < SiriProxy::Connection
def initialize upstream_dns
super()
self.name = "iPhone"
@upstream_dns = upstream_dns
end
def post_init
super
start_tls(:cert_chain_file => File.expand_path("~/.siriproxy/server.passless.crt"),
:private_key_file => File.expand_path("~/.siriproxy/server.passless.key"),
:verify_peer => false)
end
# Resolves guzzoni.apple.com using the Google DNS servers. This allows the
# machine running siriproxy to use the DNS server returning fake records for
# guzzoni.apple.com.
def resolve_guzzoni
addresses = Resolv::DNS.open(nameserver: @upstream_dns) do |dns|
res = dns.getresources('guzzoni.apple.com', Resolv::DNS::Resource::IN::A)
res.map { |r| r.address }
end
addresses.map do |address|
address.address.unpack('C*').join('.')
end.sample
end
def ssl_handshake_completed
super
self.other_connection = EventMachine.connect(resolve_guzzoni, 443, SiriProxy::Connection::Guzzoni)
self.plugin_manager.guzzoni_conn = self.other_connection
other_connection.other_connection = self #hehe
other_connection.plugin_manager = plugin_manager
end
def received_object(object)
return plugin_manager.process_filters(object, :from_iphone)
#plugin_manager.object_from_client(object, self)
end
end