mirror of
https://github.com/Sneed-Group/pypush-plus-plus
synced 2024-12-24 03:42:43 -06:00
hacks around design flaw in my APNs stuff; can now do multiple lookups
This commit is contained in:
parent
98c861c625
commit
cc54c4b79a
2 changed files with 32 additions and 32 deletions
4
apns.py
4
apns.py
|
@ -33,6 +33,10 @@ def _connect(private_key: str, cert: str) -> tlslite.TLSConnection:
|
||||||
class APNSConnection:
|
class APNSConnection:
|
||||||
incoming_queue = []
|
incoming_queue = []
|
||||||
|
|
||||||
|
# Sink everything in the queue
|
||||||
|
def sink(self):
|
||||||
|
self.incoming_queue = []
|
||||||
|
|
||||||
def _queue_filler(self):
|
def _queue_filler(self):
|
||||||
while True and not self.sock.closed:
|
while True and not self.sock.closed:
|
||||||
# print(self.sock.closed)
|
# print(self.sock.closed)
|
||||||
|
|
48
demo.py
48
demo.py
|
@ -134,42 +134,38 @@ if not 'ids_cert' in CONFIG:
|
||||||
refresh_ids_cert()
|
refresh_ids_cert()
|
||||||
print("Got IDS certificate!")
|
print("Got IDS certificate!")
|
||||||
|
|
||||||
# This is the actual lookup!
|
|
||||||
print("Looking up user...")
|
|
||||||
ids_keypair = ids.KeyPair(CONFIG['key'], CONFIG['ids_cert'])
|
ids_keypair = ids.KeyPair(CONFIG['key'], CONFIG['ids_cert'])
|
||||||
resp = ids.lookup(conn, CONFIG['username'], ids_keypair, 'com.apple.madrid', ['mailto:user_test2@icloud.com'])
|
|
||||||
print("Got response!")
|
|
||||||
#print(resp)
|
|
||||||
|
|
||||||
r = list(resp['results'].values())[0]
|
def lookup(topic:str, users: list[str]):
|
||||||
i = r['identities']
|
print(f"Looking up users {users} for topic {topic}...")
|
||||||
print(f"IDENTITIES: {len(i)}")
|
resp = ids.lookup(conn, CONFIG['username'], ids_keypair, topic, users)
|
||||||
for iden in i:
|
|
||||||
|
#r = list(resp['results'].values())[0]
|
||||||
|
for k, v in resp['results'].items():
|
||||||
|
print(f"Result for user {k} topic {topic}:")
|
||||||
|
i = v['identities']
|
||||||
|
print(f"IDENTITIES: {len(i)}")
|
||||||
|
for iden in i:
|
||||||
print("IDENTITY", end=" ")
|
print("IDENTITY", end=" ")
|
||||||
#print("========")
|
|
||||||
print(f"Push Token: {b64encode(iden['push-token']).decode()}", end=" ")
|
print(f"Push Token: {b64encode(iden['push-token']).decode()}", end=" ")
|
||||||
if 'client-data' in iden:
|
if 'client-data' in iden:
|
||||||
print(f"Client Data: {len(iden['client-data'])}")
|
print(f"Client Data: {len(iden['client-data'])}")
|
||||||
# cl = iden['client-data']
|
|
||||||
# for key, value in cl.items():
|
|
||||||
# print(f"{key}: {value}")
|
|
||||||
else:
|
else:
|
||||||
print("No client data")
|
print("No client data")
|
||||||
#print("\n\n\n")
|
|
||||||
#print("\n\n\n")
|
|
||||||
#print(iden)
|
|
||||||
#
|
|
||||||
# for key, value in iden.items():
|
|
||||||
# print(f"{key}: {value}")
|
|
||||||
#for key, value in r.items():
|
|
||||||
# print(f"{key}: {value}")
|
|
||||||
#print(r)
|
|
||||||
#print(len(str(resp)))
|
|
||||||
|
|
||||||
#print("\n\n\n\n")
|
# Hack to make sure that the requests and responses match up
|
||||||
|
# This filter MUST contain all the topics you are looking up
|
||||||
|
conn.filter(['com.apple.madrid', 'com.apple.private.alloy.facetime.multi'])
|
||||||
|
import time
|
||||||
|
time.sleep(5) # Let the server send us any messages it was holding
|
||||||
|
conn.sink() # Dump the messages
|
||||||
|
|
||||||
#for key, value in resp['results']['mailto:user_test2@icloud.com'].items():
|
lookup("com.apple.madrid", ["mailto:jjtech@jjtech.dev"])
|
||||||
# print(f"{key}: {value}")
|
lookup("com.apple.private.alloy.facetime.multi", ["mailto:jjtech@jjtech.dev"])
|
||||||
|
|
||||||
|
lookup("com.apple.private.alloy.facetime.multi", ["mailto:user_test2@icloud.com"])
|
||||||
|
lookup("com.apple.madrid", ["mailto:user_test2@icloud.com"])
|
||||||
|
|
||||||
# Save config
|
# Save config
|
||||||
with open("config.json", "w") as f:
|
with open("config.json", "w") as f:
|
||||||
|
|
Loading…
Reference in a new issue