Example #1
0
 def close(self):
     debug("close() closed=%s", self._closed)
     if self._closed:
         return
     self._closed = True
     self.scheduler.idle_add(self._process_packet_cb, self, [Protocol.CONNECTION_LOST])
     if self._conn:
         try:
             self._conn.close()
             if self._log_stats is None and self._conn.input_bytecount == 0 and self._conn.output_bytecount == 0:
                 # no data sent or received, skip logging of stats:
                 self._log_stats = False
             if self._log_stats:
                 log.info(
                     "connection closed after %s packets received (%s bytes) and %s packets sent (%s bytes)",
                     std_unit(self.input_packetcount),
                     std_unit_dec(self._conn.input_bytecount),
                     std_unit(self.output_packetcount),
                     std_unit_dec(self._conn.output_bytecount),
                 )
         except:
             log.error("error closing %s", self._conn, exc_info=True)
         self._conn = None
     self.terminate_queue_threads()
     self.scheduler.idle_add(self.clean)
Example #2
0
 def close(self):
     log("Protocol.close() closed=%s, connection=%s", self._closed,
         self._conn)
     if self._closed:
         return
     self._closed = True
     self.idle_add(self._process_packet_cb, self,
                   [Protocol.CONNECTION_LOST])
     c = self._conn
     if c:
         try:
             log("Protocol.close() calling %s", c.close)
             c.close()
             if self._log_stats is None and self._conn.input_bytecount == 0 and self._conn.output_bytecount == 0:
                 #no data sent or received, skip logging of stats:
                 self._log_stats = False
             if self._log_stats:
                 from xpra.simple_stats import std_unit, std_unit_dec
                 log.info(
                     "connection closed after %s packets received (%s bytes) and %s packets sent (%s bytes)",
                     std_unit(self.input_packetcount),
                     std_unit_dec(self._conn.input_bytecount),
                     std_unit(self.output_packetcount),
                     std_unit_dec(self._conn.output_bytecount))
         except:
             log.error("error closing %s", self._conn, exc_info=True)
         self._conn = None
     self.terminate_queue_threads()
     self.idle_add(self.clean)
     log("Protocol.close() done")
Example #3
0
 def close(self):
     log("Protocol.close() closed=%s, connection=%s", self._closed, self._conn)
     if self._closed:
         return
     self._closed = True
     self.idle_add(self._process_packet_cb, self, [Protocol.CONNECTION_LOST])
     c = self._conn
     if c:
         try:
             log("Protocol.close() calling %s", c.close)
             c.close()
             if self._log_stats is None and self._conn.input_bytecount==0 and self._conn.output_bytecount==0:
                 #no data sent or received, skip logging of stats:
                 self._log_stats = False
             if self._log_stats:
                 from xpra.simple_stats import std_unit, std_unit_dec
                 log.info("connection closed after %s packets received (%s bytes) and %s packets sent (%s bytes)",
                      std_unit(self.input_packetcount), std_unit_dec(self._conn.input_bytecount),
                      std_unit(self.output_packetcount), std_unit_dec(self._conn.output_bytecount)
                      )
         except:
             log.error("error closing %s", self._conn, exc_info=True)
         self._conn = None
     self.terminate_queue_threads()
     self.idle_add(self.clean)
     log("Protocol.close() done")
