OLD | NEW |
1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
(...skipping 13 matching lines...) Expand all Loading... |
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 | 28 |
29 import socket | 29 import socket |
30 import SocketServer | 30 import SocketServer |
31 | 31 |
32 from . import compression | 32 from . import compression |
33 from . import constants | 33 from . import constants |
34 from . import discovery | |
35 | 34 |
36 | 35 |
37 def _StatusQuery(peer, query): | 36 def _StatusQuery(peer, query): |
38 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | 37 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
39 code = sock.connect_ex((peer.address, constants.STATUS_PORT)) | 38 code = sock.connect_ex((peer.address, constants.STATUS_PORT)) |
40 if code != 0: | 39 if code != 0: |
41 # TODO(jkummerow): disconnect (after 3 failures?) | 40 # TODO(jkummerow): disconnect (after 3 failures?) |
42 return | 41 return |
43 compression.Send(query, sock) | 42 compression.Send(query, sock) |
44 compression.Send(constants.END_OF_STREAM, sock) | 43 compression.Send(constants.END_OF_STREAM, sock) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 103 |
105 rec.Advance() | 104 rec.Advance() |
106 compression.Send(constants.END_OF_STREAM, self.request) | 105 compression.Send(constants.END_OF_STREAM, self.request) |
107 | 106 |
108 | 107 |
109 class StatusSocketServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): | 108 class StatusSocketServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): |
110 def __init__(self, daemon): | 109 def __init__(self, daemon): |
111 address = (daemon.ip, constants.STATUS_PORT) | 110 address = (daemon.ip, constants.STATUS_PORT) |
112 SocketServer.TCPServer.__init__(self, address, StatusHandler) | 111 SocketServer.TCPServer.__init__(self, address, StatusHandler) |
113 self.daemon = daemon | 112 self.daemon = daemon |
OLD | NEW |