MCPcopy Create free account
hub / github.com/apenwarr/sshuttle / Proxy

Class Proxy

ssnet.py:267–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265
266
267class Proxy(Handler):
268 def __init__(self, wrap1, wrap2):
269 Handler.__init__(self, [wrap1.rsock, wrap1.wsock,
270 wrap2.rsock, wrap2.wsock])
271 self.wrap1 = wrap1
272 self.wrap2 = wrap2
273
274 def pre_select(self, r, w, x):
275 if self.wrap1.shut_write: self.wrap2.noread()
276 if self.wrap2.shut_write: self.wrap1.noread()
277
278 if self.wrap1.connect_to:
279 _add(w, self.wrap1.rsock)
280 elif self.wrap1.buf:
281 if not self.wrap2.too_full():
282 _add(w, self.wrap2.wsock)
283 elif not self.wrap1.shut_read:
284 _add(r, self.wrap1.rsock)
285
286 if self.wrap2.connect_to:
287 _add(w, self.wrap2.rsock)
288 elif self.wrap2.buf:
289 if not self.wrap1.too_full():
290 _add(w, self.wrap1.wsock)
291 elif not self.wrap2.shut_read:
292 _add(r, self.wrap2.rsock)
293
294 def callback(self):
295 self.wrap1.try_connect()
296 self.wrap2.try_connect()
297 self.wrap1.fill()
298 self.wrap2.fill()
299 self.wrap1.copy_to(self.wrap2)
300 self.wrap2.copy_to(self.wrap1)
301 if self.wrap1.buf and self.wrap2.shut_write:
302 self.wrap1.buf = []
303 self.wrap1.noread()
304 if self.wrap2.buf and self.wrap1.shut_write:
305 self.wrap2.buf = []
306 self.wrap2.noread()
307 if (self.wrap1.shut_read and self.wrap2.shut_read and
308 not self.wrap1.buf and not self.wrap2.buf):
309 self.ok = False
310 self.wrap1.nowrite()
311 self.wrap2.nowrite()
312
313
314class Mux(Handler):

Callers 2

onacceptFunction · 0.90
new_channelFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected