from analysis_ios_event.ios_script import allEvent

import struct
import socket
import random
import os
import datetime
import time
from jpype import *
appkey = '30b0a4c2a44633f1e233436b277eae31'
# 123c0cb882d3dbec4f7f66251a84d123
# 30b0a4c2a44633f1e233436b277eae31
current_path = os.path.dirname("../jiami/AESEncryptor.jar")

jvmPath = getDefaultJVMPath()

jars = [current_path + "/AESEncryptor.jar"]

jvm_cp = "-Djava.class.path={}".format(":".join(jars))

startJVM(jvmPath, jvm_cp)

JDClass = JClass("AESEncryptor")

lst = []
newList = ['959442093969', '957622214463', '940056993368', '278010757900', '633693870464']



# 遍历已有列表数据 发请求
for i in newList:
    ip = socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))
    # allEvent().installUpload(i,ip,appkey,JDClass)
    # time.sleep(1)
    allEvent().startupUpload(i, ip, appkey, JDClass)
    time.sleep(1)
    allEvent().eventUpload(i, ip, appkey, '2', JDClass)
    time.sleep(1)
    allEvent().pageUpload(i, ip, appkey, '1', JDClass)
    time.sleep(1)
    allEvent().exitUpload(i, ip, appkey, JDClass)


# for _ in range(1):
#     # 随机生成12为数组
#     i = ''.join(str(random.choice(range(10))) for _ in range(12))
#     # i = ''
#     # 随机生成ip
#     ip = socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))
#     # ip = '103.23.28.70'
#     allEvent().installUpload(i, ip, appkey, JDClass)
#     time.sleep(1)
#     allEvent().startupUpload(i, ip, appkey, JDClass)
#     time.sleep(1)
#     allEvent().eventUpload(i, ip, appkey, '0', JDClass)
#     time.sleep(1)
#     allEvent().pageUpload(i, ip, appkey, '0', JDClass)
#     time.sleep(1)
#     allEvent().exitUpload(i, ip, appkey, JDClass)
    allEvent().batchUpload(i, ip, appkey, JDClass)
#     lst.append(i)
#     print(lst)