File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,10 @@ authors.workspace = true
66edition.workspace = true
77license-file.workspace = true
88
9- [target .'cfg(windows)' .dependencies ]
9+ [target .'cfg(target_os = "macos")' .dependencies ]
10+ uuid.workspace = true
11+
12+ [target .'cfg(target_os = "windows")' .dependencies ]
1013uuid.workspace = true
1114windows = { version = " 0.60" , features = [" System_Profile" ] }
1215
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ const BUF_SIZE: usize = 25;
55
66#[ cfg( target_os = "linux" ) ]
77mod linux;
8+ #[ cfg( target_os = "macos" ) ]
9+ mod macos;
810#[ cfg( target_os = "windows" ) ]
911mod windows;
1012
Original file line number Diff line number Diff line change 1+ use std:: process:: Command ;
2+
3+ use uuid:: Uuid ;
4+
5+ impl crate :: Fingerprint {
6+ pub fn new ( ) -> Option < Self > {
7+ Command :: new ( "ioreg" )
8+ . arg ( "-d2" )
9+ . arg ( "-c" )
10+ . arg ( "IOPlatformExpertDevice" )
11+ . output ( )
12+ . ok ( )
13+ . and_then ( |out| String :: from_utf8 ( out. stdout ) . ok ( ) )
14+ . and_then ( |output| {
15+ for line in output. lines ( ) {
16+ if let Some ( ( _, uuid) ) = line. split_once ( r#""IOPlatformUUID" = ""# ) {
17+ if let Some ( ( uuid, _) ) = uuid. split_once ( '"' ) {
18+ return Uuid :: parse_str ( uuid) . ok ( ) ;
19+ }
20+ }
21+ }
22+ None
23+ } )
24+ . map ( |uuid| uuid. as_u128 ( ) )
25+ . map ( Self )
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments