server.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. # server.py -- Implementation of the server side git protocols
  2. # Copyright (C) 2008 John Carr <john.carr@unrouted.co.uk>
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; version 2
  7. # or (at your option) any later version of the License.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. # MA 02110-1301, USA.
  18. """Git smart network protocol server implementation.
  19. For more detailed implementation on the network protocol, see the
  20. Documentation/technical directory in the cgit distribution, and in particular:
  21. Documentation/technical/protocol-capabilities.txt
  22. Documentation/technical/pack-protocol.txt
  23. """
  24. import collections
  25. import socket
  26. import SocketServer
  27. import sys
  28. import zlib
  29. from dulwich.errors import (
  30. ApplyDeltaError,
  31. ChecksumMismatch,
  32. GitProtocolError,
  33. ObjectFormatException,
  34. )
  35. from dulwich import log_utils
  36. from dulwich.objects import (
  37. hex_to_sha,
  38. )
  39. from dulwich.pack import (
  40. PackStreamReader,
  41. write_pack_data,
  42. )
  43. from dulwich.protocol import (
  44. MULTI_ACK,
  45. MULTI_ACK_DETAILED,
  46. ProtocolFile,
  47. ReceivableProtocol,
  48. SINGLE_ACK,
  49. TCP_GIT_PORT,
  50. ZERO_SHA,
  51. ack_type,
  52. extract_capabilities,
  53. extract_want_line_capabilities,
  54. )
  55. logger = log_utils.getLogger(__name__)
  56. class Backend(object):
  57. """A backend for the Git smart server implementation."""
  58. def open_repository(self, path):
  59. """Open the repository at a path."""
  60. raise NotImplementedError(self.open_repository)
  61. class BackendRepo(object):
  62. """Repository abstraction used by the Git server.
  63. Please note that the methods required here are a
  64. subset of those provided by dulwich.repo.Repo.
  65. """
  66. object_store = None
  67. refs = None
  68. def get_refs(self):
  69. """
  70. Get all the refs in the repository
  71. :return: dict of name -> sha
  72. """
  73. raise NotImplementedError
  74. def get_peeled(self, name):
  75. """Return the cached peeled value of a ref, if available.
  76. :param name: Name of the ref to peel
  77. :return: The peeled value of the ref. If the ref is known not point to
  78. a tag, this will be the SHA the ref refers to. If no cached
  79. information about a tag is available, this method may return None,
  80. but it should attempt to peel the tag if possible.
  81. """
  82. return None
  83. def fetch_objects(self, determine_wants, graph_walker, progress,
  84. get_tagged=None):
  85. """
  86. Yield the objects required for a list of commits.
  87. :param progress: is a callback to send progress messages to the client
  88. :param get_tagged: Function that returns a dict of pointed-to sha -> tag
  89. sha for including tags.
  90. """
  91. raise NotImplementedError
  92. class PackStreamCopier(PackStreamReader):
  93. """Class to verify a pack stream as it is being read.
  94. The pack is read from a ReceivableProtocol using read() or recv() as
  95. appropriate and written out to the given file-like object.
  96. """
  97. def __init__(self, read_all, read_some, outfile):
  98. super(PackStreamCopier, self).__init__(read_all, read_some)
  99. self.outfile = outfile
  100. def _read(self, read, size):
  101. data = super(PackStreamCopier, self)._read(read, size)
  102. self.outfile.write(data)
  103. return data
  104. def verify(self):
  105. """Verify a pack stream and write it to the output file.
  106. See PackStreamReader.iterobjects for a list of exceptions this may
  107. throw.
  108. """
  109. for _, _, _ in self.read_objects():
  110. pass
  111. class DictBackend(Backend):
  112. """Trivial backend that looks up Git repositories in a dictionary."""
  113. def __init__(self, repos):
  114. self.repos = repos
  115. def open_repository(self, path):
  116. logger.debug('Opening repository at %s', path)
  117. # FIXME: What to do in case there is no repo ?
  118. return self.repos[path]
  119. class Handler(object):
  120. """Smart protocol command handler base class."""
  121. def __init__(self, backend, proto):
  122. self.backend = backend
  123. self.proto = proto
  124. self._client_capabilities = None
  125. def capability_line(self):
  126. return " ".join(self.capabilities())
  127. def capabilities(self):
  128. raise NotImplementedError(self.capabilities)
  129. def innocuous_capabilities(self):
  130. return ("include-tag", "thin-pack", "no-progress", "ofs-delta")
  131. def required_capabilities(self):
  132. """Return a list of capabilities that we require the client to have."""
  133. return []
  134. def set_client_capabilities(self, caps):
  135. allowable_caps = set(self.innocuous_capabilities())
  136. allowable_caps.update(self.capabilities())
  137. for cap in caps:
  138. if cap not in allowable_caps:
  139. raise GitProtocolError('Client asked for capability %s that '
  140. 'was not advertised.' % cap)
  141. for cap in self.required_capabilities():
  142. if cap not in caps:
  143. raise GitProtocolError('Client does not support required '
  144. 'capability %s.' % cap)
  145. self._client_capabilities = set(caps)
  146. logger.info('Client capabilities: %s', caps)
  147. def has_capability(self, cap):
  148. if self._client_capabilities is None:
  149. raise GitProtocolError('Server attempted to access capability %s '
  150. 'before asking client' % cap)
  151. return cap in self._client_capabilities
  152. class UploadPackHandler(Handler):
  153. """Protocol handler for uploading a pack to the server."""
  154. def __init__(self, backend, args, proto,
  155. stateless_rpc=False, advertise_refs=False):
  156. Handler.__init__(self, backend, proto)
  157. self.repo = backend.open_repository(args[0])
  158. self._graph_walker = None
  159. self.stateless_rpc = stateless_rpc
  160. self.advertise_refs = advertise_refs
  161. def capabilities(self):
  162. return ("multi_ack_detailed", "multi_ack", "side-band-64k", "thin-pack",
  163. "ofs-delta", "no-progress", "include-tag")
  164. def required_capabilities(self):
  165. return ("side-band-64k", "thin-pack", "ofs-delta")
  166. def progress(self, message):
  167. if self.has_capability("no-progress"):
  168. return
  169. self.proto.write_sideband(2, message)
  170. def get_tagged(self, refs=None, repo=None):
  171. """Get a dict of peeled values of tags to their original tag shas.
  172. :param refs: dict of refname -> sha of possible tags; defaults to all of
  173. the backend's refs.
  174. :param repo: optional Repo instance for getting peeled refs; defaults to
  175. the backend's repo, if available
  176. :return: dict of peeled_sha -> tag_sha, where tag_sha is the sha of a
  177. tag whose peeled value is peeled_sha.
  178. """
  179. if not self.has_capability("include-tag"):
  180. return {}
  181. if refs is None:
  182. refs = self.repo.get_refs()
  183. if repo is None:
  184. repo = getattr(self.repo, "repo", None)
  185. if repo is None:
  186. # Bail if we don't have a Repo available; this is ok since
  187. # clients must be able to handle if the server doesn't include
  188. # all relevant tags.
  189. # TODO: fix behavior when missing
  190. return {}
  191. tagged = {}
  192. for name, sha in refs.iteritems():
  193. peeled_sha = repo.get_peeled(name)
  194. if peeled_sha != sha:
  195. tagged[peeled_sha] = sha
  196. return tagged
  197. def handle(self):
  198. write = lambda x: self.proto.write_sideband(1, x)
  199. graph_walker = ProtocolGraphWalker(self, self.repo.object_store,
  200. self.repo.get_peeled)
  201. objects_iter = self.repo.fetch_objects(
  202. graph_walker.determine_wants, graph_walker, self.progress,
  203. get_tagged=self.get_tagged)
  204. # Do they want any objects?
  205. if len(objects_iter) == 0:
  206. return
  207. self.progress("dul-daemon says what\n")
  208. self.progress("counting objects: %d, done.\n" % len(objects_iter))
  209. write_pack_data(ProtocolFile(None, write), objects_iter,
  210. len(objects_iter))
  211. self.progress("how was that, then?\n")
  212. # we are done
  213. self.proto.write("0000")
  214. class ProtocolGraphWalker(object):
  215. """A graph walker that knows the git protocol.
  216. As a graph walker, this class implements ack(), next(), and reset(). It
  217. also contains some base methods for interacting with the wire and walking
  218. the commit tree.
  219. The work of determining which acks to send is passed on to the
  220. implementation instance stored in _impl. The reason for this is that we do
  221. not know at object creation time what ack level the protocol requires. A
  222. call to set_ack_level() is required to set up the implementation, before any
  223. calls to next() or ack() are made.
  224. """
  225. def __init__(self, handler, object_store, get_peeled):
  226. self.handler = handler
  227. self.store = object_store
  228. self.get_peeled = get_peeled
  229. self.proto = handler.proto
  230. self.stateless_rpc = handler.stateless_rpc
  231. self.advertise_refs = handler.advertise_refs
  232. self._wants = []
  233. self._cached = False
  234. self._cache = []
  235. self._cache_index = 0
  236. self._impl = None
  237. def determine_wants(self, heads):
  238. """Determine the wants for a set of heads.
  239. The given heads are advertised to the client, who then specifies which
  240. refs he wants using 'want' lines. This portion of the protocol is the
  241. same regardless of ack type, and in fact is used to set the ack type of
  242. the ProtocolGraphWalker.
  243. :param heads: a dict of refname->SHA1 to advertise
  244. :return: a list of SHA1s requested by the client
  245. """
  246. if not heads:
  247. raise GitProtocolError('No heads found')
  248. values = set(heads.itervalues())
  249. if self.advertise_refs or not self.stateless_rpc:
  250. for i, (ref, sha) in enumerate(heads.iteritems()):
  251. line = "%s %s" % (sha, ref)
  252. if not i:
  253. line = "%s\x00%s" % (line, self.handler.capability_line())
  254. self.proto.write_pkt_line("%s\n" % line)
  255. peeled_sha = self.get_peeled(ref)
  256. if peeled_sha != sha:
  257. self.proto.write_pkt_line('%s %s^{}\n' %
  258. (peeled_sha, ref))
  259. # i'm done..
  260. self.proto.write_pkt_line(None)
  261. if self.advertise_refs:
  262. return []
  263. # Now client will sending want want want commands
  264. want = self.proto.read_pkt_line()
  265. if not want:
  266. return []
  267. line, caps = extract_want_line_capabilities(want)
  268. self.handler.set_client_capabilities(caps)
  269. self.set_ack_type(ack_type(caps))
  270. command, sha = self._split_proto_line(line)
  271. want_revs = []
  272. while command != None:
  273. if command != 'want':
  274. raise GitProtocolError(
  275. 'Protocol got unexpected command %s' % command)
  276. if sha not in values:
  277. raise GitProtocolError(
  278. 'Client wants invalid object %s' % sha)
  279. want_revs.append(sha)
  280. command, sha = self.read_proto_line()
  281. self.set_wants(want_revs)
  282. return want_revs
  283. def ack(self, have_ref):
  284. return self._impl.ack(have_ref)
  285. def reset(self):
  286. self._cached = True
  287. self._cache_index = 0
  288. def next(self):
  289. if not self._cached:
  290. if not self._impl and self.stateless_rpc:
  291. return None
  292. return self._impl.next()
  293. self._cache_index += 1
  294. if self._cache_index > len(self._cache):
  295. return None
  296. return self._cache[self._cache_index]
  297. def _split_proto_line(self, line):
  298. fields = line.rstrip('\n').split(' ', 1)
  299. if len(fields) == 1 and fields[0] == 'done':
  300. return ('done', None)
  301. elif len(fields) == 2 and fields[0] in ('want', 'have'):
  302. try:
  303. hex_to_sha(fields[1])
  304. return tuple(fields)
  305. except (TypeError, AssertionError), e:
  306. raise GitProtocolError(e)
  307. raise GitProtocolError('Received invalid line from client:\n%s' % line)
  308. def read_proto_line(self):
  309. """Read a line from the wire.
  310. :return: a tuple having one of the following forms:
  311. ('want', obj_id)
  312. ('have', obj_id)
  313. ('done', None)
  314. (None, None) (for a flush-pkt)
  315. :raise GitProtocolError: if the line cannot be parsed into one of the
  316. possible return values.
  317. """
  318. line = self.proto.read_pkt_line()
  319. if not line:
  320. return (None, None)
  321. return self._split_proto_line(line)
  322. def send_ack(self, sha, ack_type=''):
  323. if ack_type:
  324. ack_type = ' %s' % ack_type
  325. self.proto.write_pkt_line('ACK %s%s\n' % (sha, ack_type))
  326. def send_nak(self):
  327. self.proto.write_pkt_line('NAK\n')
  328. def set_wants(self, wants):
  329. self._wants = wants
  330. def _is_satisfied(self, haves, want, earliest):
  331. """Check whether a want is satisfied by a set of haves.
  332. A want, typically a branch tip, is "satisfied" only if there exists a
  333. path back from that want to one of the haves.
  334. :param haves: A set of commits we know the client has.
  335. :param want: The want to check satisfaction for.
  336. :param earliest: A timestamp beyond which the search for haves will be
  337. terminated, presumably because we're searching too far down the
  338. wrong branch.
  339. """
  340. o = self.store[want]
  341. pending = collections.deque([o])
  342. while pending:
  343. commit = pending.popleft()
  344. if commit.id in haves:
  345. return True
  346. if commit.type_name != "commit":
  347. # non-commit wants are assumed to be satisfied
  348. continue
  349. for parent in commit.parents:
  350. parent_obj = self.store[parent]
  351. # TODO: handle parents with later commit times than children
  352. if parent_obj.commit_time >= earliest:
  353. pending.append(parent_obj)
  354. return False
  355. def all_wants_satisfied(self, haves):
  356. """Check whether all the current wants are satisfied by a set of haves.
  357. :param haves: A set of commits we know the client has.
  358. :note: Wants are specified with set_wants rather than passed in since
  359. in the current interface they are determined outside this class.
  360. """
  361. haves = set(haves)
  362. earliest = min([self.store[h].commit_time for h in haves])
  363. for want in self._wants:
  364. if not self._is_satisfied(haves, want, earliest):
  365. return False
  366. return True
  367. def set_ack_type(self, ack_type):
  368. impl_classes = {
  369. MULTI_ACK: MultiAckGraphWalkerImpl,
  370. MULTI_ACK_DETAILED: MultiAckDetailedGraphWalkerImpl,
  371. SINGLE_ACK: SingleAckGraphWalkerImpl,
  372. }
  373. self._impl = impl_classes[ack_type](self)
  374. class SingleAckGraphWalkerImpl(object):
  375. """Graph walker implementation that speaks the single-ack protocol."""
  376. def __init__(self, walker):
  377. self.walker = walker
  378. self._sent_ack = False
  379. def ack(self, have_ref):
  380. if not self._sent_ack:
  381. self.walker.send_ack(have_ref)
  382. self._sent_ack = True
  383. def next(self):
  384. command, sha = self.walker.read_proto_line()
  385. if command in (None, 'done'):
  386. if not self._sent_ack:
  387. self.walker.send_nak()
  388. return None
  389. elif command == 'have':
  390. return sha
  391. class MultiAckGraphWalkerImpl(object):
  392. """Graph walker implementation that speaks the multi-ack protocol."""
  393. def __init__(self, walker):
  394. self.walker = walker
  395. self._found_base = False
  396. self._common = []
  397. def ack(self, have_ref):
  398. self._common.append(have_ref)
  399. if not self._found_base:
  400. self.walker.send_ack(have_ref, 'continue')
  401. if self.walker.all_wants_satisfied(self._common):
  402. self._found_base = True
  403. # else we blind ack within next
  404. def next(self):
  405. while True:
  406. command, sha = self.walker.read_proto_line()
  407. if command is None:
  408. self.walker.send_nak()
  409. # in multi-ack mode, a flush-pkt indicates the client wants to
  410. # flush but more have lines are still coming
  411. continue
  412. elif command == 'done':
  413. # don't nak unless no common commits were found, even if not
  414. # everything is satisfied
  415. if self._common:
  416. self.walker.send_ack(self._common[-1])
  417. else:
  418. self.walker.send_nak()
  419. return None
  420. elif command == 'have':
  421. if self._found_base:
  422. # blind ack
  423. self.walker.send_ack(sha, 'continue')
  424. return sha
  425. class MultiAckDetailedGraphWalkerImpl(object):
  426. """Graph walker implementation speaking the multi-ack-detailed protocol."""
  427. def __init__(self, walker):
  428. self.walker = walker
  429. self._found_base = False
  430. self._common = []
  431. def ack(self, have_ref):
  432. self._common.append(have_ref)
  433. if not self._found_base:
  434. self.walker.send_ack(have_ref, 'common')
  435. if self.walker.all_wants_satisfied(self._common):
  436. self._found_base = True
  437. self.walker.send_ack(have_ref, 'ready')
  438. # else we blind ack within next
  439. def next(self):
  440. while True:
  441. command, sha = self.walker.read_proto_line()
  442. if command is None:
  443. self.walker.send_nak()
  444. if self.walker.stateless_rpc:
  445. return None
  446. continue
  447. elif command == 'done':
  448. # don't nak unless no common commits were found, even if not
  449. # everything is satisfied
  450. if self._common:
  451. self.walker.send_ack(self._common[-1])
  452. else:
  453. self.walker.send_nak()
  454. return None
  455. elif command == 'have':
  456. if self._found_base:
  457. # blind ack; can happen if the client has more requests
  458. # inflight
  459. self.walker.send_ack(sha, 'ready')
  460. return sha
  461. class ReceivePackHandler(Handler):
  462. """Protocol handler for downloading a pack from the client."""
  463. def __init__(self, backend, args, proto,
  464. stateless_rpc=False, advertise_refs=False):
  465. Handler.__init__(self, backend, proto)
  466. self.repo = backend.open_repository(args[0])
  467. self.stateless_rpc = stateless_rpc
  468. self.advertise_refs = advertise_refs
  469. def capabilities(self):
  470. return ("report-status", "delete-refs")
  471. def _apply_pack(self, refs):
  472. f, commit = self.repo.object_store.add_thin_pack()
  473. all_exceptions = (IOError, OSError, ChecksumMismatch, ApplyDeltaError,
  474. AssertionError, socket.error, zlib.error,
  475. ObjectFormatException)
  476. status = []
  477. # TODO: more informative error messages than just the exception string
  478. try:
  479. PackStreamCopier(self.proto.read, self.proto.recv, f).verify()
  480. p = commit()
  481. if not p:
  482. raise IOError('Failed to write pack')
  483. p.check()
  484. status.append(('unpack', 'ok'))
  485. except all_exceptions, e:
  486. status.append(('unpack', str(e).replace('\n', '')))
  487. # The pack may still have been moved in, but it may contain broken
  488. # objects. We trust a later GC to clean it up.
  489. for oldsha, sha, ref in refs:
  490. ref_status = 'ok'
  491. try:
  492. if sha == ZERO_SHA:
  493. if not 'delete-refs' in self.capabilities():
  494. raise GitProtocolError(
  495. 'Attempted to delete refs without delete-refs '
  496. 'capability.')
  497. try:
  498. del self.repo.refs[ref]
  499. except all_exceptions:
  500. ref_status = 'failed to delete'
  501. else:
  502. try:
  503. self.repo.refs[ref] = sha
  504. except all_exceptions:
  505. ref_status = 'failed to write'
  506. except KeyError, e:
  507. ref_status = 'bad ref'
  508. status.append((ref, ref_status))
  509. return status
  510. def handle(self):
  511. refs = self.repo.get_refs().items()
  512. if self.advertise_refs or not self.stateless_rpc:
  513. if refs:
  514. self.proto.write_pkt_line(
  515. "%s %s\x00%s\n" % (refs[0][1], refs[0][0],
  516. self.capability_line()))
  517. for i in range(1, len(refs)):
  518. ref = refs[i]
  519. self.proto.write_pkt_line("%s %s\n" % (ref[1], ref[0]))
  520. else:
  521. self.proto.write_pkt_line("%s capabilities^{} %s" % (
  522. ZERO_SHA, self.capability_line()))
  523. self.proto.write("0000")
  524. if self.advertise_refs:
  525. return
  526. client_refs = []
  527. ref = self.proto.read_pkt_line()
  528. # if ref is none then client doesnt want to send us anything..
  529. if ref is None:
  530. return
  531. ref, caps = extract_capabilities(ref)
  532. self.set_client_capabilities(caps)
  533. # client will now send us a list of (oldsha, newsha, ref)
  534. while ref:
  535. client_refs.append(ref.split())
  536. ref = self.proto.read_pkt_line()
  537. # backend can now deal with this refs and read a pack using self.read
  538. status = self._apply_pack(client_refs)
  539. # when we have read all the pack from the client, send a status report
  540. # if the client asked for it
  541. if self.has_capability('report-status'):
  542. for name, msg in status:
  543. if name == 'unpack':
  544. self.proto.write_pkt_line('unpack %s\n' % msg)
  545. elif msg == 'ok':
  546. self.proto.write_pkt_line('ok %s\n' % name)
  547. else:
  548. self.proto.write_pkt_line('ng %s %s\n' % (name, msg))
  549. self.proto.write_pkt_line(None)
  550. # Default handler classes for git services.
  551. DEFAULT_HANDLERS = {
  552. 'git-upload-pack': UploadPackHandler,
  553. 'git-receive-pack': ReceivePackHandler,
  554. }
  555. class TCPGitRequestHandler(SocketServer.StreamRequestHandler):
  556. def __init__(self, handlers, *args, **kwargs):
  557. self.handlers = handlers and handlers or DEFAULT_HANDLERS
  558. SocketServer.StreamRequestHandler.__init__(self, *args, **kwargs)
  559. def handle(self):
  560. proto = ReceivableProtocol(self.connection.recv, self.wfile.write)
  561. command, args = proto.read_cmd()
  562. logger.info('Handling %s request, args=%s', command, args)
  563. cls = self.handlers.get(command, None)
  564. if not callable(cls):
  565. raise GitProtocolError('Invalid service %s' % command)
  566. h = cls(self.server.backend, args, proto)
  567. h.handle()
  568. class TCPGitServer(SocketServer.TCPServer):
  569. allow_reuse_address = True
  570. serve = SocketServer.TCPServer.serve_forever
  571. def _make_handler(self, *args, **kwargs):
  572. return TCPGitRequestHandler(self.handlers, *args, **kwargs)
  573. def __init__(self, backend, listen_addr, port=TCP_GIT_PORT, handlers=None):
  574. self.backend = backend
  575. self.handlers = handlers
  576. logger.info('Listening for TCP connections on %s:%d', listen_addr, port)
  577. SocketServer.TCPServer.__init__(self, (listen_addr, port),
  578. self._make_handler)
  579. def verify_request(self, request, client_address):
  580. logger.info('Handling request from %s', client_address)
  581. return True
  582. def handle_error(self, request, client_address):
  583. logger.exception('Exception happened during processing of request '
  584. 'from %s', client_address)