requestRouteToHost of URL rather than MMSC on MMS Download

// FREEBIE

Closes #1806
This commit is contained in:
Moxie Marlinspike 2014-08-12 16:07:09 -07:00
parent feabbb33d2
commit 7b0479ff0f
2 changed files with 27 additions and 35 deletions

View File

@ -82,25 +82,20 @@ public class MmsDownloadHelper extends MmsCommunication {
byte[] pdu = null; byte[] pdu = null;
for (MmsConnectionParameters.Apn param : connectionParameters.get()) { for (MmsConnectionParameters.Apn param : connectionParameters.get()) {
String proxy = null; try {
int proxyPort = 80; if (proxyIfPossible && param.hasProxy()) {
boolean hasRoute; if (checkRouteToHost(context, param.getProxy(), usingMmsRadio)) {
pdu = makeRequest(context, url, param.getProxy(), param.getPort());
if (proxyIfPossible && param.hasProxy()) { }
proxy = param.getProxy(); } else {
proxyPort = param.getPort(); if (checkRouteToHost(context, Uri.parse(url).getHost(), usingMmsRadio)) {
hasRoute = checkRouteToHost(context, proxy, usingMmsRadio); pdu = makeRequest(context, url, null, -1);
} else { }
hasRoute = checkRouteToHost(context, Uri.parse(param.getMmsc()).getHost(), usingMmsRadio);
}
if (hasRoute) {
try {
pdu = makeRequest(context, url, proxy, proxyPort);
} catch(IOException e) {
Log.w("MmsDownloadHelper", "Request failed: "+e.getMessage());
} }
if (pdu != null) break; if (pdu != null) break;
} catch (IOException ioe) {
Log.w("MmsDownloadHelper", ioe);
} }
} }

View File

@ -101,28 +101,25 @@ public class MmsSendHelper extends MmsCommunication {
Log.w(TAG, "Sending MMS of length: " + mms.length); Log.w(TAG, "Sending MMS of length: " + mms.length);
try { try {
MmsConnectionParameters parameters = getMmsConnectionParameters(context, apn); MmsConnectionParameters parameters = getMmsConnectionParameters(context, apn);
for (MmsConnectionParameters.Apn param : parameters.get()) { for (MmsConnectionParameters.Apn param : parameters.get()) {
String proxy = null; try {
int proxyPort = 80; if (useProxyIfAvailable && param.hasProxy()) {
boolean hasRoute; if (checkRouteToHost(context, param.getProxy(), usingMmsRadio)) {
byte[] response = makePost(context, param.getMmsc(), param.getProxy(), param.getPort(), mms);
if(useProxyIfAvailable && param.hasProxy()){ if (response != null) return response;
proxy = param.getProxy(); }
proxyPort = param.getPort(); } else {
hasRoute = checkRouteToHost(context, proxy, usingMmsRadio); if (checkRouteToHost(context, Uri.parse(param.getMmsc()).getHost(), usingMmsRadio)) {
} else { byte[] response = makePost(context, param.getMmsc(), null, -1, mms);
hasRoute = checkRouteToHost(context, Uri.parse(param.getMmsc()).getHost(), usingMmsRadio); if (response != null) return response;
} }
if (hasRoute) {
try {
byte[] response = makePost(context, param.getMmsc(), proxy, proxyPort, mms);
if (response != null) return response;
} catch(IOException e) {
Log.w("MmsSendHelper", "Request failed: "+e.getMessage());
} }
} catch (IOException ioe) {
Log.w(TAG, ioe);
} }
} }
throw new IOException("Connection manager could not obtain route to host."); throw new IOException("Connection manager could not obtain route to host.");
} catch (ApnUnavailableException aue) { } catch (ApnUnavailableException aue) {
Log.w(TAG, aue); Log.w(TAG, aue);