Skip to content

Commit

Permalink
fix: getIpFamily not detecting IPv6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
michelkaporin committed Dec 24, 2021
1 parent e50e6f4 commit c544dc2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const NETWORK_ERRORS = {
ECONNRESET: ErrorCodes.connectionRefused,
ENETUNREACH: ErrorCodes.connectionRefused,
ENOTFOUND: ErrorCodes.dnsNotFound,
EADDRNOTAVAIL: ErrorCodes.dnsNotFound, // happens when DNS cannot resolve the IPv6
};

export const DEFAULT_ERROR_MESSAGES: { [P in ErrorCodes]: string } = {
Expand Down
7 changes: 5 additions & 2 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ErrorCodes, GenericErrorTypes, DEFAULT_ERROR_MESSAGES, MAX_RETRY_ATTEMP

import { BundleFiles, SupportedFiles } from './interfaces/files.interface';
import { AnalysisResult } from './interfaces/analysis-result.interface';
import { makeRequest, Payload } from './needle';
import { FailedResponse, makeRequest, Payload } from './needle';
import { AnalysisOptions, AnalysisContext } from './interfaces/analysis-options.interface';

type ResultSuccess<T> = { type: 'success'; value: T };
Expand Down Expand Up @@ -99,7 +99,10 @@ export async function getIpFamily(authHost: string): Promise<IpFamily> {
},
0,
);
return res.success ? family : undefined;

const ipv6Incompatible = (<FailedResponse>res).errorCode == ErrorCodes.dnsNotFound;

return ipv6Incompatible ? undefined : family;
}

type CheckSessionErrorCodes = GenericErrorTypes | ErrorCodes.unauthorizedUser | ErrorCodes.loginInProgress;
Expand Down
2 changes: 1 addition & 1 deletion src/needle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface SuccessResponse<T> {
success: true;
body: T;
}
type FailedResponse = {
export type FailedResponse = {
success: false;
errorCode: number;
};
Expand Down

0 comments on commit c544dc2

Please sign in to comment.