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

Fingerprint: config parameter for interface and native method for IP address #189

Merged
merged 7 commits into from
Oct 2, 2015
Merged

Fingerprint: config parameter for interface and native method for IP address #189

merged 7 commits into from
Oct 2, 2015

Conversation

apognu
Copy link
Contributor

@apognu apognu commented Oct 1, 2015

This PR tries to respond to #170 and #158.

I added a configuration directive to the client conf file to set the network interface used for fingerprinting.

client {
  iface = "enp2s0"
}

It also adds a second method for retrieving the IP address of this network card (before we try ifconfig) using net.Interfaces(). This is not perfect yet since I totally ignore IPv6 addresses, but it's a base to develop from.

// ipAddress returns the first IPv4 address on the configured default interface
// Tries Golang native functions and falls back onto ifconfig
func (f *NetworkFingerprint) ipAddress(device string) string {
if ip, err := f.nativeIpAddress(device); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't that be err != nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, no, that function should return the IP if there was no error, so if err == nil. Look at the if body.

If err is different than nil, its execution continues, and we would try the ifconfig method.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I see. Thanks.

@@ -31,6 +31,9 @@ type Config struct {
// Region is the clients region
Region string

// Network interface to be used in network fingerprinting
Iface string
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets change Iface to "NetworkInterface" for long term clarity both in code and docs. After that lets merge! Thanks

dadgar added a commit that referenced this pull request Oct 2, 2015
Fingerprint: config parameter for interface and native method for IP address
@dadgar dadgar merged commit e943746 into hashicorp:master Oct 2, 2015
benbuzbee pushed a commit to benbuzbee/nomad that referenced this pull request Jul 21, 2022
@github-actions
Copy link

github-actions bot commented May 9, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants