コード例 #1
0
        public new void Load()
        {
            // Try to load, and save a new file if load failed
            if (!base.Load())
            {
                base.Save();
            }

            RMLog.Level = LogLevel;

            // Output the settings being used
            RMLog.Info("Using settings from " + base.FileName);
            RMLog.Info("-Listen port...." + ListenPort.ToString());
            if (TargetPort > 0)
            {
                RMLog.Info("-Telnet target.." + TargetHostname + ":" + TargetPort.ToString());
            }
            else
            {
                RMLog.Info("-Telnet target..DISABLED");
            }
            if (RLoginPort > 0)
            {
                RMLog.Info("-RLogin target.." + TargetHostname + ":" + RLoginPort.ToString());
            }
            else
            {
                RMLog.Info("-RLogin target..DISABLED");
            }
            RMLog.Info("-Log level......" + LogLevel.ToString());
            if (CertificateFilename != "")
            {
                // If file doesn't exist, and it's relative, convert to absolute
                if (!File.Exists(CertificateFilename) && !Path.IsPathRooted(CertificateFilename))
                {
                    CertificateFilename = StringUtils.PathCombine(ProcessUtils.StartupPath, CertificateFilename);
                }

                if (File.Exists(CertificateFilename))
                {
                    RMLog.Info("-Cert file......" + CertificateFilename);
                    if (CertificatePassword == "")
                    {
                        RMLog.Info("-Cert password..none");
                    }
                    else
                    {
                        RMLog.Info("-Cert password..yes (hidden)");
                    }
                }
                else
                {
                    RMLog.Error("-Cert file not found: '" + CertificateFilename + "'");
                    CertificateFilename = "";
                }
            }
            if (RelayFilename != "")
            {
                // If file doesn't exist, and it's relative, convert to absolute
                if (!File.Exists(RelayFilename) && !Path.IsPathRooted(RelayFilename))
                {
                    RelayFilename = StringUtils.PathCombine(ProcessUtils.StartupPath, RelayFilename);
                }

                if (File.Exists(RelayFilename))
                {
                    RMLog.Info("-Relay file....." + RelayFilename);
                }
                else
                {
                    RMLog.Error("-Relay file not found: '" + RelayFilename + "'");
                    RelayFilename = "";
                }
            }
        }
コード例 #2
0
ファイル: Config.cs プロジェクト: rickparrish/fTelnetProxy
        public new void Load()
        {
            // Try to load, and save a new file if load failed
            if (!base.Load())
            {
                base.Save();
            }

            RMLog.Level = LogLevel;

            // Output the settings being used
            RMLog.Info("Using settings from " + base.FileName);
            RMLog.Info("-Listen port: " + ListenPort.ToString());
            if (TargetPort > 0)
            {
                RMLog.Info("-Telnet target: " + TargetHostname + ":" + TargetPort.ToString());
            }
            else
            {
                RMLog.Info("-Telnet target: DISABLED");
            }
            if (RLoginPort > 0)
            {
                RMLog.Info("-RLogin target: " + TargetHostname + ":" + RLoginPort.ToString());
            }
            else
            {
                RMLog.Info("-RLogin target: DISABLED");
            }
            RMLog.Info("-Log level: " + LogLevel.ToString());
            if (!string.IsNullOrWhiteSpace(CertificateFilename))
            {
                // If file doesn't exist, and it's relative, convert to absolute
                if (!File.Exists(CertificateFilename) && !Path.IsPathRooted(CertificateFilename))
                {
                    CertificateFilename = StringUtils.PathCombine(ProcessUtils.StartupPath, CertificateFilename);
                }

                if (File.Exists(CertificateFilename))
                {
                    RMLog.Info("-Cert file: " + CertificateFilename);
                    if (string.IsNullOrWhiteSpace(CertificatePassword))
                    {
                        RMLog.Info("-Cert password: none");
                    }
                    else
                    {
                        RMLog.Info("-Cert password: yes (hidden)");
                    }
                }
                else
                {
                    RMLog.Error("-Cert file not found: '" + CertificateFilename + "'");
                    CertificateFilename = "";
                }
            }
            if (!string.IsNullOrWhiteSpace(User) && OSUtils.IsUnix)
            {
                RMLog.Info($"-Run as user: '******'");
            }
            if (!string.IsNullOrWhiteSpace(RelayFilename))
            {
                // If file doesn't exist, and it's relative, convert to absolute
                if (!File.Exists(RelayFilename) && !Path.IsPathRooted(RelayFilename))
                {
                    RelayFilename = StringUtils.PathCombine(ProcessUtils.StartupPath, RelayFilename);
                }

                if (File.Exists(RelayFilename))
                {
                    RMLog.Info("-Relay file: " + RelayFilename);
                }
                else
                {
                    RMLog.Error("-Relay file not found: '" + RelayFilename + "'");
                    RelayFilename = "";
                }
            }
            if (!string.IsNullOrWhiteSpace(RelayDeniedFilename))
            {
                // If file doesn't exist, and it's relative, convert to absolute
                if (!File.Exists(RelayDeniedFilename) && !Path.IsPathRooted(RelayDeniedFilename))
                {
                    RelayDeniedFilename = StringUtils.PathCombine(ProcessUtils.StartupPath, RelayDeniedFilename);
                }

                if (File.Exists(RelayDeniedFilename))
                {
                    RMLog.Info("-Relay denied file: " + RelayDeniedFilename);
                }
                else
                {
                    RMLog.Error("-Relay denied file not found: '" + RelayDeniedFilename + "'");
                    RelayDeniedFilename = "";
                }
            }
            if (MaxIdleTimeInMinutes > 0)
            {
                RMLog.Info($"-Max idle time before disconnecting: {MaxIdleTimeInMinutes} minutes");
            }
            else
            {
                RMLog.Info("-Max idle time before disconnecting: DISABLED");
            }
            if (MaxSessionLengthInHours > 0)
            {
                RMLog.Info($"-Max session length before disconnecting: {MaxSessionLengthInHours} hours");
            }
            else
            {
                RMLog.Info("-Max session length before disconnecting: DISABLED");
            }
        }