Esempio n. 1
0
 def get_ui(self, cfg, id = None):
     s = self._b.getstats()
     ui = self.app.inflate("openvpn:widget")
     ui.find("nclients").set("text", s["nclients"])
     ui.find("bytesin").set("text", str_fsize(float(s["bytesin"])))
     ui.find("bytesout").set("text", str_fsize(float(s["bytesout"])))
     return ui
Esempio n. 2
0
 def get_info(self, iface):
     ui = UI.Container( 
         UI.Formline(
             UI.HContainer(
                 UI.Image(file='/dl/network/%s.png'%('up' if iface.up else 'down')),
                 UI.Label(text=iface.name, bold=True)
             ),
             text='Interface',
         ),
         UI.Formline(
             UI.Label(text=self.get_ip(iface)),
             text='Address',
         ),
         UI.Formline(
             UI.Label(text='Up %s, down %s' % (
                 str_fsize(self.get_tx(iface)),
                 str_fsize(self.get_rx(iface)),
             )),
             text='Traffic',
         ),
     )
     return ui
Esempio n. 3
0
 def get_info(self, iface):
     ui = UI.Container( 
         UI.Formline(
             UI.HContainer(
                 UI.Image(file='/dl/network/%s.png'%('up' if iface.up else 'down')),
                 UI.Label(text=iface.name, bold=True)
             ),
             text='Interface',
         ),
         UI.Formline(
             UI.Label(text=self.get_ip(iface.name)),
             text='Address',
         ),
         UI.Formline(
             UI.Label(text='Up %s, down %s' % (
                 str_fsize(self.get_tx(iface)),
                 str_fsize(self.get_rx(iface)),
             )),
             text='Traffic',
         ),
     )
     return ui
