Parse the '229' response for an EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.
(resp, peer)
| 829 | |
| 830 | |
| 831 | def parse229(resp, peer): |
| 832 | '''Parse the '229' response for an EPSV request. |
| 833 | Raises error_proto if it does not contain '(|||port|)' |
| 834 | Return ('host.addr.as.numbers', port#) tuple.''' |
| 835 | if resp[:3] != '229': |
| 836 | raise error_reply(resp) |
| 837 | left = resp.find('(') |
| 838 | if left < 0: raise error_proto(resp) |
| 839 | right = resp.find(')', left + 1) |
| 840 | if right < 0: |
| 841 | raise error_proto(resp) # should contain '(|||port|)' |
| 842 | if resp[left + 1] != resp[right - 1]: |
| 843 | raise error_proto(resp) |
| 844 | parts = resp[left + 1:right].split(resp[left+1]) |
| 845 | if len(parts) != 5: |
| 846 | raise error_proto(resp) |
| 847 | host = peer[0] |
| 848 | port = int(parts[3]) |
| 849 | return host, port |
| 850 | |
| 851 | |
| 852 | def parse257(resp): |
no test coverage detected
searching dependent graphs…