Class: SiriProxy::Connection::Iphone
- Inherits:
-
SiriProxy::Connection
- Object
- EventMachine::Connection
- SiriProxy::Connection
- SiriProxy::Connection::Iphone
- Defined in:
- lib/siriproxy/connection/iphone.rb
Overview
This is the connection to the iPhone
Instance Attribute Summary
Attributes inherited from SiriProxy::Connection
#consumed_ace, #input_buffer, #last_ref_id, #name, #other_connection, #output_buffer, #plugin_manager, #processed_headers, #ssled, #unzip_stream, #unzipped_input, #unzipped_output, #zip_stream
Instance Method Summary collapse
-
#initialize(upstream_dns) ⇒ Iphone
constructor
A new instance of Iphone.
- #post_init ⇒ Object
- #received_object(object) ⇒ Object
-
#resolve_guzzoni ⇒ Object
Resolves guzzoni.apple.com using the Google DNS servers.
- #ssl_handshake_completed ⇒ Object
Methods inherited from SiriProxy::Connection
#flush_output_buffer, #flush_unzipped_output, #has_next_object?, #inject_object_to_output_stream, #parse_object, #prep_received_object, #process_compressed_data, #read_next_object_from_unzipped, #receive_binary_data, #receive_line
Constructor Details
#initialize(upstream_dns) ⇒ Iphone
Returns a new instance of Iphone.
7 8 9 10 11 |
# File 'lib/siriproxy/connection/iphone.rb', line 7 def initialize upstream_dns super() self.name = "iPhone" @upstream_dns = upstream_dns end |
Instance Method Details
#post_init ⇒ Object
13 14 15 16 17 18 |
# File 'lib/siriproxy/connection/iphone.rb', line 13 def post_init super start_tls(:cert_chain_file => File.("~/.siriproxy/server.passless.crt"), :private_key_file => File.("~/.siriproxy/server.passless.key"), :verify_peer => false) end |
#received_object(object) ⇒ Object
44 45 46 47 48 |
# File 'lib/siriproxy/connection/iphone.rb', line 44 def received_object(object) return plugin_manager.process_filters(object, :from_iphone) #plugin_manager.object_from_client(object, self) end |
#resolve_guzzoni ⇒ Object
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.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/siriproxy/connection/iphone.rb', line 24 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 |
#ssl_handshake_completed ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/siriproxy/connection/iphone.rb', line 36 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 |