Esempio n. 4
0
    def get_ui(self):
        ui = self.app.inflate('filesystems:main')

        t = ui.find('vdlist')

        for x in self._vdevs:
            t.append(
                UI.DTR(
                    UI.Iconfont(iconfont=x.icon), UI.Label(text=x.name),
                    UI.Label(text='Encrypted Disk' if x.fstype ==
                             'crypt' else 'Virtual Disk'),
                    UI.Label(text=str_fsize(x.size)),
                    UI.Label(text=x.mount if x.mount else 'Not Mounted'),
                    UI.HContainer(
                        UI.TipIcon(
                            iconfont='gen-key',
                            text='Encrypt Disk',
                            id=('ecvd/' + str(self._vdevs.index(x))),
                            warning=
                            'Are you sure you wish to encrypt virtual disk %s? This will erase ALL data on the disk, and is irreversible.'
                            % x.name) if x.fstype != 'crypt' else None,
                        UI.TipIcon(iconfont='gen-arrow-down-3'
                                   if x.mount else 'gen-arrow-up-3',
                                   text='Unmount' if x.mount else 'Mount',
                                   id=('umvd/' if x.mount else 'mvd/') +
                                   str(self._vdevs.index(x)))
                        if x.mount != '/' else None,
                        UI.TipIcon(
                            iconfont='gen-cancel-circle',
                            text='Delete',
                            id=('delvd/' + str(self._vdevs.index(x))),
                            warning=
                            'Are you sure you wish to delete virtual disk %s?'
                            % (x.name)) if x.delete else None,
                    )))

        t = ui.find('pdlist')

        for x in self._devs:
            if x.fstype == 'disk':
                fstype = 'Physical Disk'
            elif x.fstype == 'rom':
                fstype = 'Optical Disk Drive'
            elif x.fstype == 'part':
                fstype = 'Disk Partition'
            elif x.fstype == 'loop':
                fstype = 'Loopback'
            else:
                fstype = 'Unknown'
            t.append(
                UI.DTR(
                    UI.Iconfont(iconfont=x.icon),
                    UI.Label(text=x.name, bold=False if x.parent else True),
                    UI.Label(text=fstype), UI.Label(text=str_fsize(x.size)),
                    UI.HContainer(
                        UI.TipIcon(iconfont='gen-arrow-down-3'
                                   if x.mount else 'gen-arrow-up-3',
                                   text='Unmount' if x.mount else 'Mount',
                                   id=('umd/' if x.mount else 'md/') +
                                   str(self._devs.index(x)))
                        if x.mount != '/' and x.fstype != 'disk' else None, )))

        t = ui.find('list')

        for u in self.fstab:
            t.append(
                UI.DTR(
                    UI.Label(text=u.src, bold=True),
                    UI.Label(text=u.dst),
                    UI.Label(text=u.fs_type),
                    UI.Label(text=u.options),
                    UI.Label(text=str(u.dump_p)),
                    UI.Label(text=str(u.fsck_p)),
                    UI.HContainer(
                        UI.TipIcon(iconfont='gen-pencil-2',
                                   id='edit/' + str(self.fstab.index(u)),
                                   text='Edit'),
                        UI.TipIcon(iconfont='gen-cancel-circle',
                                   id='del/' + str(self.fstab.index(u)),
                                   text='Delete',
                                   warning='Remove %s from fstab' % u.src)),
                ))

        if self._editing != -1:
            try:
                e = self.fstab[self._editing]
            except:
                e = backend.Entry()
                e.src = '/dev/sda1'
                e.dst = '/tmp'
                e.options = 'none'
                e.fs_type = 'none'
                e.dump_p = 0
                e.fsck_p = 0
            self.setup_ui_edit(ui, e)
        else:
            ui.remove('dlgEdit')

        if self._add:
            ui.append(
                'main',
                UI.DialogBox(UI.FormLine(UI.TextInput(name='addname',
                                                      id='addname'),
                                         text='Virtual disk name'),
                             UI.FormLine(UI.TextInput(name='addsize',
                                                      id='addsize'),
                                         text='Disk size (in MB)'),
                             UI.FormLine(UI.EditPassword(
                                 id='passwd', value='Click to add password'),
                                         text='Password')
                             if self._add == 'enc' else None,
                             id='dlgAdd'))

        if self._enc:
            ui.append(
                'main',
                UI.DialogBox(UI.FormLine(UI.EditPassword(
                    id='encpasswd', value='Click to add password'),
                                         text='Password'),
                             id='dlgEnc'))

        if self._auth:
            ui.append(
                'main',
                UI.DialogBox(UI.FormLine(UI.Label(text=self._auth.name),
                                         text='For disk:'),
                             UI.FormLine(UI.TextInput(name='authpasswd',
                                                      password=True),
                                         text='Password'),
                             id='dlgAuth'))

        return ui
