##// END OF EJS Templates
sshpeer: inline I/O into _validaterepo()...
Gregory Szorc -
r36011:a9cffd14 default
parent child Browse files
Show More
@@ -212,9 +212,28 b' class sshpeer(wireproto.wirepeer):'
212 self._abort(error.RepoError(msg, hint=hint))
212 self._abort(error.RepoError(msg, hint=hint))
213
213
214 try:
214 try:
215 # skip any noise generated by remote shell
215 pairsarg = '%s-%s' % ('0' * 40, '0' * 40)
216 self._callstream("hello")
216
217 r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40)))
217 handshake = [
218 'hello\n',
219 'between\n',
220 'pairs %d\n' % len(pairsarg),
221 pairsarg,
222 ]
223
224 requestlog = self.ui.configbool('devel', 'debug.peer-request')
225
226 if requestlog:
227 self.ui.debug('devel-peer-request: hello\n')
228 self.ui.debug('sending hello command\n')
229 if requestlog:
230 self.ui.debug('devel-peer-request: between\n')
231 self.ui.debug('devel-peer-request: pairs: %d bytes\n' %
232 len(pairsarg))
233 self.ui.debug('sending between command\n')
234
235 self._pipeo.write(''.join(handshake))
236 self._pipeo.flush()
218 except IOError:
237 except IOError:
219 badresponse()
238 badresponse()
220
239
@@ -222,8 +241,8 b' class sshpeer(wireproto.wirepeer):'
222 max_noise = 500
241 max_noise = 500
223 while lines[-1] and max_noise:
242 while lines[-1] and max_noise:
224 try:
243 try:
225 l = r.readline()
244 l = self._pipei.readline()
226 self._readerr()
245 _forwardoutput(self.ui, self._pipee)
227 if lines[-1] == "1\n" and l == "\n":
246 if lines[-1] == "1\n" and l == "\n":
228 break
247 break
229 if l:
248 if l:
@@ -54,24 +54,16 b' class prehelloserver(wireprotoserver.ssh'
54
54
55 class extrahandshakecommandspeer(sshpeer.sshpeer):
55 class extrahandshakecommandspeer(sshpeer.sshpeer):
56 """An ssh peer that sends extra commands as part of initial handshake."""
56 """An ssh peer that sends extra commands as part of initial handshake."""
57 # There isn't a good hook point. So we wrap _callstream() and inject
57 def _validaterepo(self):
58 # logic when the peer says "hello".
59 def _callstream(self, cmd, **args):
60 if cmd != b'hello':
61 return super(extrahandshakecommandspeer, self)._callstream(cmd,
62 **args)
63
64 mode = self._ui.config(b'sshpeer', b'handshake-mode')
58 mode = self._ui.config(b'sshpeer', b'handshake-mode')
65 if mode == b'pre-no-args':
59 if mode == b'pre-no-args':
66 self._callstream(b'no-args')
60 self._callstream(b'no-args')
67 return super(extrahandshakecommandspeer, self)._callstream(
61 return super(extrahandshakecommandspeer, self)._validaterepo()
68 cmd, **args)
69 elif mode == b'pre-multiple-no-args':
62 elif mode == b'pre-multiple-no-args':
70 self._callstream(b'unknown1')
63 self._callstream(b'unknown1')
71 self._callstream(b'unknown2')
64 self._callstream(b'unknown2')
72 self._callstream(b'unknown3')
65 self._callstream(b'unknown3')
73 return super(extrahandshakecommandspeer, self)._callstream(
66 return super(extrahandshakecommandspeer, self)._validaterepo()
74 cmd, **args)
75 else:
67 else:
76 raise error.ProgrammingError(b'unknown HANDSHAKECOMMANDMODE: %s' %
68 raise error.ProgrammingError(b'unknown HANDSHAKECOMMANDMODE: %s' %
77 mode)
69 mode)
General Comments 0
You need to be logged in to leave comments. Login now