コード例 #1
0
ファイル: Main.cs プロジェクト: nolith/internetpack
    public static void StartServer()
    {
      string lDiskFolder = Path.GetDirectoryName(typeof(CmdMain).Assembly.Location)+@"\FtpRoot";;

      fRootFolder = new VirtualFolder(null, "[ROOT]");
      fRootFolder.Add(new VirtualFolder(null, "virtual"));
      fRootFolder.Add(new DiscFolder(null, "drive-c", @"c:\"));
      fRootFolder.Add(new DiscFolder(null, "disc", lDiskFolder));
      fRootFolder.Add(new EmptyFile(null, "=== Welcome to the FTP ==="));

      fUserManager = new UserManager();
      ((UserManager)fUserManager).AddUser("test", "test");

      fFtpServer = new VirtualFtpServer();
      fFtpServer.Port = 2222;
      fFtpServer.Timeout = 60*1000; /* 1 minute */
      fFtpServer.Binding.ListenerThreadCount = 10;
      fFtpServer.RootFolder = fRootFolder;
      fFtpServer.UserManager = fUserManager;
      fFtpServer.ServerName = "VirtualFTP Sample - powered by RemObjects Internet Pack for .NET";
      
      fFtpServer.Open();		

      Debug.Write("VirtualFTP 0.3 BETA - started up");
    }
コード例 #2
0
ファイル: FtpServer.cs プロジェクト: Fedorm/core-master
        public void Start()
        {
            rootFolder = new VirtualFolder(null, "root");
            SetReadOnly(rootFolder, "root");

            VirtualFtpServer fFtpServer = new VirtualFtpServer();
            fFtpServer.Detailed500Errors = true;
            fFtpServer.Port = port;
            fFtpServer.PassiveAddress = passiveAddress;
            fFtpServer.PassivePortFrom = passivePortFrom;
            fFtpServer.PassivePortTo = passivePortTo;
            fFtpServer.Timeout = 60 * 1000; /* 1 minute */
            if (fFtpServer.BindingV4 != null)
                fFtpServer.BindingV4.ListenerThreadCount = 10;
            fFtpServer.RootFolder = rootFolder;
            fFtpServer.UserManager = new UserManagerEx(fFtpServer, rootPath);
            fFtpServer.ServerName = "BitMobile FTP Server";
            fFtpServer.OnUserLogin += OnUserLogin;
            fFtpServer.OnChangeDirectory += OnChangeDirectory;

            fFtpServer.Open();
        }
コード例 #3
0
ファイル: FtpServer.cs プロジェクト: Fedorm/core-master
        private IFtpFolder CreateAdminFolder(VirtualFtpSession session)
        {
            String solutionName = session.Username.Split('_')[0];

            CreateFileSystemFoldersIfNotExists(solutionName);

            VirtualFolder f = new VirtualFolder(rootFolder, session.Username);
            SetReadOnly(f, session.Username);

            DiscFolder df;
            df = new DiscFolder(null, "exchange", GetExchangeFolder(solutionName));
            SetReadOnly(df, session.Username);
            df.UserWrite = true;
            f.Add(df);

            CatalogFile cfs = new CatalogFile(null, "exchange.txt", GetExchangeFolder(solutionName));
            SetReadOnly(cfs, session.Username);
            f.Add(cfs);

            df = new DiscFolder(null, "shared", GetSharedFolder(solutionName));
            SetReadOnly(df, session.Username);
            df.UserWrite = true;
            f.Add(df);

            cfs = new CatalogFile(null, "shared.txt", GetSharedFolder(solutionName));
            SetReadOnly(cfs, session.Username);
            f.Add(cfs);

            df = new DiscFolder(null, "private", GetPrivateFolder(solutionName, ""));
            SetReadOnly(df, session.Username);
            df.UserWrite = true;
            f.Add(df);

            cfs = new CatalogFile(null, "private.txt", GetPrivateFolder(solutionName, ""));
            SetReadOnly(cfs, session.Username);
            f.Add(cfs);

            rootFolder.Add(f);
            return f;
        }
コード例 #4
0
ファイル: FtpServer.cs プロジェクト: Fedorm/core-master
        private IFtpFolder CreateUserFolder(VirtualFtpSession session)
        {
            String[] arr = session.Username.Split('_');
            String solutionName = arr[0];
            String userFolderName = arr[1];

            CreateFileSystemFoldersIfNotExists(solutionName);

            VirtualFolder f = new VirtualFolder(rootFolder, session.Username);
            SetReadOnly(f, session.Username);

            String sharedFolder = GetSharedFolder(solutionName);
            DiscFolder df;
            df = new DiscFolder(null, "shared", sharedFolder);
            SetReadOnly(df, session.Username);
            f.Add(df);

            CatalogFile cfs = new CatalogFile(null, "shared.txt", sharedFolder);
            SetReadOnly(cfs, session.Username); 
            f.Add(cfs);

            String privateFolder = GetPrivateFolder(solutionName, userFolderName);
            df = new DiscFolder(null, "private", privateFolder);
            SetReadOnly(df, session.Username);
            df.UserWrite = true;
            f.Add(df);

            CatalogFile cfp = new CatalogFile(null, "private.txt", privateFolder);
            SetReadOnly(cfp, session.Username);
            f.Add(cfp);

            rootFolder.Add(f);
            return f;
        }
コード例 #5
0
ファイル: FtpServer.cs プロジェクト: Fedorm/core-master
        private IFtpFolder CreateRootFolder(VirtualFtpSession session)
        {
            VirtualFolder f = new VirtualFolder(rootFolder, session.Username);
            SetReadOnly(f, session.Username);

            foreach (String dir in System.IO.Directory.EnumerateDirectories(rootPath))
            {
                String name = new System.IO.DirectoryInfo(dir).Name;
                DiscFolder df = new DiscFolder(null, name, dir);
                SetReadOnly(df, session.Username);
                f.Add(df);
            }
            rootFolder.Add(f);
            return f;
        }