Esempio n. 5
0
        ui = self.app.inflate("openvpn:main")

        try:
            self._b.connect()
            status = self._b.getstatus()
            stats = self._b.getstats()
            messages = self._b.getmessages()
            self._b.disconnect()
        except Exception, e:
            self.put_message("err", e)
            return ui

        ui.find("nclients").set("text",
                                "Clients: {0}".format(stats["nclients"]))
        ui.find("bytesin").set(
            "text", "Bytes in: {0}".format(str_fsize(float(stats["bytesin"]))))
        ui.find("bytesout").set(
            "text",
            "Bytes out: {0}".format(str_fsize(float(stats["bytesout"]))))

        map(
            lambda c: ui.append(
                "clients",
                UI.DTR(
                    UI.Icon(icon="/dl/core/ui/stock/user.png"),
                    UI.Label(text=c["cn"]), UI.Label(text=c["raddress"]),
                    UI.Label(text=c["vaddress"]),
                    UI.Label(text=str_fsize(float(c["brecv"]))),
                    UI.Label(text=str_fsize(float(c["bsent"]))),
                    UI.Label(text=c["connsince"]),
                    UI.TipIcon(icon="/dl/core/ui/stock/delete.png",
Esempio n. 6
0
    def get_ui(self):
        ui = self.app.inflate('filesystems:main')

        t = ui.find('vdlist')

        for x in self._vdevs:
            t.append(UI.DTR(
                UI.Iconfont(iconfont=x.icon),
                UI.Label(text=x.name),
                UI.Label(text='Encrypted Disk' if x.fstype == 'crypt' else 'Virtual Disk'),
                UI.Label(text=str_fsize(x.size)),
                UI.Label(text=x.mount if x.mount else 'Not Mounted'),
                UI.HContainer(
                    UI.TipIcon(iconfont='gen-key', 
                        text='Encrypt Disk', 
                        id=('ecvd/' + str(self._vdevs.index(x))),
                        warning='Are you sure you wish to encrypt virtual disk %s? This will erase ALL data on the disk, and is irreversible.'%x.name
                    ) if x.fstype != 'crypt' else None,
                    UI.TipIcon(iconfont='gen-arrow-down-3' if x.mount else 'gen-arrow-up-3', 
                        text='Unmount' if x.mount else 'Mount', 
                        id=('umd/' if x.mount else 'md/') + str(self._vdevs.index(x))
                    ) if x.mount != '/' else None,
                    UI.TipIcon(iconfont='gen-cancel-circle', 
                        text='Delete', 
                        id=('delvd/' + str(self._vdevs.index(x))), 
                        warning='Are you sure you wish to delete virtual disk %s?' % (x.name)
                    ) if x.delete else None,
                )
            ))

        t = ui.find('pdlist')

        for x in self._devs:
            if x.fstype == 'disk':
                fstype = 'Physical Disk'
            elif x.fstype == 'rom':
                fstype = 'Optical Disk Drive'
            elif x.fstype == 'part':
                fstype = 'Disk Partition'
            elif x.fstype == 'loop':
                fstype = 'Loopback'
            else:
                fstype = 'Unknown'
            t.append(UI.DTR(
                UI.Iconfont(iconfont=x.icon),
                UI.Label(text=x.name, bold=False if x.parent else True),
                UI.Label(text=fstype),
                UI.Label(text=str_fsize(x.size)),
                UI.HContainer(
                    UI.TipIcon(iconfont='gen-arrow-down-3' if x.mount else 'gen-arrow-up-3', 
                        text='Unmount' if x.mount else 'Mount', 
                        id=('umd/' if x.mount else 'md/') + str(self._devs.index(x))
                    ) if x.mount != '/' and x.fstype != 'disk' else None,
                )
            ))

        t = ui.find('list')

        for u in self.fstab:
            t.append(UI.DTR(
                    UI.Label(text=u.src, bold=True),
                    UI.Label(text=u.dst),
                    UI.Label(text=u.fs_type),
                    UI.Label(text=u.options),
                    UI.Label(text=str(u.dump_p)),
                    UI.Label(text=str(u.fsck_p)),
                    UI.HContainer(
                        UI.TipIcon(iconfont='gen-pencil-2', id='edit/'+str(self.fstab.index(u)), text='Edit'),
                        UI.TipIcon(iconfont='gen-cancel-circle', id='del/'+str(self.fstab.index(u)), text='Delete', warning='Remove %s from fstab'%u.src)
                    ),
                ))

        if self._editing != -1:
            try:
                e = self.fstab[self._editing]
            except:
                e = backend.Entry()
                e.src = '/dev/sda1'
                e.dst = '/tmp'
                e.options = 'none'
                e.fs_type = 'none'
                e.dump_p = 0
                e.fsck_p = 0
            self.setup_ui_edit(ui, e)
        else:
            ui.remove('dlgEdit')

        if self._add:
            ui.append('main', UI.DialogBox(
                UI.FormLine(
                    UI.TextInput(name='addname', id='addname'),
                    text='Virtual disk name'
                ),
                UI.FormLine(
                    UI.TextInput(name='addsize', id='addsize'),
                    text='Disk size (in MB)'
                ),
                UI.FormLine(
                    UI.EditPassword(id='passwd', value='Click to add password'),
                    text='Password'
                ) if self._add == 'enc' else None,
                id='dlgAdd'
            ))

        if self._enc:
            ui.append('main', UI.DialogBox(
                UI.FormLine(
                    UI.EditPassword(id='encpasswd', value='Click to add password'),
                    text='Password'
                ),
                id='dlgEnc'
            ))

        if self._auth:
            ui.append('main', UI.DialogBox(
                UI.FormLine(
                    UI.Label(text=self._auth.name),
                    text='For disk:'
                ),
                UI.FormLine(
                    UI.TextInput(name='authpasswd', password=True),
                    text='Password'
                ), id='dlgAuth'
            ))

        return ui
Esempio n. 7
0
def trans_fsize(x):
    return str_fsize(int(x['value']))
Esempio n. 8
0
    def get_ui(self):
        if self._redirect is not None:
            r = self._redirect
            self._redirect = None
            return r

        ui = self.app.inflate('filesystems:main')

        t = ui.find('vdlist')

        for x in self._vdevs:
            t.append(UI.DTR(
                UI.Iconfont(iconfont=x.icon),
                UI.Label(text=x.name),
                UI.Label(text='Encrypted Disk' if x.fstype == 'crypt' else 'Virtual Disk'),
                UI.Label(text=str_fsize(x.size)),
                UI.LinkLabel(text=x.mount, id='open/%s'%self.enc_file(x.mount)) if x.mount else UI.Label(text='Not Mounted'),
                UI.HContainer(
                    UI.TipIcon(iconfont='gen-key', 
                        text='Encrypt Disk', 
                        id=('ecvd/' + str(self._vdevs.index(x))),
                        warning='Are you sure you wish to encrypt virtual disk %s? This will erase ALL data on the disk, and is irreversible.'%x.name
                    ) if x.fstype != 'crypt' else None,
                    UI.TipIcon(iconfont='gen-arrow-down-3' if x.mount else 'gen-arrow-up-3', 
                        text='Unmount' if x.mount else 'Mount', 
                        id=('umvd/' if x.mount else 'mvd/') + str(self._vdevs.index(x))
                    ) if x.mount != '/' else None,
                    UI.TipIcon(iconfont='gen-cancel-circle', 
                        text='Delete', 
                        id=('delvd/' + str(self._vdevs.index(x))), 
                        warning='Are you sure you wish to delete virtual disk %s?' % (x.name)
                    ) if x.delete else None,
                )
            ))

        t = ui.find('pdlist')

        for x in self._devs:
            if x.fstype == 'disk':
                fstype = 'Physical Disk'
            elif x.fstype == 'rom':
                fstype = 'Optical Disk Drive'
            elif x.fstype == 'part':
                fstype = 'Disk Partition'
            elif x.fstype == 'loop':
                fstype = 'Loopback'
            else:
                fstype = 'Unknown'
            t.append(UI.DTR(
                UI.Iconfont(iconfont=x.icon),
                UI.Label(text=x.name, bold=False if x.parent else True),
                UI.Label(text=fstype),
                UI.Label(text=str_fsize(x.size)),
                UI.LinkLabel(text=x.mount, id='open/%s'%self.enc_file(x.mount)) if x.mount else UI.Label(text='Not Mounted'),
                UI.HContainer(
                    UI.TipIcon(iconfont='gen-arrow-down-3' if x.mount else 'gen-arrow-up-3', 
                        text='Unmount' if x.mount else 'Mount', 
                        id=('umd/' if x.mount else 'md/') + str(self._devs.index(x))
                    ) if x.mount != '/' and x.fstype != 'disk' else None,
                )
            ))

        t = ui.find('list')

        for u in self.fstab:
            t.append(UI.DTR(
                    UI.Label(text=u.src, bold=True),
                    UI.Label(text=u.dst),
                    UI.Label(text=u.fs_type),
                    UI.Label(text=u.options),
                    UI.Label(text=str(u.dump_p)),
                    UI.Label(text=str(u.fsck_p)),
                    UI.HContainer(
                        UI.TipIcon(iconfont='gen-pencil-2', id='edit/'+str(self.fstab.index(u)), text='Edit'),
                        UI.TipIcon(iconfont='gen-cancel-circle', id='del/'+str(self.fstab.index(u)), text='Delete', warning='Remove %s from fstab'%u.src)
                    ),
                ))

        for x in self._cfg.cipher_opts:
            ui.find('dcipher').append(UI.SelectOption(text=x, value=x, id=x, selected=x==self._cfg.cipher))
        for x in self._cfg.dhash_opts:
            ui.find('dhash').append(UI.SelectOption(text=x, value=x, id=x, selected=x==self._cfg.dhash))
        ui.find('dkeysize').set('value', self._cfg.keysize)

        if self._editing != -1:
            try:
                e = self.fstab[self._editing]
            except:
                e = backend.Entry()
                e.src = '/dev/sda1'
                e.dst = '/tmp'
                e.options = 'none'
                e.fs_type = 'none'
                e.dump_p = 0
                e.fsck_p = 0
            self.setup_ui_edit(ui, e)
        else:
            ui.remove('dlgEdit')

        if self._add:
            ui.append('main', UI.DialogBox(
                UI.FormLine(
                    UI.TextInput(name='addname', id='addname'),
                    text='Virtual disk name', feedback="gen-storage", iid="addname"
                ),
                UI.FormLine(
                    UI.TextInput(name='addsize', id='addsize'),
                    text='Disk size (in MB)', feedback="gen-storage", iid="addsize"
                ),
                UI.Formline(UI.TextInput(id='passwd', name="passwd", password=True, verify="password", verifywith="passwd"),
                    text="Password", feedback="gen-lock", iid="passwd"
                ) if self._add == 'enc' else None,
                UI.Formline(UI.TextInput(id='passwdb', name="passwdb", password=True, verify="password", verifywith="passwd"),
                    text="Confirm password", feedback="gen-lock", iid="passwdb"
                ) if self._add == 'enc' else None,
                id='dlgAdd', title="Adding %s disk" % ('encrypted' if self._add == 'enc' else 'virtual'), iconfont="gen-storage"
            ))

        if self._enc:
            ui.append('main', UI.DialogBox(
                UI.Formline(UI.TextInput(id='encpasswd', name="encpasswd", password=True, verify="password", verifywith="encpasswd"),
                    text="Password", feedback="gen-lock", iid="encpasswd"
                ),
                UI.Formline(UI.TextInput(id='encpasswdb', name="encpasswdb", password=True, verify="password", verifywith="encpasswd"),
                    text="Confirm password", feedback="gen-lock", iid="encpasswdb"
                ),
                id='dlgEnc', title="Encrypting virtual disk %s" % self._enc.name, iconfont="gen-lock"
            ))

        if self._auth:
            ui.append('main', UI.Authorization(
                app='Filesystems',
                reason='Decrypt %s'%self._auth.img,
                label='Please enter your encryption passphrase'
            ))

        return ui
Esempio n. 9
0
File: main.py Progetto: bneg/genesis
    def get_ui(self):
        ui = self.app.inflate("openvpn:main")

        try:
            self._b.connect()
            status =   self._b.getstatus()
            stats =    self._b.getstats()
            messages = self._b.getmessages()
            self._b.disconnect()
        except Exception, e:
            self.put_message("err", e)
            return ui

        ui.find("nclients").set("text",   "Clients: {0}".format(stats["nclients"]))
        ui.find("bytesin").set( "text",  "Bytes in: {0}".format(str_fsize(float(stats["bytesin"]))))
        ui.find("bytesout").set("text", "Bytes out: {0}".format(str_fsize(float(stats["bytesout"]))))

        map(lambda c: ui.append("clients", UI.DTR(
            UI.Icon(icon="/dl/core/ui/stock/user.png"),
            UI.Label(text=c["cn"]),
            UI.Label(text=c["raddress"]),
            UI.Label(text=c["vaddress"]),
            UI.Label(text=str_fsize(float(c["brecv"]))),
            UI.Label(text=str_fsize(float(c["bsent"]))),
            UI.Label(text=c["connsince"]),
            UI.TipIcon(
                icon="/dl/core/ui/stock/delete.png",
                text="Disconnect",
                warning="Disconnect {0} ({1})?".format(c["cn"], c["raddress"]),
                id="disconnect/{0}".format(c["raddress"]))
Esempio n. 10
0
def trans_fsize(x):
    return str_fsize(int(x['value']))