Exemple #1
0
        public static DeviceInfo[] ListDevices(out bool isRemote, out string serverApplication,
                                               out string serverVersion, out string serverOperatingSystem,
                                               out string serverOperatingSystemVersion, out string serverArchitecture,
                                               string aaruRemote = null)
        {
            isRemote                     = false;
            serverApplication            = null;
            serverVersion                = null;
            serverOperatingSystem        = null;
            serverOperatingSystemVersion = null;
            serverArchitecture           = null;

            if (aaruRemote is null)
            {
                switch (DetectOS.GetRealPlatformID())
                {
                case PlatformID.Win32NT: return(Windows.ListDevices.GetList());

                case PlatformID.Linux:   return(Linux.ListDevices.GetList());

                case PlatformID.FreeBSD: return(FreeBSD.ListDevices.GetList());

                default:
                    throw new
                          InvalidOperationException($"Platform {DetectOS.GetRealPlatformID()} not yet supported.");
                }
            }

            try
            {
                var aaruUri = new Uri(aaruRemote);

                if (aaruUri.Scheme != "aaru" &&
                    aaruUri.Scheme != "dic")
                {
                    AaruConsole.ErrorWriteLine("Invalid remote URI.");

                    return(new DeviceInfo[0]);
                }

                using var remote = new Remote.Remote(aaruUri);

                isRemote                     = true;
                serverApplication            = remote.ServerApplication;
                serverVersion                = remote.ServerVersion;
                serverOperatingSystem        = remote.ServerOperatingSystem;
                serverOperatingSystemVersion = remote.ServerOperatingSystemVersion;
                serverArchitecture           = remote.ServerArchitecture;

                return(remote.ListDevices());
            }
            catch (Exception)
            {
                AaruConsole.ErrorWriteLine("Error connecting to host.");

                return(new DeviceInfo[0]);
            }
        }
Exemple #2
0
        public static DeviceInfo[] ListDevices(out bool isRemote, out string serverApplication,
                                               out string serverVersion, out string serverOperatingSystem,
                                               out string serverOperatingSystemVersion, out string serverArchitecture,
                                               string aaruRemote = null)
        {
            isRemote                     = false;
            serverApplication            = null;
            serverVersion                = null;
            serverOperatingSystem        = null;
            serverOperatingSystemVersion = null;
            serverArchitecture           = null;

            if (aaruRemote is null)
            {
                switch (DetectOS.GetRealPlatformID())
                {
                case PlatformID.Win32NT: return(Windows.ListDevices.GetList());

                case PlatformID.Linux:   return(Linux.ListDevices.GetList());

                case PlatformID.FreeBSD: return(FreeBSD.ListDevices.GetList());

                default:
                    throw new
                          InvalidOperationException($"Platform {DetectOS.GetRealPlatformID()} not yet supported.");
                }
            }

            try
            {
                if (aaruRemote.ToLowerInvariant().StartsWith("aaru://"))
                {
                    aaruRemote = aaruRemote.Substring(7);
                }

                using (var remote = new Remote.Remote(aaruRemote))
                {
                    isRemote                     = true;
                    serverApplication            = remote.ServerApplication;
                    serverVersion                = remote.ServerVersion;
                    serverOperatingSystem        = remote.ServerOperatingSystem;
                    serverOperatingSystemVersion = remote.ServerOperatingSystemVersion;
                    serverArchitecture           = remote.ServerArchitecture;

                    return(remote.ListDevices());
                }
            }
            catch (Exception)
            {
                AaruConsole.ErrorWriteLine("Error connecting to host.");

                return(new DeviceInfo[0]);
            }
        }