@@ -3,7 +3,7 @@ use std::{num::NonZeroU64, path::PathBuf, str::FromStr};
3
3
use serde:: { de, Deserialize , Deserializer , Serialize } ;
4
4
use smart_default:: SmartDefault ;
5
5
use std:: fs;
6
- use tracing:: { debug, info, level_filters:: LevelFilter } ;
6
+ use tracing:: { debug, info, level_filters:: LevelFilter , warn } ;
7
7
use uuid:: Uuid ;
8
8
9
9
use telio:: crypto:: SecretKey ;
@@ -57,26 +57,30 @@ fn reconnect_after_expiry_default() -> Percentage {
57
57
58
58
#[ derive( Serialize , Deserialize , Debug , Default ) ]
59
59
pub struct DeviceIdentity {
60
- pub hw_identifier : String ,
60
+ pub hw_identifier : Uuid ,
61
61
pub private_key : SecretKey ,
62
62
pub machine_identifier : String ,
63
63
}
64
64
65
- pub fn generate_hw_identifier ( private_key : SecretKey ) -> String {
65
+ pub fn generate_hw_identifier ( ) -> Uuid {
66
66
// Generate hw_identifier
67
- let public_key = private_key. public ( ) ;
68
- debug ! ( "Generating hw identifier" ) ;
69
- format ! ( "{}.{}" , public_key, "teliod" )
67
+ debug ! ( "Generating a new hw identifier" ) ;
68
+ Uuid :: new_v4 ( )
70
69
}
71
70
72
71
impl DeviceIdentity {
73
72
pub fn from_file ( identity_path : & PathBuf ) -> Option < DeviceIdentity > {
74
- info ! ( "Fetching config" ) ;
73
+ info ! ( "Fetching identity config" ) ;
75
74
76
75
if let Ok ( file) = fs:: File :: open ( identity_path) {
77
- debug ! ( "found existing config." ) ;
76
+ debug ! (
77
+ "Found existing identity config {}" ,
78
+ identity_path. to_string_lossy( )
79
+ ) ;
78
80
if let Ok ( c) = serde_json:: from_reader ( file) {
79
81
return Some ( c) ;
82
+ } else {
83
+ warn ! ( "Reading identity config failed" ) ;
80
84
}
81
85
}
82
86
None
@@ -90,8 +94,6 @@ pub struct TeliodDaemonConfig {
90
94
pub log_file_path : String ,
91
95
pub interface : InterfaceConfig ,
92
96
93
- pub app_user_uid : Uuid ,
94
-
95
97
#[ serde( deserialize_with = "deserialize_authentication_token" ) ]
96
98
pub authentication_token : String ,
97
99
@@ -163,7 +165,6 @@ mod tests {
163
165
let expected = TeliodDaemonConfig {
164
166
log_level : LevelFilter :: INFO ,
165
167
log_file_path : "test.log" . to_owned ( ) ,
166
- app_user_uid : Uuid :: from_str ( "2ba97921-38d7-4736-9d47-261cf3e5c223" ) . unwrap ( ) ,
167
168
interface : InterfaceConfig {
168
169
name : "utun10" . to_owned ( ) ,
169
170
config_provider : InterfaceConfigurationProvider :: Manual ,
@@ -183,7 +184,6 @@ mod tests {
183
184
let json = r#"{
184
185
"log_level": "Info",
185
186
"log_file_path": "test.log",
186
- "app_user_uid": "2ba97921-38d7-4736-9d47-261cf3e5c223",
187
187
"interface": {
188
188
"name": "utun10",
189
189
"config_provider": "manual"
@@ -198,7 +198,6 @@ mod tests {
198
198
let json = r#"{
199
199
"log_level": "Info",
200
200
"log_file_path": "test.log",
201
- "app_user_uid": "2ba97921-38d7-4736-9d47-261cf3e5c223",
202
201
"interface": {
203
202
"name": "utun10",
204
203
"config_provider": "manual"
0 commit comments