Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic IPv6 support. #67

Merged
merged 5 commits into from
Jan 25, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/builder/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ factory.isPlatformSupport = function (p) {
* @return {object} - Argument builder
* @throw if given platform is not supported
*/
factory.getExecutablePath = function (platform) {
factory.getExecutablePath = function (platform, v6) {
if (!this.isPlatformSupport(platform)) {
throw new Error(util.format('Platform |%s| is not support', platform));
}
Expand All @@ -74,11 +74,11 @@ factory.getExecutablePath = function (platform) {
if (platform === 'aix') {
ret = '/usr/sbin/ping';
} else if (factory.isLinux(platform)) {
ret = '/bin/ping';
ret = v6 ? '/sbin/ping6' : '/bin/ping';
} else if (factory.isWindow(platform)) {
ret = process.env.SystemRoot + '/system32/ping.exe';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering whether we should support the '-6' for windows command, per docs: https://ss64.com/nt/ping.html
BTW I don't have access to to Windows machine to validate this behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we probably should. I can test on Windows. I'll make the code force either IPv4 or IPv6.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(done, on merge we should squash with the latest commit)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, how to create a message box with review icon like this? Any button in github UI for doing this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mondwan click "Files changed" at the top, then hover over the line number and click when you want to add a line-specific comment. :)

} else if (factory.isMacOS(platform)) {
ret = '/sbin/ping';
ret = v6 ? '/sbin/ping6' : '/sbin/ping';
}

return ret;
Expand Down
2 changes: 1 addition & 1 deletion lib/builder/mac.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ builder.getResult = function (target, config) {
ret.push('-n');
}

if (_config.timeout) {
if (_config.timeout && !_config.v6) {
ret = ret.concat([
'-t',
util.format('%d', _config.timeout),
Expand Down
2 changes: 1 addition & 1 deletion lib/ping-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function probe(addr, config) {
var platform = os.platform();
var argumentBuilder = builderFactory.createBuilder(platform);
ping = cp.spawn(
builderFactory.getExecutablePath(platform),
builderFactory.getExecutablePath(platform, config.v6),
argumentBuilder.getResult(addr, _config)
);

Expand Down