예제 #1
0
        public static string BuildCommandLine(PuTTYSessionInfo profileInfo)
        {
            var command = string.Empty;

            // Protocol
            switch (profileInfo.Mode)
            {
            case ConnectionMode.SSH:
                command += "-ssh";
                break;

            case ConnectionMode.Telnet:
                command += "-telnet";
                break;

            case ConnectionMode.Serial:
                command += "-serial";
                break;

            case ConnectionMode.Rlogin:
                command += "-rlogin";
                break;

            case ConnectionMode.RAW:
                command += "-raw";
                break;
            }

            // Profile
            if (!string.IsNullOrEmpty(profileInfo.Profile))
            {
                command += $" -load {'"'}{profileInfo.Profile}{'"'}";
            }

            // Username
            if (!string.IsNullOrEmpty(profileInfo.Username))
            {
                command += $" -l {profileInfo.Username}";
            }

            // Additional commands
            if (!string.IsNullOrEmpty(profileInfo.AdditionalCommandLine))
            {
                command += $" {profileInfo.AdditionalCommandLine}";
            }

            // SerialLine, Baud
            if (profileInfo.Mode == ConnectionMode.Serial)
            {
                command += $" {profileInfo.HostOrSerialLine} -sercfg {profileInfo.PortOrBaud}";
            }

            // Port, Host
            if (profileInfo.Mode != ConnectionMode.Serial)
            {
                command += $" -P {profileInfo.PortOrBaud} {profileInfo.HostOrSerialLine}";
            }

            return(command);
        }
예제 #2
0
        public static PuTTYSessionInfo Parse(Settings.PuTTYSessionInfo sessionInfo)
        {
            PuTTYSessionInfo info = new PuTTYSessionInfo();

            info.HostOrSerialLine      = sessionInfo.HostOrSerialLine;
            info.PortOrBaud            = sessionInfo.PortOrBaud;
            info.Mode                  = sessionInfo.ConnectionMode;
            info.Username              = sessionInfo.Username;
            info.Profile               = sessionInfo.Profile;
            info.AdditionalCommandLine = sessionInfo.AdditionalCommandLine;

            return(info);
        }
예제 #3
0
        public static PuTTYSessionInfo Parse(ProfileInfo profileInfo)
        {
            var info = new PuTTYSessionInfo
            {
                Mode                  = profileInfo.PuTTY_ConnectionMode,
                HostOrSerialLine      = profileInfo.PuTTY_HostOrSerialLine,
                PortOrBaud            = profileInfo.PuTTY_OverridePortOrBaud ? profileInfo.PuTTY_PortOrBaud : GetPortOrBaudByConnectionMode(profileInfo.PuTTY_ConnectionMode),
                Username              = profileInfo.PuTTY_OverrideUsername ? profileInfo.PuTTY_Username : SettingsManager.Current.PuTTY_Username,
                Profile               = profileInfo.PuTTY_OverrideProfile ? profileInfo.PuTTY_Profile : SettingsManager.Current.PuTTY_Profile,
                AdditionalCommandLine = profileInfo.PuTTY_OverrideAdditionalCommandLine ? profileInfo.PuTTY_AdditionalCommandLine : SettingsManager.Current.PuTTY_AdditionalCommandLine
            };

            return(info);
        }
예제 #4
0
        public static PuTTYSessionInfo Parse(ProfileInfo profileInfo)
        {
            var info = new PuTTYSessionInfo
            {
                HostOrSerialLine      = profileInfo.PuTTY_HostOrSerialLine,
                PortOrBaud            = profileInfo.PuTTY_PortOrBaud,
                Mode                  = profileInfo.PuTTY_ConnectionMode,
                Username              = profileInfo.PuTTY_Username,
                Profile               = profileInfo.PuTTY_Profile,
                AdditionalCommandLine = profileInfo.PuTTY_AdditionalCommandLine
            };

            return(info);
        }
예제 #5
0
        public static string BuildCommandLine(PuTTYSessionInfo profileInfo)
        {
            var command = string.Empty;

            // Protocol
            switch (profileInfo.Mode)
            {
            case ConnectionMode.SSH:
                command += "-ssh";
                break;

            case ConnectionMode.Telnet:
                command += "-telnet";
                break;

            case ConnectionMode.Serial:
                command += "-serial";
                break;

            case ConnectionMode.Rlogin:
                command += "-rlogin";
                break;

            case ConnectionMode.RAW:
                command += "-raw";
                break;
            }

            // Profile
            if (!string.IsNullOrEmpty(profileInfo.Profile))
            {
                command += $" -load {'"'}{profileInfo.Profile}{'"'}";
            }

            // Username
            if (!string.IsNullOrEmpty(profileInfo.Username))
            {
                command += $" -l {profileInfo.Username}";
            }

            // Log
            if (profileInfo.EnableLog)
            {
                switch (profileInfo.LogMode)
                {
                case LogMode.SessionLog:
                    command += $" -sessionlog";
                    break;

                case LogMode.SSHLog:
                    command += $" -sshlog";
                    break;

                case LogMode.SSHRawLog:
                    command += $" -sshrawlog";
                    break;
                }

                command += $" {'"'}{ Environment.ExpandEnvironmentVariables(Path.Combine(profileInfo.LogPath, profileInfo.LogFileName))}{'"'}";
            }

            // Additional commands
            if (!string.IsNullOrEmpty(profileInfo.AdditionalCommandLine))
            {
                command += $" {profileInfo.AdditionalCommandLine}";
            }

            // SerialLine, Baud
            if (profileInfo.Mode == ConnectionMode.Serial)
            {
                command += $" {profileInfo.HostOrSerialLine} -sercfg {profileInfo.PortOrBaud}";
            }

            // Port, Host
            if (profileInfo.Mode != ConnectionMode.Serial)
            {
                command += $" -P {profileInfo.PortOrBaud} {profileInfo.HostOrSerialLine}";
            }

            return(command);
        }