Guest User

Untitled

a guest
Oct 10th, 2017
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 196 @gen.coroutine
  2. 197 def send_oleh(self, stream, address):
  3. 198 # OLEHを送る
  4. 199 access_log.info("OLEH to: {ip}:{port}".format(ip=address[0], port=address[1]))
  5. 200 client_port = self.address_state[address]["client_port"]
  6. 201 oleh_length = 5 | 0x80000000
  7. 202 remote_ip_obj = ipaddress.ip_address(address[0])
  8. 203 remote_ip_bytes = remote_ip_obj.packed
  9. 204 oleh_header = pack("!4s", "oleh".encode("utf-8")) + pack("<I", oleh_length)
  10. 205 oleh_agent = pack("!4s", "agnt".encode("utf-8")) + pack("<I", len(self.SERVER_NAME)) + pack("!{length}s".format(length=len(self. SERVER_NAME)), self.SERVER_NAME.encode("utf-8"))
  11. 206 oleh_sessionid = pack("!4s", "sid\x00".encode("utf-8")) + pack("<I", 2) + pack("<H", self.session_id)
  12. 207 oleh_version = pack("!4s", "ver\x00".encode("utf-8")) + pack("<I", 4) + pack("<I", self.PCP_VERSION)
  13. 208 oleh_remoteip = pack("!4s", "rip\x00".encode("utf-8")) + pack("<I", len(remote_ip_bytes)) + pack(">{length}s".format(length=len( remote_ip_bytes)), remote_ip_bytes)
  14. 209 oleh_remoteport = pack("!4s", "port".encode("utf-8")) + pack("<I", 2) + pack("<H", client_port)
  15. 210 oleh_content = oleh_header + oleh_agent + oleh_sessionid + oleh_version + oleh_remoteip + oleh_remoteport
  16. 211 app_log.debug("Send OLEH")
  17. 212 yield stream.write(oleh_content)
  18. 213 self.address_state[address]["next_state"] = PCPState.SERV
  19. 214 return
RAW Paste Data