Example #4
0
    def populate_connection(self):
        def settimedeltastr(label, from_time):
            delta = datetime.timedelta(seconds=(int(time.time()) -
                                                int(from_time)))
            label.set_text(str(delta))

        if self.client.server_load:
            self.server_load_label.set_text("  ".join(
                [str(x / 1000.0) for x in self.client.server_load]))
        if self.client.server_start_time > 0:
            settimedeltastr(self.session_started_label,
                            self.client.server_start_time)
        else:
            self.session_started_label.set_text("unknown")
        settimedeltastr(self.session_connected_label, self.client.start_time)

        p = self.client._protocol
        c = p._conn
        self.input_packets_label.set_text(std_unit_dec(p.input_packetcount))
        self.input_bytes_label.set_text(std_unit_dec(c.input_bytecount))
        self.output_packets_label.set_text(std_unit_dec(p.output_packetcount))
        self.output_bytes_label.set_text(std_unit_dec(c.output_bytecount))

        def get_sound_info(supported, prop):
            if not supported:
                return {"state": "disabled"}
            if prop is None:
                return {"state": "inactive"}
            return prop.get_info()

        def set_sound_info(label, details, supported, prop):
            p = get_sound_info(supported, prop)
            label.set_text(p.get("state", ""))
            if details:
                d = p.get("queue.used_pct", -1)
                if d >= 0:
                    details.set_text(" (buffer: %s%%)" % str(d).rjust(3))
                else:
                    details.set_text("")

        set_sound_info(self.speaker_label, self.speaker_details,
                       self.client.speaker_enabled, self.client.sound_sink)
        set_sound_info(self.microphone_label, None,
                       self.client.microphone_enabled,
                       self.client.sound_source)

        self.connection_type_label.set_text(c.info)
        self.compression_label.set_text(str(p._compression_level))
        suffix = ""
        if c.info.lower() == "ssh":
            suffix = " (%s)" % c.info
        self.input_encryption_label.set_text((p.cipher_in_name or "None") +
                                             suffix)
        self.output_encryption_label.set_text((p.cipher_out_name or "None") +
                                              suffix)
        return True
Example #5
0
    def populate_connection(self):
        def settimedeltastr(label, from_time):
            delta = datetime.timedelta(seconds=(int(time.time()) - int(from_time)))
            label.set_text(str(delta))

        if self.client.server_load:
            self.server_load_label.set_text("  ".join([str(x / 1000.0) for x in self.client.server_load]))
        if self.client.server_start_time > 0:
            settimedeltastr(self.session_started_label, self.client.server_start_time)
        else:
            self.session_started_label.set_text("unknown")
        settimedeltastr(self.session_connected_label, self.client.start_time)

        p = self.client._protocol
        c = p._conn
        self.input_packets_label.set_text(std_unit_dec(p.input_packetcount))
        self.input_bytes_label.set_text(std_unit_dec(c.input_bytecount))
        self.output_packets_label.set_text(std_unit_dec(p.output_packetcount))
        self.output_bytes_label.set_text(std_unit_dec(c.output_bytecount))

        def get_sound_info(supported, prop):
            if not supported:
                return {"state": "disabled"}
            if prop is None:
                return {"state": "inactive"}
            return prop.get_info()

        def set_sound_info(label, details, supported, prop):
            p = get_sound_info(supported, prop)
            label.set_text(p.get("state", ""))
            if details:
                d = p.get("queue.used_pct", -1)
                if d >= 0:
                    details.set_text(" (buffer: %s%%)" % str(d).rjust(3))
                else:
                    details.set_text("")

        set_sound_info(self.speaker_label, self.speaker_details, self.client.speaker_enabled, self.client.sound_sink)
        set_sound_info(self.microphone_label, None, self.client.microphone_enabled, self.client.sound_source)

        self.connection_type_label.set_text(c.info)
        self.compression_label.set_text(str(p._compression_level))
        suffix = ""
        if c.info.lower() == "ssh":
            suffix = " (%s)" % c.info
        self.input_encryption_label.set_text((p.cipher_in_name or "None") + suffix)
        self.output_encryption_label.set_text((p.cipher_out_name or "None") + suffix)
        return True
