Skip to content

Commit

Permalink
#3229 don't assume we get bytes or strings here
Browse files Browse the repository at this point in the history
for now we may get either and we should not care,
convert to strings to make the code easier to read
  • Loading branch information
totaam committed Aug 4, 2021
1 parent 219d040 commit 2a5a56b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions xpra/server/proxy/proxy_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def process_client_packet(self, proto, packet):
hello = self.filter_client_caps(self.caps, CLIENT_REMOVE_CAPS_CHALLENGE)
self.queue_server_packet(("hello", hello))
return
if packet_type=="ping_echo" and self.client_ping_timer and len(packet)>=7 and packet[6]==strtobytes(self.uuid):
if packet_type=="ping_echo" and self.client_ping_timer and len(packet)>=7 and strtobytes(packet[6])==strtobytes(self.uuid):
#this is one of our ping packets:
self.client_last_ping_echo = packet[1]
self.client_last_ping_latency = 1000*monotonic_time()-self.client_last_ping_echo
Expand Down Expand Up @@ -471,7 +471,7 @@ def process_server_packet(self, proto, packet):
#may need to bump packet size:
proto.max_packet_size = max(MAX_PACKET_SIZE, maxw*maxh*4*4)
packet = ("hello", caps)
elif packet_type=="ping_echo" and self.server_ping_timer and len(packet)>=7 and packet[6]==strtobytes(self.uuid):
elif packet_type=="ping_echo" and self.server_ping_timer and len(packet)>=7 and strtobytes(packet[6])==strtobytes(self.uuid):
#this is one of our ping packets:
self.server_last_ping_echo = packet[1]
self.server_last_ping_latency = 1000*monotonic_time()-self.server_last_ping_echo
Expand Down Expand Up @@ -578,21 +578,21 @@ def encode_loop(self):
if packet is None:
return
try:
packet_type = packet[0]
if packet_type==b"lost-window":
packet_type = bytestostr(packet[0])
if packet_type=="lost-window":
wid = packet[1]
self.lost_windows.remove(wid)
ve = self.video_encoders.get(wid)
if ve:
del self.video_encoders[wid]
del self.video_encoders_last_used_time[wid]
ve.clean()
elif packet_type==b"draw":
elif packet_type=="draw":
#modify the packet with the video encoder:
if self.process_draw(packet):
#then send it as normal:
self.queue_client_packet(packet)
elif packet_type==b"check-video-timeout":
elif packet_type=="check-video-timeout":
#not a real packet, this is added by the timeout check:
wid = packet[1]
ve = self.video_encoders.get(wid)
Expand All @@ -613,8 +613,9 @@ def encode_loop(self):

def process_draw(self, packet):
wid, x, y, width, height, encoding, pixels, _, rowstride, client_options = packet[1:11]
encoding = bytestostr(encoding)
#never modify mmap packets
if encoding in (b"mmap", b"scroll"):
if encoding in ("mmap", "scroll"):
return True

client_options = typedict(client_options)
Expand Down

0 comments on commit 2a5a56b

Please sign in to comment.