暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

跨平台 FTP Server

生有可恋 2023-03-13
788

除了老牌的 vsftp ,有没有好用的 FTP 服务端软件?

最近在处理 PACS 相关的服务,影像系统主要依赖 HTTP 或 FTP 传输文件。很多 NAS 存储都带 FTP 功能,如果不带的话就只能自己搭一个,特别是一些有年头的老存储。

推荐一个跨平台的 FTP 服务端软件,支持 Windows 、Linux,使用 go 语言开发。

项目地址:

    https://github.com/fclairamb/ftpserver

    在项目的 Release 页面有提前编译好的各个平台的可执行文件,我们直接从源码编译进行测试:

      C:\> set http_proxy=http://127.0.0.1:7890
      C:\> set https_proxy=http://127.0.0.1:7890


      $ git clone https://github.com/fclairamb/ftpserver.git
      Cloning into 'ftpserver'...
      remote: Enumerating objects: 7174, done.
      ...
      Resolving deltas: 100% (4925/4925), done.


      D:\ftpserver> go build
      go: downloading github.com/fclairamb/go-log v0.4.1
      go: downloading github.com/fclairamb/ftpserverlib v0.21.0
      go: downloading github.com/go-kit/log v0.2.1
      ...
      go: downloading github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
      go: downloading github.com/jmespath/go-jmespath v0.4.0

      编译完成后在项目目录下会生成一个可执行文件,Windows下是 ftpserver.exe

        $ git status
        On branch main
        Your branch is up to date with 'origin/main'.


        Changes not staged for commit:
        (use "git add <file>..." to update what will be committed)
        (use "git restore <file>..." to discard changes in working directory)
        modified: config/config.go


        Untracked files:
        (use "git add <file>..." to include in what will be committed)
        ftpserver.exe


        no changes added to commit (use "git add" and/or "git commit -a")

        其中在 config/config.go 代码中定义了 FTP 的默认端口号 2121,如果需要使用传统的 21 端口可以在代码文件中修改,或在配置文件中进行定义,配置文件中不定义端口时,服务会使用代码中定义好的默认端口。

        软件运行前需要创建配置文件:

          C:\> ftpserver.exe -h
          Usage of D:\gitRepo\ftpserver\ftpserver.exe:
          -conf string
          Configuration file
          -conf-only
                  Only create the conf

          可以使用 -conf-only 创建一个示例配置文件,此处我给出 Windows 下的配置文件示例 ftpserver.json :

            {
            "version": 1,
              "listen_address"":21",
            "accesses": [
            {
            "read_only": true,
            "user": "test1",
            "pass": "test",
            "fs": "os",
            "params": {
            "basePath": "d:\\"
            }
            },
            {
            "user": "test2",
            "pass": "test",
            "fs": "os",
            "params": {
            "basePath": "e:\\"
            }
            }
            ]
            }

            运行 FTP 服务:

              C:\> ftpserver.exe -conf ftpserver.json
              level=info version= date= commit= event="FTP server"
              level=info component=server address=[::]:21 event=Listening...
              level=info component=server event=Starting...

              该 FTP 服务支持多用户、多根目录,可控制用户权限,默认权限为可读写,可以定义用户权限为只读。

              全文完。

              如果转发本文,文末务必注明:“转自微信公众号:生有可恋”。

              文章转载自生有可恋,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

              评论