get real ip from doc

This commit is contained in:
Luiz Costa 2024-06-03 12:35:16 +01:00
parent d2b3f4e691
commit 9ebe41fd66

View File

@ -35,8 +35,11 @@ def create_session(name, protocol):
acc_doc = frappe.get_doc('IT User Account', doc.get('link'))
username = acc_doc.username
password = acc_doc.get_password('password')
# Get IP
ip_doc = frappe.get_doc('IP Address', doc.get('main_ip'))
ip_address = ip_doc.ip_address
uri = urllib.parse.quote_plus(f"{protocol}://{username if username else ''}{':' + password if password else ''}@{doc.main_ip}{':' + str(PROTOCOL_PORT[protocol])}").lower()
uri = urllib.parse.quote_plus(f"{protocol}://{username if username else ''}{':' + password if password else ''}@{ip_address}{':' + str(PROTOCOL_PORT[protocol])}").lower()
if protocol == 'RDP':
uri = f"{uri}/?ignore-cert=true&disable-audio=true"
url = f'{guaca_config.guacamole_server}/?#/?token={token}&quickconnect={uri}'