little fixes in Class Import

This commit is contained in:
2024-08-23 14:37:19 +02:00
parent c87ba4493d
commit 9667bf0690
2 changed files with 21 additions and 12 deletions

View File

@ -181,16 +181,17 @@ class ImportTunnel:
if len(pathsplit1) > 17:
pathsplit = pathsplit1[len(pathsplit1) - 17:]
os.rename(filepath, os.environ['HOME'] + '/tester/' + str(pathsplit))
os.system('nmcli connection down ' + str(TunnelActiv.active()))
if self.a != '':
os.system('nmcli connection down ' + str(TunnelActiv.active()))
os.system('nmcli connection import type wireguard file ' + os.environ['HOME'] + '/tester/' +
str(pathsplit))
os.system('nmcli con mod ' + str(pathsplit[:-5]) + ' connection.autoconnect no')
else:
subprocess.call('cp ' + str(filepath) + ' ' + os.environ['HOME'] + '/tester/', shell=True)
os.system('nmcli connection down ' + str(TunnelActiv.active()))
if self.a != '':
os.system('nmcli connection down ' + str(TunnelActiv.active()))
os.system('nmcli connection import type wireguard file ' + str(filepath))
os.system('nmcli con mod ' + str(pathsplit1[:-5]) + ' connection.autoconnect no')
self.StrVar.set(value=' ')
self.StrVar.set('')
self.a = TunnelActiv.active()
self.l_box.insert(0, self.a)
self.l_box.update()
@ -201,11 +202,11 @@ class ImportTunnel:
wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
file = open(wg_read, 'r')
data = ConToDict.covert_to_dict(file)
self.add.set('Address: ' + data[0])
self.DNS.set(' DNS: ' + data[1])
self.enp.set('Endpoint: ' + data[2])
# Address Label
ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
file.close()
os.system('nmcli con mod ' + str(self.a) + ' connection.autoconnect no')
if "PrivateKey = " not in read:
Message()
except EOFError: