Parse the '227' response for a PASV request. Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)' Return ('host.addr.as.numbers', port#) tuple.
(resp)
| 810 | _227_re = None |
| 811 | |
| 812 | def parse227(resp): |
| 813 | '''Parse the '227' response for a PASV request. |
| 814 | Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)' |
| 815 | Return ('host.addr.as.numbers', port#) tuple.''' |
| 816 | if resp[:3] != '227': |
| 817 | raise error_reply(resp) |
| 818 | global _227_re |
| 819 | if _227_re is None: |
| 820 | import re |
| 821 | _227_re = re.compile(r'(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)', re.ASCII) |
| 822 | m = _227_re.search(resp) |
| 823 | if not m: |
| 824 | raise error_proto(resp) |
| 825 | numbers = m.groups() |
| 826 | host = '.'.join(numbers[:4]) |
| 827 | port = (int(numbers[4]) << 8) + int(numbers[5]) |
| 828 | return host, port |
| 829 | |
| 830 | |
| 831 | def parse229(resp, peer): |
no test coverage detected
searching dependent graphs…