(String address, String port)
| 598 | |
| 599 | new RedirectionDialog( getString(R.string.mitm_redirection), MITM.this, new RedirectionDialogListener(){ |
| 600 | @Override |
| 601 | public void onInputEntered(String address, String port){ |
| 602 | if(address.isEmpty() == false && port.isEmpty() == false){ |
| 603 | try{ |
| 604 | int iport = Integer.parseInt(port); |
| 605 | |
| 606 | if(iport <= 0 || iport > 65535) |
| 607 | throw new Exception(getString(R.string.error_port_outofrange)); |
| 608 | |
| 609 | address = address.startsWith("http") ? address : "http://" + address; |
| 610 | |
| 611 | URL url = new URL(address); |
| 612 | address = url.getHost(); |
| 613 | |
| 614 | activity.setVisibility(View.VISIBLE); |
| 615 | Toast.makeText(MITM.this, getString(R.string.tap_again), Toast.LENGTH_LONG).show(); |
| 616 | |
| 617 | |
| 618 | final String faddress = address; |
| 619 | final int fport = iport; |
| 620 | |
| 621 | mSpoofSession = new SpoofSession(); |
| 622 | |
| 623 | mSpoofSession.start(new OnSessionReadyListener(){ |
| 624 | @Override |
| 625 | public void onSessionReady(){ |
| 626 | System.getProxy().setRedirection(faddress, fport); |
| 627 | } |
| 628 | |
| 629 | @Override |
| 630 | public void onError(String error, int resId){ |
| 631 | error = error == null ? getString(resId) : error; |
| 632 | setSpoofErrorState(error); |
| 633 | } |
| 634 | }); |
| 635 | |
| 636 | } catch(Exception e){ |
| 637 | new ErrorDialog(getString(R.string.error), e.getMessage(), MITM.this).show(); |
| 638 | } |
| 639 | } else |
| 640 | new ErrorDialog(getString(R.string.error), getString(R.string.error_invalid_address_or_port), MITM.this).show(); |
| 641 | } |
| 642 | }).show(); |
| 643 | } else |
| 644 | setStoppedState(); |
nothing calls this directly
no test coverage detected