Beispiel #1
0
    def attempt_windows_vpn(self):
        """Attempt to connect to Windows VPN.

        * Arguments sent to powershell MUST BE STRINGS
        * Each argument cannot be the empty string or null or PS will think
          there's no param there!!!
        * Last 3 ps params are bools converted to ints (0/1) converted to
          strings. It's easy to force convert '0' and '1' to ints on
          powershell side.
        * Setting execution policy to unrestricted is necessary so that we
          can access VPN functions
        * Email CANNOT have spaces, but password can.
        """
        # 32bit powershell path :
        # 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe'
        # Opinionated view that 32bit is not necessary
        powershell_path = \
            'C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe'

        for i in range(len(self.vpn_options)):
            # Convert to string
            self.vpn_options[i] = str(self.vpn_options[i])

        return subprocess.call([
            powershell_path, '-ExecutionPolicy', 'Unrestricted',
            pyinstaller_path('merlink\\scripts\\connect_windows.ps1'),
            *self.vpn_data, *self.vpn_options
        ])
Beispiel #2
0
 def login_window_setup(self):
     """Set options for the login window self.app."""
     self.app.setModal(True)  # Make the login window prevent program usage
     self.app.meraki_img = QLabel()
     self.app.meraki_img.setOpenExternalLinks(True)
     pixmap = QPixmap(pyinstaller_path('media/cloud_miles.png'))
     self.app.meraki_img.setPixmap(pixmap)
     # Background for program should be #Meraki green = #78be20
     self.app.setStyleSheet("background-color:#eee")
     self.app.setWindowTitle('MerLink - Login Window')
Beispiel #3
0
 def set_vpn_failure(self):
     """Tell user that VPN connection was unsuccessful.
     Show an icon of Miles with a red interdictory circle and let
     the user know the connection failed.
     """
     self.tray_icon.setIcon(QIcon(pyinstaller_path(
         'media/unmiles.ico')))
     # Provide system VPN settings if the user wants more info
     self.tray_icon.messageClicked.connect(open_vpnsettings)
     # Show the user this message so they know where the program went
     self.tray_icon.showMessage("Merlink", "Connection failure!",
                                QSystemTrayIcon.Information, 1500)
Beispiel #4
0
    def __init__(self, app, merlink_gui):
        """Init QSystemTrayIcon and set the Window and Tray Icons."""
        self.app = app
        self.app.setWindowIcon(QIcon(pyinstaller_path('media/miles.ico')))
        self.tray_icon = QSystemTrayIcon(app)
        self.tray_icon.setIcon(QIcon(pyinstaller_path('media/miles.ico')))
        connection_status = 'VPN disconnected'
        self.tray_icon.setToolTip("Merlink - " + connection_status)

        connect_action = QAction("Connect to ...", app)
        # These 3 lines are to make "Connect to ..." bold
        font = QFont()
        font.setBold(True)
        connect_action.setFont(font)

        disconnect_action = QAction("Disconnect", app)
        show_action = QAction("Show", app)
        quit_action = QAction("Exit", app)
        hide_action = QAction("Hide", app)
        # Allow this if we're not connected
        connect_action.triggered.connect(merlink_gui.setup_vpn)
        disconnect_action.triggered.connect(app.disconnect)
        show_action.triggered.connect(app.show)
        hide_action.triggered.connect(app.hide)
        quit_action.triggered.connect(sys.exit)

        tray_menu = QMenu()
        tray_menu.addAction(connect_action)
        tray_menu.addAction(disconnect_action)
        tray_menu.addSeparator()
        tray_menu.addAction(show_action)
        tray_menu.addAction(hide_action)
        tray_menu.addAction(quit_action)
        self.tray_icon.setContextMenu(tray_menu)
        self.tray_icon.show()

        # If systray icon is clicked
        # If they click on the connected message, show them the VPN connection
        self.tray_icon.activated.connect(self.icon_activated)
Beispiel #5
0
 def set_vpn_success(self):
     """Tell user that VPN connection was successful.
     NOTE: There's no such thing as "minimize to system tray".
     What we're doing is hiding the window and
     then adding an icon to the system tray
     This function will set the icon to Miles with 3D glasses and
     show a message that the connection was successful.
     """
     self.tray_icon.setIcon(
         QIcon(pyinstaller_path('media/connected_miles.ico')))
     # Provide system VPN settings if the user wants more info
     self.tray_icon.messageClicked.connect(open_vpnsettings)
     # Show the user this message so they know where the program went
     self.tray_icon.showMessage("Merlink", "Connection success!",
                                QSystemTrayIcon.Information, 1500)
Beispiel #6
0
    def attempt_linux_vpn(self):
        """Attempt to connect on linux.

        * FPM executes `chmod a+x` on the merlink connect script post-install.
        * sudo required to create a connection with nmcli
        * pkexec is built into latest Fedora, Debian, Ubuntu.
        * 'pkexec <cmd>' correctly asks in GUI on Debian, Ubuntu but in
          terminal on Fedora
        * pkexec is PolicyKit, which is the preferred means of asking for
          permission on LSB
        * *self.vpn_data not possible due to the way the shell interprets it.
        """
        vpn_name, address, psk, username, password = self.vpn_data
        vpn_cmd = 'pkexec ' + pyinstaller_path(
            'merlink/vpn/connect_linux.sh')\
            + ' ' + vpn_name + ' ' + address + ' ' + psk + ' ' + username \
            + ' ' + password
        print("Command being run: ", vpn_cmd)
        return subprocess.Popen([vpn_cmd], shell=True)