Skip to content

Commit

Permalink
Enable OneBox hostnames that include the port (#417)
Browse files Browse the repository at this point in the history
* Enable OneBox hostnames that include the port

* Add null check

* Since apparently org.apache.commons.lang3.StringUtils is being removed, use com.azure.core.util.CoreUtils instead
  • Loading branch information
yihezkel authored Feb 12, 2025
1 parent 945e8e5 commit 56e0446
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package com.microsoft.azure.kusto.ingest;

import com.azure.core.util.CoreUtils;
import com.microsoft.azure.kusto.data.exceptions.ExceptionUtils;
import com.microsoft.azure.kusto.ingest.source.CompressionType;
import org.apache.http.conn.util.InetAddressUtils;

import java.io.IOException;
import java.net.URI;
import com.microsoft.azure.kusto.data.instrumentation.MonitoredActivity;
import com.microsoft.azure.kusto.data.instrumentation.SupplierTwoExceptions;
import com.microsoft.azure.kusto.data.instrumentation.TraceableAttributes;
import com.microsoft.azure.kusto.data.instrumentation.MonitoredActivity;
import com.microsoft.azure.kusto.ingest.exceptions.IngestionClientException;
import com.microsoft.azure.kusto.ingest.exceptions.IngestionServiceException;
import com.microsoft.azure.kusto.ingest.result.IngestionResult;
import com.microsoft.azure.kusto.ingest.source.*;
import org.apache.http.conn.util.InetAddressUtils;

import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -46,17 +45,17 @@ static boolean isReservedHostname(String rawUri) {
}

String authority = uri.getAuthority().toLowerCase();
boolean isIPFlag;
boolean isIpAddress;
if (authority.startsWith("[") && authority.endsWith("]")) {
authority = authority.substring(1, authority.length() - 1);
isIPFlag = true;
isIpAddress = true;
} else {
isIPFlag = InetAddressUtils.isIPv4Address(authority);
isIpAddress = InetAddressUtils.isIPv4Address(authority);
}

boolean isLocalFlag = authority.contains("localhost");
boolean isLocalhost = authority.contains("localhost");
String host = CoreUtils.isNullOrEmpty(uri.getHost()) ? "" : uri.getHost();

return isLocalFlag || isIPFlag || authority.equalsIgnoreCase("onebox.dev.kusto.windows.net");
return isLocalhost || isIpAddress || host.equalsIgnoreCase("onebox.dev.kusto.windows.net");
}

protected abstract IngestionResult ingestFromFileImpl(FileSourceInfo fileSourceInfo, IngestionProperties ingestionProperties)
Expand Down

0 comments on commit 56e0446

Please sign in to comment.