Example #6
0
 def populate_table(self):
     if self.table:
         self.alignment.remove(self.table)
     #remove expired requests:
     now = monotonic_time()
     self.requests = [x for x in self.requests if x[-1] > now]
     self.expire_labels = {}
     tb = TableBuilder(rows=1, columns=4, row_spacings=15)
     #generate a new table:
     self.table = tb.get_table()
     if not self.requests:
         tb.add_row(gtk.Label("No requests pending"))
     else:
         headers = [
             gtk.Label("URL / Filename"),
             gtk.Label(""),
             gtk.Label("Expires in"),
             gtk.Label("Action")
         ]
         tb.add_row(*headers)
         for cb_answer, send_id, dtype, url, filesize, printit, openit, expires in self.requests:
             details = u""
             if dtype == b"file" and filesize > 0:
                 details = u"%sB" % std_unit_dec(filesize)
             expires_label = gtk.Label()
             self.expire_labels[expires_label] = expires
             buttons = self.action_buttons(cb_answer, send_id, dtype,
                                           printit, openit)
             items = (gtk.Label(bytestostr(url)), gtk.Label(details),
                      expires_label, buttons)
             tb.add_row(*items)
         self.update_expires_label()
     self.alignment.add(self.table)
     self.table.show_all()
Example #7
0
    def populate_form(self):
        btn = link_btn("https://github.com/Xpra-org/xpra/blob/master/docs/Network/README.md",
                       label="Open Network Documentation", icon_name=None)
        self.vbox.pack_start(btn, expand=True, fill=False, padding=20)

        tb = self.table()
        #"https://github.com/Xpra-org/xpra/blob/master/docs/Network/Multicast-DNS.md")
        self.radio_cb_auto(tb, "Session Sharing", "sharing")
        self.radio_cb_auto(tb, "Session Lock", "lock", "Prevent sessions from being taken over by new clients")
        self.sep(tb)
        self.bool_cb(tb, "Multicast DNS", "mdns", "Publish the session via mDNS")
        self.bool_cb(tb, "Bandwidth Detection", "bandwidth-detection", "Automatically detect runtime bandwidth limits")
        bwoptions = {
            "auto" : "Auto",
            }
        for bwlimit in BANDWIDTH_MENU_OPTIONS:
            if bwlimit<=0:
                s = "None"
            elif bwlimit>=10*1000*1000:
                s = "%iMbps" % (bwlimit//(1000*1000))
            else:
                s = "%sbps" % std_unit_dec(bwlimit)
            bwoptions[bwlimit] = s
        self.combo(tb, "Bandwidth Limit", "bandwidth-limit", bwoptions)
        #ssl options
        #ssh=paramiko | plink
        #exit-ssh
        #Remote Logging
        #open-files
        #open-url
        #file-size-limit
        self.vbox.show_all()
Example #8
0
 def close(self):
     if self._closed:
         return
     self._closed = True
     scheduler.idle_add(self._process_packet_cb, self, [Protocol.CONNECTION_LOST])
     if self._conn:
         try:
             self._conn.close()
             log.info("connection closed after %s packets received (%s bytes) and %s packets sent (%s bytes)",
                      std_unit(self.input_packetcount), std_unit_dec(self._conn.input_bytecount),
                      std_unit(self.output_packetcount), std_unit_dec(self._conn.output_bytecount)
                      )
         except:
             log.error("error closing %s", self._conn, exc_info=True)
         self._conn = None
     self.terminate_io_threads()
     scheduler.idle_add(self.clean)
Example #9
0
 def close(self):
     if self._closed:
         return
     self._closed = True
     scheduler.idle_add(self._process_packet_cb, self,
                        [Protocol.CONNECTION_LOST])
     if self._conn:
         try:
             self._conn.close()
             log.info(
                 "connection closed after %s packets received (%s bytes) and %s packets sent (%s bytes)",
                 std_unit(self.input_packetcount),
                 std_unit_dec(self._conn.input_bytecount),
                 std_unit(self.output_packetcount),
                 std_unit_dec(self._conn.output_bytecount))
         except:
             log.error("error closing %s", self._conn, exc_info=True)
         self._conn = None
     self.terminate_io_threads()
     scheduler.idle_add(self.clean)
Example #10
0
 def close(self):
     debug("close() closed=%s", self._closed)
     if self._closed:
         return
     self._closed = True
     self.scheduler.idle_add(self._process_packet_cb, self, [Protocol.CONNECTION_LOST])
     if self._conn:
         try:
             self._conn.close()
             if self._log_stats is None and self._conn.input_bytecount==0 and self._conn.output_bytecount==0:
                 #no data sent or received, skip logging of stats:
                 self._log_stats = False
             if self._log_stats:
                 log.info("connection closed after %s packets received (%s bytes) and %s packets sent (%s bytes)",
                      std_unit(self.input_packetcount), std_unit_dec(self._conn.input_bytecount),
                      std_unit(self.output_packetcount), std_unit_dec(self._conn.output_bytecount)
                      )
         except:
             log.error("error closing %s", self._conn, exc_info=True)
         self._conn = None
     self.terminate_queue_threads()
     self.scheduler.idle_add(self.clean)
Example #11
0
    def populate_table(self):
        if self.table:
            self.alignment.remove(self.table)
        #remove expired requests:
        now = monotonic_time()
        self.requests = [x for x in self.requests if x[-1] > now]
        self.expire_labels = {}
        tb = TableBuilder(rows=1, columns=4, row_spacings=15)

        def l(s=""):
            return gtk.Label(s)

        #generate a new table:
        self.table = tb.get_table()
        if not self.requests:
            tb.add_row(l("No requests pending"))
        else:
            headers = [
                l("URL / Filename"),
                l(""),
                l("Expires in"),
                l("Action")
            ]
            tb.add_row(*headers)
            for cb_answer, send_id, dtype, url, filesize, printit, openit, expires in self.requests:
                details = u""
                if dtype == b"file" and filesize > 0:
                    details = u"%sB" % std_unit_dec(filesize)
                expires_label = l()
                self.expire_labels[expires_label] = expires
                buttons = self.action_buttons(cb_answer, send_id, dtype,
                                              printit, openit)
                s = bytestostr(url)
                main_label = l(s)
                if dtype == b"url" and s.find("?") > 0 and len(s) > 48:
                    parts = s.split("?", 1)
                    main_label.set_label(parts[0] + "?..")
                    main_label.set_tooltip_text(s)
                main_label.set_line_wrap(True)
                try:
                    main_label.set_line_wrap_mode(pango.WrapMode.WORD_CHAR)
                except AttributeError:
                    main_label.set_line_wrap_mode(pango.WRAP_WORD_CHAR)
                main_label.set_size_request(URI_MAX_WIDTH, -1)
                items = (main_label, l(details), expires_label, buttons)
                tb.add_row(*items)
            self.update_expires_label()
        self.alignment.add(self.table)
        self.table.show_all()
Example #12
0
    def populate_connection(self):
        def settimedeltastr(label, from_time):
            delta = datetime.timedelta(seconds=(int(time.time())-int(from_time)))
            label.set_text(str(delta))
        if self.client.server_load:
            self.server_load_label.set_text("  ".join([str(x/1000.0) for x in self.client.server_load]))
        if self.client.server_start_time>0:
            settimedeltastr(self.session_started_label, self.client.server_start_time)
        else:
            self.session_started_label.set_text("unknown")
        settimedeltastr(self.session_connected_label, self.client.start_time)

        p = self.client._protocol
        if p is None:
            #no longer connected!
            return False
        c = p._conn
        self.input_packets_label.set_text(std_unit_dec(p.input_packetcount))
        self.input_bytes_label.set_text(std_unit_dec(c.input_bytecount))
        self.output_packets_label.set_text(std_unit_dec(p.output_packetcount))
        self.output_bytes_label.set_text(std_unit_dec(c.output_bytecount))

        def get_sound_info(supported, prop):
            if not supported:
                return {"state" : "disabled"}
            if prop is None:
                return {"state" : "inactive"}
            return prop.get_info()
        def set_sound_info(label, details, supported, prop):
            p = get_sound_info(supported, prop)
            label.set_text(p.get("state", ""))
            if details:
                d = p.get("queue.used", -1)
                if d>=0:
                    details.set_text(" (buffer: %sms)" % str(d).rjust(3))
                else:
                    details.set_text("")
        set_sound_info(self.speaker_label, self.speaker_details, self.client.speaker_enabled, self.client.sound_sink)
        set_sound_info(self.microphone_label, None, self.client.microphone_enabled, self.client.sound_source)

        self.connection_type_label.set_text(c.info)
        protocol_info = p.get_info()
        encoder = protocol_info.get("encoder", "bug")
        compressor = protocol_info.get("compressor", "none")
        level = protocol_info.get("compression_level", 0)
        compression_str = encoder + " + "+compressor
        if level>0:
            compression_str += " (level %s)" % level
        self.compression_label.set_text(compression_str)

        def enclabel(label, cipher):
            if not cipher:
                info = "None"
            else:
                info = str(cipher)
            if c.info.lower()=="ssh":
                info += " (%s)" % c.info
            if get_network_caps().get("pycrypto.fastmath", False):
                info += " (fastmath available)"
            label.set_text(info)
        enclabel(self.input_encryption_label, p.cipher_in_name)
        enclabel(self.output_encryption_label, p.cipher_out_name)
        return True
Example #13
0
def pixelstr(v):
    if v<0:
        return  "n/a"
    return std_unit_dec(v)
Example #14
0
    def populate_connection(self):
        def settimedeltastr(label, from_time):
            delta = datetime.timedelta(seconds=(int(time.time())-int(from_time)))
            label.set_text(str(delta))
        if self.client.server_load:
            self.server_load_label.set_text("  ".join([str(x/1000.0) for x in self.client.server_load]))
        if self.client.server_start_time>0:
            settimedeltastr(self.session_started_label, self.client.server_start_time)
        else:
            self.session_started_label.set_text("unknown")
        settimedeltastr(self.session_connected_label, self.client.start_time)

        p = self.client._protocol
        if p is None:
            #no longer connected!
            return False
        c = p._conn
        self.input_packets_label.set_text(std_unit_dec(p.input_packetcount))
        self.input_bytes_label.set_text(std_unit_dec(c.input_bytecount))
        self.output_packets_label.set_text(std_unit_dec(p.output_packetcount))
        self.output_bytes_label.set_text(std_unit_dec(c.output_bytecount))

        def get_sound_info(supported, prop):
            if not supported:
                return {"state" : "disabled"}
            if prop is None:
                return {"state" : "inactive"}
            return prop.get_info()
        def set_sound_info(label, details, supported, prop):
            p = get_sound_info(supported, prop)
            label.set_text(p.get("state", ""))
            if details:
                d = p.get("queue.used_pct", -1)
                if d>=0:
                    details.set_text(" (buffer: %s%%)" % str(d).rjust(3))
                else:
                    details.set_text("")
        set_sound_info(self.speaker_label, self.speaker_details, self.client.speaker_enabled, self.client.sound_sink)
        set_sound_info(self.microphone_label, None, self.client.microphone_enabled, self.client.sound_source)

        self.connection_type_label.set_text(c.info)
        protocol_info = p.get_info()
        encoder = protocol_info.get("encoder", "bug")
        compressor = protocol_info.get("compressor", "none")
        level = protocol_info.get("compression_level", 0)
        compression_str = encoder + " + "+compressor
        if level>0:
            compression_str += " (level %s)" % level
        self.compression_label.set_text(compression_str)

        def enclabel(label, cipher):
            if not cipher:
                info = "None"
            else:
                info = str(cipher)
            if c.info.lower()=="ssh":
                info += " (%s)" % c.info
            if get_network_caps().get("pycrypto.fastmath", False):
                info += " (fastmath available)"
            label.set_text(info)
        enclabel(self.input_encryption_label, p.cipher_in_name)
        enclabel(self.output_encryption_label, p.cipher_out_name)
        return True
Example #15
0
def pixelstr(v):
    if v<0:
        return  "n/a"
    return std_unit_dec(v)