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 send_device_info #181

Merged
merged 2 commits into from
Sep 7, 2023
Merged

Add send_device_info #181

merged 2 commits into from
Sep 7, 2023

Conversation

dongri
Copy link
Contributor

@dongri dongri commented Aug 28, 2023

Send device info to hub

@dongri dongri requested a review from a team as a code owner August 28, 2023 07:21
src/main.rs Outdated
Comment on lines 334 to 335
Ok(None) => String::from("No MAC address found."),
Err(_) => String::from("No MAC address found."),
Copy link
Contributor

Choose a reason for hiding this comment

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

nits

Suggested change
Ok(None) => String::from("No MAC address found."),
Err(_) => String::from("No MAC address found."),
_ => String::from("No MAC address found."),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, Thanks!
c0b716c

src/main.rs Outdated
const OS: &str = env::consts::OS;
let mac_address: String = match get_mac_address() {
Ok(Some(ma)) => ma.to_string(),
Ok(None) => String::from("No MAC address found."),
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO
This code If no mac address registered, the above message is inserted into the Hub instead.
But, I think that if Agent has no mac address, Agent can't connect to Hub.
So I think if Agent can't find the MAC address, we should shutdown the Agent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the mac address is additional information since it is used for the log display screen. It is not a required field, so it is better to be able to communicate even if it cannot be obtained.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is not a required field, so it is better to be able to communicate even if it cannot be obtained.

I think so too. But, I think that the device that has no MAC address can't connect to the Hub over IP.
Are there situations where the device can communicate via IP in the absence of a MAC address?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there would be no communication with devices that do not have a MAC address.

Copy link
Contributor

@rabe1028 rabe1028 Sep 6, 2023

Choose a reason for hiding this comment

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

I think there would be no communication with devices that do not have a MAC address.

I think so too.
So, I think the message, "No MAC address found." can't be sent to Hub.

async fn send_device_info(did: String) {
const VERSION: &str = env!("CARGO_PKG_VERSION");
const OS: &str = env::consts::OS;
let mac_address: String = match get_mac_address() {
Copy link
Contributor

Choose a reason for hiding this comment

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

MUST
Following this code, get_mac_address() returns the first MAC address.
https://github.com/repnop/mac_address/blob/master/src/lib.rs#L107C5-L107C5
So if the machine has multiple NICs, it may return a different address that doesn't connect to the Hub.
Is this the desired behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Certainly getting the first one with the OS command when there are multiple NICs is a problem, but is there any other better way?

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no simple solution, but, there may be some solutions like the following page.
https://qiita.com/saiton03/items/e23b308cc2b8e4ebd66d

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What happens if I have one domain and multiple IP addresses?

Maybe this time, the purpose is not to know which network interface was used to make the connection, but to get the mac address to identify the terminal, so I think it is OK as long as it is unique.

Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if I have one domain and multiple IP addresses?

DNS will return one IP address randomly. This occurs, for example, with DNS round robin.
If the device has multiple NICs, and the server uses DNS round-robin, the MAC address may switched randomly.

Maybe this time, the purpose is not to know which network interface was used to make the connection, but to get the mac address to identify the terminal, so I think it is OK as long as it is unique.

OK, I understood.

@dongri dongri requested a review from rabe1028 September 2, 2023 11:10
Copy link
Contributor

@rabe1028 rabe1028 left a comment

Choose a reason for hiding this comment

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

I left some comments, but I think that it will be a major issue.
LGTM

@dongri dongri merged commit 3709a9a into develop Sep 7, 2023
5 checks passed
@rabe1028 rabe1028 mentioned this pull request Oct 8, 2023
@rabe1028 rabe1028 deleted the get-device-info branch February 5, 2024 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants