Skip to content

Commit

Permalink
#1136: bail out early if this is not an xpra packet (saves instantiat…
Browse files Browse the repository at this point in the history
…ing a protocol instance for nothing)

git-svn-id: https://xpra.org/svn/Xpra/trunk@12699 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 27, 2016
1 parent 6ef6dc9 commit ef0fc0d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/xpra/server/server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,20 @@ def run_proxy():
self.start_tcp_proxy(conn, frominfo)
make_thread(run_proxy, "tcp-proxy-for-%s" % frominfo, daemon=True).start()
return True
#FIXME: if we have peek data and it isn't an xpra client,
#we can bail out early without making a protocol
else:
v = conn.peek(128)
log("%s.peek(128)=%s", conn, v)
if v and v[0] not in ("P", ord("P")):
#not an xpra client
msg = "disconnect: invalid packet format, not an xpra client?\n"
try:
from xpra.net.bytestreams import set_socket_timeout
set_socket_timeout(conn, 1)
conn.write(msg)
conn.close()
except Exception as e:
log("error sending '%s': %s", nonl(msg), e)
return True
netlog.info(info_msg)
return self.make_protocol(socktype, conn, frominfo)

Expand Down

0 comments on commit ef0fc0d

Please sign in to comment.