mirror of
https://github.com/Sneed-Group/pypush-plus-plus
synced 2024-12-23 11:22:42 -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:
|
||||
incoming_queue = []
|
||||
|
||||
# Sink everything in the queue
|
||||
def sink(self):
|
||||
self.incoming_queue = []
|
||||
|
||||
def _queue_filler(self):
|
||||
while True and not self.sock.closed:
|
||||
# print(self.sock.closed)
|
||||
|
|
60
demo.py
60
demo.py
|
@ -134,42 +134,38 @@ if not 'ids_cert' in CONFIG:
|
|||
refresh_ids_cert()
|
||||
print("Got IDS certificate!")
|
||||
|
||||
# This is the actual lookup!
|
||||
print("Looking up user...")
|
||||
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]
|
||||
i = r['identities']
|
||||
print(f"IDENTITIES: {len(i)}")
|
||||
for iden in i:
|
||||
print("IDENTITY", end=" ")
|
||||
#print("========")
|
||||
print(f"Push Token: {b64encode(iden['push-token']).decode()}", end=" ")
|
||||
if 'client-data' in iden:
|
||||
print(f"Client Data: {len(iden['client-data'])}")
|
||||
# cl = iden['client-data']
|
||||
# for key, value in cl.items():
|
||||
# print(f"{key}: {value}")
|
||||
else:
|
||||
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)))
|
||||
def lookup(topic:str, users: list[str]):
|
||||
print(f"Looking up users {users} for topic {topic}...")
|
||||
resp = ids.lookup(conn, CONFIG['username'], ids_keypair, topic, users)
|
||||
|
||||
#print("\n\n\n\n")
|
||||
#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(f"Push Token: {b64encode(iden['push-token']).decode()}", end=" ")
|
||||
if 'client-data' in iden:
|
||||
print(f"Client Data: {len(iden['client-data'])}")
|
||||
|
||||
#for key, value in resp['results']['mailto:user_test2@icloud.com'].items():
|
||||
# print(f"{key}: {value}")
|
||||
else:
|
||||
print("No client data")
|
||||
|
||||
# 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
|
||||
|
||||
lookup("com.apple.madrid", ["mailto:jjtech@jjtech.dev"])
|
||||
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
|
||||
with open("config.json", "w") as f:
|
||||
|
|
Loading…
Reference in a new issue