def generateSecureVPN():
# Can't use a template as SecureVPN use multiple everything.
# Copy the file to the target directory and strip it of user keys
existing_profiles = glob.glob(getUserDataPath("providers/SecureVPN" + "/*.ovpn"))
for connection in existing_profiles:
xbmcvfs.delete(connection)
# Get the list from the provider data directory
profiles = getProfileList("SecureVPN")
destination_path = getProviderPath("SecureVPN" + "/")
for profile in profiles:
shortname = profile[profile.index("SecureVPN")+10:]
shortname = shortname[:shortname.index(".")]
proto = "(UDP)"
filename = shortname + " " + proto + ".ovpn"
profile_file = open(profile, 'r')
output_file = open(destination_path + filename, 'w')
profile_contents = profile_file.readlines()
profile_file.close()
output = ""
i = 0
write = True;
for line in profile_contents:
line = line.strip(' \t\n\r')
if not (line == "" or line.startswith("#")) :
if "<key>" in line or "<cert>" in line: write = False
if "</key>" in line:
write = True
line = "key #USERKEY"
if "</cert>" in line:
write = True
line = "cert #USERCERT"
if write : output_file.write(line + "\n")
i = i + 1
output_file.close()
generateMetaData("SecureVPN", MINIMUM_LEVEL)
评论列表
文章目录