Пример #1
0
        public static int StartDaemon(ClientInfo clientInfo)
        {
            IOStream stream  = clientInfo.IoStream;
            Options  options = clientInfo.Options;

            options.amDaemon = true;

            stream.IOPrintf("@RSYNCD: " + options.protocolVersion + "\n");
            string line = stream.ReadLine();

            try
            {
                options.remoteProtocol = Int32.Parse(line.Substring(9, 2));
            }
            catch
            {
                options.remoteProtocol = 0;
            }
            bool isValidstring = line.StartsWith("@RSYNCD: ") && line.EndsWith("\n") && options.remoteProtocol > 0;

            if (!isValidstring)
            {
                stream.IOPrintf("@ERROR: protocol startup error\n");
                return(-1);
            }
            if (options.protocolVersion > options.remoteProtocol)
            {
                options.protocolVersion = options.remoteProtocol;
            }
            line = stream.ReadLine();
            if (line.CompareTo("#list\n") == 0)
            {
                ClientServer.SendListing(stream);
                return(-1);
            }

            if (line[0] == '#')
            {
                stream.IOPrintf("@ERROR: Unknown command '" + line.Replace("\n", String.Empty) + "'\n");
                return(-1);
            }

            int i = config.GetNumberModule(line.Replace("\n", String.Empty));

            if (i < 0)
            {
                stream.IOPrintf("@ERROR: Unknown module " + line);
                MainClass.Exit("@ERROR: Unknown module " + line, clientInfo);
            }
            options.doStats  = true;
            options.ModuleId = i;
            ClientServer.RsyncModule(clientInfo, i);
            clientInfo.IoStream.Close();
            return(1);
        }
Пример #2
0
        public static int StartDaemon(ClientInfo clientInfo)
        {
            var stream  = clientInfo.IoStream;
            var options = clientInfo.Options;

            options.AmDaemon = true;

            stream.IoPrintf("@RSYNCD: " + options.ProtocolVersion + "\n");
            var line = stream.ReadLine();

            try
            {
                options.RemoteProtocol = Int32.Parse(line.Substring(9, 2));
            }
            catch
            {
                options.RemoteProtocol = 0;
            }
            var isValidstring = line.StartsWith("@RSYNCD: ") && line.EndsWith("\n") && options.RemoteProtocol > 0;

            if (!isValidstring)
            {
                stream.IoPrintf("@ERROR: protocol startup error\n");
                return(-1);
            }
            if (options.ProtocolVersion > options.RemoteProtocol)
            {
                options.ProtocolVersion = options.RemoteProtocol;
            }
            line = stream.ReadLine();
            if (String.Compare(line, "#list\n", StringComparison.Ordinal) == 0)
            {
                ClientServer.SendListing(stream);
                return(-1);
            }

            if (line[0] == '#')
            {
                stream.IoPrintf("@ERROR: Unknown command '" + line.Replace("\n", String.Empty) + "'\n");
                return(-1);
            }

            var i = Config.GetNumberModule(line.Replace("\n", String.Empty));

            if (i < 0)
            {
                stream.IoPrintf("@ERROR: Unknown module " + line);
                WinRsync.Exit("@ERROR: Unknown module " + line, clientInfo);
            }
            options.DoStats  = true;
            options.ModuleId = i;
            ClientServer.RsyncModule(clientInfo, i);
            clientInfo.IoStream.Close();
            return(1);
        }