Browse Source

Fix minio bug (#24)

Fix minio bug

Reviewed-on: #24
master
Lunny Xiao 2 months ago
parent
commit
38c8c2b477
19 changed files with 480 additions and 231 deletions
  1. +2
    -1
      .gitignore
  2. +1
    -1
      go.mod
  3. +2
    -42
      go.sum
  4. +3
    -2
      vendor/goftp.io/server/.drone.yml
  5. +2
    -1
      vendor/goftp.io/server/.gitignore
  6. +48
    -14
      vendor/goftp.io/server/cmd.go
  7. +28
    -7
      vendor/goftp.io/server/conn.go
  8. +10
    -21
      vendor/goftp.io/server/driver.go
  9. +19
    -19
      vendor/goftp.io/server/driver_file.go
  10. +115
    -42
      vendor/goftp.io/server/driver_minio.go
  11. +1
    -0
      vendor/goftp.io/server/file_info.go
  12. +4
    -2
      vendor/goftp.io/server/go.mod
  13. +4
    -43
      vendor/goftp.io/server/go.sum
  14. +31
    -19
      vendor/goftp.io/server/logger.go
  15. +176
    -0
      vendor/goftp.io/server/notifier.go
  16. +9
    -0
      vendor/goftp.io/server/perm.go
  17. +17
    -10
      vendor/goftp.io/server/server.go
  18. +7
    -6
      vendor/goftp.io/server/socket.go
  19. +1
    -1
      vendor/modules.txt

+ 2
- 1
.gitignore View File

@@ -3,4 +3,5 @@ custom.ini
ftpd
.history
bindata.go
config.ini
config.ini
.vscode

+ 1
- 1
go.mod View File

@@ -17,5 +17,5 @@ require (
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd
github.com/syndtr/goleveldb v1.0.0
github.com/unknwon/goconfig v0.0.0-20190425194916-3dba17dd7b9e
goftp.io/server v0.3.3-0.20200206033707-57b389cc6571
goftp.io/server v0.3.5-0.20200428022247-5cd49dc54bdb
)

+ 2
- 42
go.sum View File

@@ -1,4 +1,3 @@
code.gitea.io/log v0.0.0-20191208183219-f31613838113/go.mod h1:YOBHMQw/14CwuwNStgQyvnzoDJEO6ARjcSdD48QRzhM=
gitea.com/goftp/file-driver v0.0.0-20190712091345-f79c2ed973f8 h1:uCOouUDYTyK+Zz86dnkvDBUKnbqfqA/Fk/hxp5sXWv8=
gitea.com/goftp/file-driver v0.0.0-20190712091345-f79c2ed973f8/go.mod h1:ghdogu0Da3rwYCSJ20JPgTiMcDpzeRbzvuFIOOW3G7w=
gitea.com/goftp/leveldb-auth v0.0.0-20190711092309-e8e3d5ad5ac8 h1:dvw8cqH+NbkiR0ikE3NSZpRKyBL9fOPuG9h4lKKDJ30=
@@ -26,20 +25,13 @@ gitea.com/tango/xsrf v0.0.0-20190606015726-fb1b2fb84238 h1:ti3ZmMFweqSwRCKbCVzza
gitea.com/tango/xsrf v0.0.0-20190606015726-fb1b2fb84238/go.mod h1:TTynPmrkQOiNzSrbDsDEL273wUIvPC7d+sUweqVPOkI=
github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755 h1:1B7wb36fHLSwZfHg6ngZhhtIEHQjiC5H4p7qQGBEffg=
github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755/go.mod h1:voKvFVpXBJxdIPeqjoJuLK+UVcRlo/JLjeToGxPYu68=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-xweb/uuid v0.0.0-20140604020037-d7dce341f851 h1:D46USD6oGNWzoJ/h5CWaFq3ELLoLoJzllJ03Xh78VYg=
github.com/go-xweb/uuid v0.0.0-20140604020037-d7dce341f851/go.mod h1:OmDEC58ZYO1Esk+Uy32SB6LWof9lyROl7q76dBFOCWw=
github.com/goftp/file-driver v0.0.0-20180502053751-5d604a0fc0c9 h1:cC0Hbb+18DJ4i6ybqDybvj4wdIDS4vnD0QEci98PgM8=
@@ -50,31 +42,20 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf h1:2IYBd5TD/maMqTU2YUzp2tJL4cNaOYQ9EBullN9t9pk=
github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf/go.mod h1:lli8NYPQOFy3O++YmYbqVgOcQ1JPCwdOy+5zSjKJ9qY=
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de h1:nyxwRdWHAVxpFcDThedEgQ07DbcRc5xgNObtbTp76fk=
github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de/go.mod h1:3q8WtuPQsoRbatJuy3nvq/hRSvuBJrHHr+ybPPiNvHQ=
github.com/lunny/tango v0.5.6/go.mod h1:qW1SakbmM67DdOHN6mipeYWhB1Uu6lYsgU3u6fQmu5o=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/minio/minio-go/v6 v6.0.46 h1:waExJtO53xrnsNX//7cSc1h3478wqTryDx4RVD7o26I=
@@ -90,8 +71,6 @@ github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qiniu/api.v6 v6.0.9+incompatible h1:mG/jDC2GD9u2DqP1yIbX+USd3S60bQYSRh6Su6EbnsU=
@@ -100,7 +79,6 @@ github.com/qiniu/bytes v0.0.0-20140728010635-4887e7b2bde3 h1:PXNXOJs716xnMtH6kMk
github.com/qiniu/bytes v0.0.0-20140728010635-4887e7b2bde3/go.mod h1:5KFTwj5mNES3FmpAF+DEDuVolB/OVAUj3oNqPLriYbo=
github.com/qiniu/rpc v0.0.0-20140728010754-30c22466d920 h1:G6C/49DiPwATK+4oBi6OCf14WzCwNMTC1s5Udov4dwQ=
github.com/qiniu/rpc v0.0.0-20140728010754-30c22466d920/go.mod h1:vUC++Z6RsGp85+Oyiu1l5+mpao6xy/Vi1J/G1fKiwDk=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk=
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd h1:ug7PpSOB5RBPK1Kg6qskGBoP3Vnj/aNYFTznWvlkGo0=
@@ -112,10 +90,8 @@ github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs=
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
@@ -130,14 +106,12 @@ github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs=
github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
github.com/unknwon/goconfig v0.0.0-20190425194916-3dba17dd7b9e h1:WIu9z0oMGXDY19FEawfE3gNMXbJ3n2KDRvTHBnkxjnM=
github.com/unknwon/goconfig v0.0.0-20190425194916-3dba17dd7b9e/go.mod h1:qu2ZQ/wcC/if2u32263HTVC39PeOQRSmidQk3DuDFQ8=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
goftp.io/ftpd v0.0.0-20180821024231-89d1eae9c018/go.mod h1:411wH3gYllZ079MJ6lG5UI++ERPF+VklHvGlMux980A=
goftp.io/server v0.0.0-20190712054601-1149070ae46b/go.mod h1:xreggPYu7ZuNe9PfbxiQca7bYGwU44IvlCCg3KzWJtQ=
goftp.io/server v0.0.0-20190812034929-9b3874d17690 h1:vHUbHALX1kwsxK6gFQeY19+10zk/pSABN/0vumWLCxQ=
goftp.io/server v0.0.0-20190812034929-9b3874d17690/go.mod h1:99FISrRpwKfaL4Ey/dX8N48WToveng/s2OXR5sJ3cnc=
goftp.io/server v0.3.3-0.20200206033707-57b389cc6571 h1:AMsRl+sn342eN3KyYyY1YhA8n9HFX8PnGMuGMcd0yj4=
goftp.io/server v0.3.3-0.20200206033707-57b389cc6571/go.mod h1:Ewqfa40Xnkh/AEA+Sf9KX2lp8aKnEum77YDHhHwABK4=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
goftp.io/server v0.3.5-0.20200428022247-5cd49dc54bdb h1:KyExRJCQa5lv7e1djnrZHOahYVdEKo3VMhTlNVrfrJw=
goftp.io/server v0.3.5-0.20200428022247-5cd49dc54bdb/go.mod h1:hFZeR656ErRt3ojMKt7H10vQ5nuWV1e0YeUTeorlR6k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
@@ -147,21 +121,15 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJV
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
@@ -171,21 +139,13 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a h1:mEQZbbaBjWyLNy0tmZmgEuQAR8XOQ3hL8GYi3J/NG64=
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk=
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

+ 3
- 2
vendor/goftp.io/server/.drone.yml View File

@@ -19,7 +19,7 @@ steps:
commands:
- export PATH=$PATH:/go:/srv/app/bin
- go vet ./...
- go test -race ./...
- go test -v -race ./...
environment:
GOPATH: /srv/app
MINIO_SERVER_ENDPOINT: minio:9000
@@ -28,6 +28,7 @@ steps:
MINIO_SERVER_SECRET_KEY:
from_secret: aws_secret_access_key
MINIO_SERVER_BUCKET: test
GOPROXY: https://goproxy.cn,direct
when:
event:
- push
@@ -36,7 +37,7 @@ steps:

services:
- name: minio
image: minio/minio:RELEASE.2019-10-12T01-39-57Z
image: minio/minio:RELEASE.2020-03-14T02-21-58Z
commands:
- minio server ./data
environment:


+ 2
- 1
vendor/goftp.io/server/.gitignore View File

@@ -1,3 +1,4 @@
testdata
coverage.txt
exampleftpd/exampleftpd
exampleftpd/exampleftpd
.vscode

+ 48
- 14
vendor/goftp.io/server/cmd.go View File

@@ -12,6 +12,7 @@ import (
"strings"
)

// Command represents a Command interface to a ftp command
type Command interface {
IsExtend() bool
RequireParam() bool
@@ -113,13 +114,16 @@ func (cmd commandAppe) Execute(conn *Conn, param string) {
targetPath := conn.buildPath(param)
conn.writeMessage(150, "Data transfer starting")

bytes, err := conn.driver.PutFile(targetPath, conn.dataConn, true)
conn.server.notifiers.BeforePutFile(conn, targetPath)
size, err := conn.driver.PutFile(targetPath, conn.dataConn, true)
conn.server.notifiers.AfterFilePut(conn, targetPath, size, err)
if err == nil {
msg := "OK, received " + strconv.Itoa(int(bytes)) + " bytes"
msg := fmt.Sprintf("OK, received %d bytes", size)
conn.writeMessage(226, msg)
} else {
conn.writeMessage(450, fmt.Sprint("error during transfer: ", err))
}

}

type commandOpts struct{}
@@ -225,9 +229,20 @@ func (cmd commandCwd) RequireAuth() bool {

func (cmd commandCwd) Execute(conn *Conn, param string) {
path := conn.buildPath(param)
err := conn.driver.ChangeDir(path)
info, err := conn.driver.Stat(path)
if err != nil {
conn.writeMessage(550, fmt.Sprint("Directory change to ", path, " failed: ", err))
return
}
if !info.IsDir() {
conn.writeMessage(550, fmt.Sprint("Directory change to ", path, " is a file"))
return
}

conn.server.notifiers.BeforeChangeCurDir(conn, conn.curDir, path)
err = conn.changeCurDir(path)
conn.server.notifiers.AfterCurDirChanged(conn, conn.curDir, path, err)
if err == nil {
conn.namePrefix = path
conn.writeMessage(250, "Directory changed to "+path)
} else {
conn.writeMessage(550, fmt.Sprint("Directory change to ", path, " failed: ", err))
@@ -252,7 +267,9 @@ func (cmd commandDele) RequireAuth() bool {

func (cmd commandDele) Execute(conn *Conn, param string) {
path := conn.buildPath(param)
conn.server.notifiers.BeforeDeleteFile(conn, path)
err := conn.driver.DeleteFile(path)
conn.server.notifiers.AfterFileDeleted(conn, path, err)
if err == nil {
conn.writeMessage(250, "File deleted")
} else {
@@ -377,14 +394,13 @@ func (cmd commandEpsv) RequireAuth() bool {
}

func (cmd commandEpsv) Execute(conn *Conn, param string) {
addr := conn.passiveListenIP()
socket, err := newPassiveSocket(addr, conn.PassivePort, conn.logger, conn.sessionID, conn.tlsConfig)
socket, err := conn.newPassiveSocket()
if err != nil {
log.Println(err)
conn.writeMessage(425, "Data connection failed")
return
}
conn.dataConn = socket
msg := fmt.Sprintf("Entering Extended Passive Mode (|||%d|)", socket.Port())
conn.writeMessage(229, msg)
}
@@ -538,7 +554,9 @@ func (cmd commandMkd) RequireAuth() bool {

func (cmd commandMkd) Execute(conn *Conn, param string) {
path := conn.buildPath(param)
conn.server.notifiers.BeforeCreateDir(conn, path)
err := conn.driver.MakeDir(path)
conn.server.notifiers.AfterDirCreated(conn, path, err)
if err == nil {
conn.writeMessage(257, "Directory created")
} else {
@@ -614,6 +632,7 @@ func (cmd commandPass) RequireAuth() bool {

func (cmd commandPass) Execute(conn *Conn, param string) {
ok, err := conn.server.Auth.CheckPasswd(conn.reqUser, param)
conn.server.notifiers.AfterUserLogin(conn, conn.reqUser, param, ok, err)
if err != nil {
conn.writeMessage(550, "Checking password error")
return
@@ -648,14 +667,21 @@ func (cmd commandPasv) RequireAuth() bool {

func (cmd commandPasv) Execute(conn *Conn, param string) {
listenIP := conn.passiveListenIP()
socket, err := newPassiveSocket(listenIP, conn.PassivePort, conn.logger, conn.sessionID, conn.tlsConfig)
// TODO: IPv6 for this command is not implemented
if strings.HasPrefix(listenIP, "::") {
conn.writeMessage(550, fmt.Sprint("Action not taken "))
return
}

socket, err := conn.newPassiveSocket()
if err != nil {
conn.writeMessage(425, "Data connection failed")
return
}
conn.dataConn = socket
p1 := socket.Port() / 256
p2 := socket.Port() - (p1 * 256)

quads := strings.Split(listenIP, ".")
target := fmt.Sprintf("(%s,%s,%s,%s,%d,%d)", quads[0], quads[1], quads[2], quads[3], p1, p2)
msg := "Entering Passive Mode " + target
@@ -713,7 +739,7 @@ func (cmd commandPwd) RequireAuth() bool {
}

func (cmd commandPwd) Execute(conn *Conn, param string) {
conn.writeMessage(257, "\""+conn.namePrefix+"\" is the current directory")
conn.writeMessage(257, "\""+conn.curDir+"\" is the current directory")
}

// CommandQuit responds to the QUIT FTP command. The client has requested the
@@ -759,15 +785,18 @@ func (cmd commandRetr) Execute(conn *Conn, param string) {
conn.lastFilePos = 0
conn.appendData = false
}()
bytes, data, err := conn.driver.GetFile(path, conn.lastFilePos)
conn.server.notifiers.BeforeDownloadFile(conn, path)
size, data, err := conn.driver.GetFile(path, conn.lastFilePos)
if err == nil {
defer data.Close()
conn.writeMessage(150, fmt.Sprintf("Data transfer starting %v bytes", bytes))
conn.writeMessage(150, fmt.Sprintf("Data transfer starting %d bytes", size))
err = conn.sendOutofBandDataWriter(data)
conn.server.notifiers.AfterFileDownloaded(conn, path, size, err)
if err != nil {
conn.writeMessage(551, "Error reading file")
}
} else {
conn.server.notifiers.AfterFileDownloaded(conn, path, size, err)
conn.writeMessage(551, "File not available")
}
}
@@ -868,7 +897,9 @@ func (cmd commandRmd) RequireAuth() bool {

func (cmd commandRmd) Execute(conn *Conn, param string) {
path := conn.buildPath(param)
conn.server.notifiers.BeforeDeleteDir(conn, path)
err := conn.driver.DeleteDir(path)
conn.server.notifiers.AfterDirDeleted(conn, path, err)
if err == nil {
conn.writeMessage(250, "Directory deleted")
} else {
@@ -1089,9 +1120,11 @@ func (cmd commandStor) Execute(conn *Conn, param string) {
conn.appendData = false
}()

bytes, err := conn.driver.PutFile(targetPath, conn.dataConn, conn.appendData)
conn.server.notifiers.BeforePutFile(conn, targetPath)
size, err := conn.driver.PutFile(targetPath, conn.dataConn, conn.appendData)
conn.server.notifiers.AfterFilePut(conn, targetPath, size, err)
if err == nil {
msg := "OK, received " + strconv.Itoa(int(bytes)) + " bytes"
msg := fmt.Sprintf("OK, received %d bytes", size)
conn.writeMessage(226, msg)
} else {
conn.writeMessage(450, fmt.Sprint("error during transfer: ", err))
@@ -1199,6 +1232,7 @@ func (cmd commandUser) RequireAuth() bool {

func (cmd commandUser) Execute(conn *Conn, param string) {
conn.reqUser = param
conn.server.notifiers.BeforeLoginUser(conn, conn.reqUser)
if conn.tls || conn.tlsConfig == nil {
conn.writeMessage(331, "User name ok, password required")
} else {


+ 28
- 7
vendor/goftp.io/server/conn.go View File

@@ -26,6 +26,7 @@ const (
defaultWelcomeMessage = "Welcome to the Go FTP Server"
)

// Conn represents a connection between ftp client and the server
type Conn struct {
conn net.Conn
controlReader *bufio.Reader
@@ -37,7 +38,7 @@ type Conn struct {
server *Server
tlsConfig *tls.Config
sessionID string
namePrefix string
curDir string
reqUser string
user string
renameFrom string
@@ -47,26 +48,38 @@ type Conn struct {
tls bool
}

// RemoteAddr returns the remote ftp client's address
func (conn *Conn) RemoteAddr() net.Addr {
return conn.conn.RemoteAddr()
}

// LoginUser returns the login user name if login
func (conn *Conn) LoginUser() string {
return conn.user
}

// IsLogin returns if user has login
func (conn *Conn) IsLogin() bool {
return len(conn.user) > 0
}

func (conn *Conn) PublicIp() string {
return conn.server.PublicIp
// PublicIP returns the public ip of the server
func (conn *Conn) PublicIP() string {
return conn.server.PublicIP
}

func (conn *Conn) passiveListenIP() string {
var listenIP string
if len(conn.PublicIp()) > 0 {
listenIP = conn.PublicIp()
if len(conn.PublicIP()) > 0 {
listenIP = conn.PublicIP()
} else {
listenIP = conn.conn.LocalAddr().(*net.TCPAddr).IP.String()
}

if listenIP == "::1" {
return listenIP
}

lastIdx := strings.LastIndex(listenIP, ":")
if lastIdx <= 0 {
return listenIP
@@ -74,6 +87,7 @@ func (conn *Conn) passiveListenIP() string {
return listenIP[:lastIdx]
}

// PassivePort returns the port which could be used by passive mode.
func (conn *Conn) PassivePort() int {
if len(conn.server.PassivePorts) > 0 {
portRange := strings.Split(conn.server.PassivePorts, "-")
@@ -138,6 +152,8 @@ func (conn *Conn) Serve() {
func (conn *Conn) Close() {
conn.conn.Close()
conn.closed = true
conn.reqUser = ""
conn.user = ""
if conn.dataConn != nil {
conn.dataConn.Close()
conn.dataConn = nil
@@ -242,9 +258,9 @@ func (conn *Conn) buildPath(filename string) (fullPath string) {
if len(filename) > 0 && filename[0:1] == "/" {
fullPath = filepath.Clean(filename)
} else if len(filename) > 0 && filename != "-a" {
fullPath = filepath.Clean(conn.namePrefix + "/" + filename)
fullPath = filepath.Clean(conn.curDir + "/" + filename)
} else {
fullPath = filepath.Clean(conn.namePrefix)
fullPath = filepath.Clean(conn.curDir)
}
fullPath = strings.Replace(fullPath, "//", "/", -1)
fullPath = strings.Replace(fullPath, string(filepath.Separator), "/", -1)
@@ -279,3 +295,8 @@ func (conn *Conn) sendOutofBandDataWriter(data io.ReadCloser) error {

return nil
}

func (conn *Conn) changeCurDir(path string) error {
conn.curDir = path
return nil
}

+ 10
- 21
vendor/goftp.io/server/driver.go View File

@@ -20,20 +20,12 @@ type DriverFactory interface {
// chosen persistence layer. graval will create a new instance of your
// driver for each client that connects and delegate to it as required.
type Driver interface {
// Init init
Init(*Conn)

// params - a file path
// returns - a time indicating when the requested path was last modified
// - an error if the file doesn't exist or the user lacks
// permissions
Stat(string) (FileInfo, error)

// params - path
// returns - true if the current user is permitted to change to the
// requested path
ChangeDir(string) error

// params - path, function on file or subdir found
// returns - error
// path
@@ -71,19 +63,7 @@ type MultipleDriver struct {
drivers map[string]Driver
}

// Init init
func (driver *MultipleDriver) Init(conn *Conn) {
}

func (driver *MultipleDriver) ChangeDir(path string) error {
for prefix, driver := range driver.drivers {
if strings.HasPrefix(path, prefix) {
return driver.ChangeDir(strings.TrimPrefix(path, prefix))
}
}
return errors.New("Not a directory")
}

// Stat implements Driver
func (driver *MultipleDriver) Stat(path string) (FileInfo, error) {
for prefix, driver := range driver.drivers {
if strings.HasPrefix(path, prefix) {
@@ -93,6 +73,7 @@ func (driver *MultipleDriver) Stat(path string) (FileInfo, error) {
return nil, errors.New("Not a file")
}

// ListDir implements Driver
func (driver *MultipleDriver) ListDir(path string, callback func(FileInfo) error) error {
for prefix, driver := range driver.drivers {
if strings.HasPrefix(path, prefix) {
@@ -102,6 +83,7 @@ func (driver *MultipleDriver) ListDir(path string, callback func(FileInfo) error
return errors.New("Not a directory")
}

// DeleteDir implements Driver
func (driver *MultipleDriver) DeleteDir(path string) error {
for prefix, driver := range driver.drivers {
if strings.HasPrefix(path, prefix) {
@@ -111,6 +93,7 @@ func (driver *MultipleDriver) DeleteDir(path string) error {
return errors.New("Not a directory")
}

// DeleteFile implements Driver
func (driver *MultipleDriver) DeleteFile(path string) error {
for prefix, driver := range driver.drivers {
if strings.HasPrefix(path, prefix) {
@@ -121,6 +104,7 @@ func (driver *MultipleDriver) DeleteFile(path string) error {
return errors.New("Not a file")
}

// Rename implements Driver
func (driver *MultipleDriver) Rename(fromPath string, toPath string) error {
for prefix, driver := range driver.drivers {
if strings.HasPrefix(fromPath, prefix) {
@@ -131,6 +115,7 @@ func (driver *MultipleDriver) Rename(fromPath string, toPath string) error {
return errors.New("Not a file")
}

// MakeDir implements Driver
func (driver *MultipleDriver) MakeDir(path string) error {
for prefix, driver := range driver.drivers {
if strings.HasPrefix(path, prefix) {
@@ -140,6 +125,7 @@ func (driver *MultipleDriver) MakeDir(path string) error {
return errors.New("Not a directory")
}

// GetFile implements Driver
func (driver *MultipleDriver) GetFile(path string, offset int64) (int64, io.ReadCloser, error) {
for prefix, driver := range driver.drivers {
if strings.HasPrefix(path, prefix) {
@@ -150,6 +136,7 @@ func (driver *MultipleDriver) GetFile(path string, offset int64) (int64, io.Read
return 0, nil, errors.New("Not a file")
}

// PutFile implements Driver
func (driver *MultipleDriver) PutFile(destPath string, data io.Reader, appendData bool) (int64, error) {
for prefix, driver := range driver.drivers {
if strings.HasPrefix(destPath, prefix) {
@@ -160,10 +147,12 @@ func (driver *MultipleDriver) PutFile(destPath string, data io.Reader, appendDat
return 0, errors.New("Not a file")
}

// MultipleDriverFactory implements a DriverFactory
type MultipleDriverFactory struct {
drivers map[string]Driver
}

// NewDriver implements DriverFactory
func (factory *MultipleDriverFactory) NewDriver() (Driver, error) {
return &MultipleDriver{factory.drivers}, nil
}

+ 19
- 19
vendor/goftp.io/server/driver_file.go View File

@@ -13,6 +13,7 @@ import (
"strings"
)

// FileDriver implements Driver directly read local file system
type FileDriver struct {
RootPath string
Perm
@@ -23,22 +24,7 @@ func (driver *FileDriver) realPath(path string) string {
return filepath.Join(append([]string{driver.RootPath}, paths...)...)
}

func (driver *FileDriver) Init(conn *Conn) {
//driver.conn = conn
}

func (driver *FileDriver) ChangeDir(path string) error {
rPath := driver.realPath(path)
f, err := os.Lstat(rPath)
if err != nil {
return err
}
if f.IsDir() {
return nil
}
return errors.New("Not a directory")
}

// Stat implements Driver
func (driver *FileDriver) Stat(path string) (FileInfo, error) {
basepath := driver.realPath(path)
rPath, err := filepath.Abs(basepath)
@@ -67,6 +53,7 @@ func (driver *FileDriver) Stat(path string) (FileInfo, error) {
return &fileInfo{f, mode, owner, group}, nil
}

// ListDir implements Driver
func (driver *FileDriver) ListDir(path string, callback func(FileInfo) error) error {
basepath := driver.realPath(path)
return filepath.Walk(basepath, func(f string, info os.FileInfo, err error) error {
@@ -102,6 +89,7 @@ func (driver *FileDriver) ListDir(path string, callback func(FileInfo) error) er
})
}

// DeleteDir implements Driver
func (driver *FileDriver) DeleteDir(path string) error {
rPath := driver.realPath(path)
f, err := os.Lstat(rPath)
@@ -109,11 +97,12 @@ func (driver *FileDriver) DeleteDir(path string) error {
return err
}
if f.IsDir() {
return os.Remove(rPath)
return os.RemoveAll(rPath)
}
return errors.New("Not a directory")
}

// DeleteFile implements Driver
func (driver *FileDriver) DeleteFile(path string) error {
rPath := driver.realPath(path)
f, err := os.Lstat(rPath)
@@ -126,17 +115,20 @@ func (driver *FileDriver) DeleteFile(path string) error {
return errors.New("Not a file")
}

// Rename implements Driver
func (driver *FileDriver) Rename(fromPath string, toPath string) error {
oldPath := driver.realPath(fromPath)
newPath := driver.realPath(toPath)
return os.Rename(oldPath, newPath)
}

// MakeDir implements Driver
func (driver *FileDriver) MakeDir(path string) error {
rPath := driver.realPath(path)
return os.MkdirAll(rPath, os.ModePerm)
}

// GetFile implements Driver
func (driver *FileDriver) GetFile(path string, offset int64) (int64, io.ReadCloser, error) {
rPath := driver.realPath(path)
f, err := os.Open(rPath)
@@ -149,11 +141,12 @@ func (driver *FileDriver) GetFile(path string, offset int64) (int64, io.ReadClos
return 0, nil, err
}

f.Seek(offset, os.SEEK_SET)
f.Seek(offset, io.SeekStart)

return info.Size(), f, nil
return info.Size() - offset, f, nil
}

// PutFile implements Driver
func (driver *FileDriver) PutFile(destPath string, data io.Reader, appendData bool) (int64, error) {
rPath := driver.realPath(destPath)
var isExist bool
@@ -213,11 +206,18 @@ func (driver *FileDriver) PutFile(destPath string, data io.Reader, appendData bo
return bytes, nil
}

// FileDriverFactory implements DriverFactory
type FileDriverFactory struct {
RootPath string
Perm
}

// NewDriver implements DriverFactory
func (factory *FileDriverFactory) NewDriver() (Driver, error) {
var err error
factory.RootPath, err = filepath.Abs(factory.RootPath)
if err != nil {
return nil, err
}
return &FileDriver{factory.RootPath, factory.Perm}, nil
}

+ 115
- 42
vendor/goftp.io/server/driver_minio.go View File

@@ -7,6 +7,7 @@ package server
import (
"errors"
"io"
"log"
"os"
"strings"
"time"
@@ -15,31 +16,48 @@ import (
)

var (
ErrNotImplemented = errors.New("not implemented")
_ Driver = &MinioDriver{}
)

// MinioDriver implements Driver to store files in minio
type MinioDriver struct {
client *minio.Client
perm Perm
bucket string
}

func (driver *MinioDriver) Init(conn *Conn) {
func buildMinioPath(p string) string {
return strings.TrimPrefix(p, "/")
}

func (driver *MinioDriver) ChangeDir(path string) error {
return ErrNotImplemented
func buildMinioDir(p string) string {
v := buildMinioPath(p)
if !strings.HasSuffix(v, "/") {
return v + "/"
}
return v
}

func buildMinioPath(p string) string {
return strings.TrimPrefix(p, "/")
type myPerm struct {
Perm
isDir bool
}

func (m *myPerm) GetMode(user string) (os.FileMode, error) {
mode, err := m.Perm.GetMode(user)
if err != nil {
return 0, err
}
if m.isDir {
return mode | os.ModeDir, nil
}
return mode, nil
}

type minioFileInfo struct {
p string
info minio.ObjectInfo
perm Perm
isDir bool
p string
info minio.ObjectInfo
perm Perm
}

func (m *minioFileInfo) Name() string {
@@ -60,7 +78,7 @@ func (m *minioFileInfo) ModTime() time.Time {
}

func (m *minioFileInfo) IsDir() bool {
return m.isDir
return m.Mode().IsDir()
}

func (m *minioFileInfo) Sys() interface{} {
@@ -78,65 +96,84 @@ func (m *minioFileInfo) Group() string {
}

func (driver *MinioDriver) isDir(path string) (bool, error) {
doneCh := make(chan struct{})
defer close(doneCh)
p := buildMinioPath(path)
objectCh := driver.client.ListObjects(driver.bucket, p, false, doneCh)
for object := range objectCh {
if object.Err != nil {
return false, object.Err
p := buildMinioDir(path)

info, err := driver.client.StatObject(driver.bucket, p, minio.StatObjectOptions{})
if err != nil {
doneCh := make(chan struct{})
objectCh := driver.client.ListObjects(driver.bucket, p, false, doneCh)
for object := range objectCh {
if strings.HasPrefix(object.Key, p) {
close(doneCh)
return true, nil
}
}
return true, nil

close(doneCh)
return false, nil
}
return false, nil

return strings.HasSuffix(info.Key, "/"), nil
}

// Stat implements Driver
func (driver *MinioDriver) Stat(path string) (FileInfo, error) {
if path == "/" {
return &minioFileInfo{
p: "/",
perm: driver.perm,
isDir: true,
p: "/",
perm: &myPerm{driver.perm, true},
}, nil
}

p := buildMinioPath(path)
objInfo, err := driver.client.StatObject(driver.bucket, p, minio.StatObjectOptions{})
if err != nil {
if isDir, err := driver.isDir(path); err != nil {
if isDir, err := driver.isDir(p); err != nil {
return nil, err
} else if isDir {
return &minioFileInfo{
p: path,
perm: driver.perm,
isDir: true,
p: path,
perm: &myPerm{driver.perm, true},
}, nil
}
return nil, errors.New("Not a directory")
}
isDir := strings.HasSuffix(objInfo.Key, "/")
return &minioFileInfo{
p: p,
info: objInfo,
perm: driver.perm,
perm: &myPerm{driver.perm, isDir},
}, nil
}

// ListDir implements Driver
func (driver *MinioDriver) ListDir(path string, callback func(FileInfo) error) error {
doneCh := make(chan struct{})
defer close(doneCh)

p := buildMinioPath(path)
p := buildMinioDir(path)
if p == "/" {
p = ""
}
objectCh := driver.client.ListObjects(driver.bucket, p, false, doneCh)
for object := range objectCh {
if object.Err != nil {
return object.Err
}

if err := callback(&minioFileInfo{
p: object.Key,
// ignore itself
if object.Key == p {
continue
}

isDir := strings.HasSuffix(object.Key, "/")
info := minioFileInfo{
p: strings.TrimPrefix(object.Key, p),
info: object,
perm: driver.perm,
}); err != nil {
perm: &myPerm{driver.perm, isDir},
}

if err := callback(&info); err != nil {
return err
}
}
@@ -144,12 +181,13 @@ func (driver *MinioDriver) ListDir(path string, callback func(FileInfo) error) e
return nil
}

// DeleteDir implements Driver
func (driver *MinioDriver) DeleteDir(path string) error {
doneCh := make(chan struct{})
defer close(doneCh)

p := buildMinioPath(path)
objectCh := driver.client.ListObjects(driver.bucket, p, false, doneCh)
objectCh := driver.client.ListObjects(driver.bucket, p, true, doneCh)
for object := range objectCh {
if object.Err != nil {
return object.Err
@@ -162,10 +200,12 @@ func (driver *MinioDriver) DeleteDir(path string) error {
return nil
}

// DeleteFile implements Driver
func (driver *MinioDriver) DeleteFile(path string) error {
return driver.client.RemoveObject(driver.bucket, buildMinioPath(path))
}

// Rename implements Driver
func (driver *MinioDriver) Rename(fromPath string, toPath string) error {
src := minio.NewSourceInfo(driver.bucket, buildMinioPath(fromPath), nil)
dst, err := minio.NewDestinationInfo(driver.bucket, buildMinioPath(toPath), nil, nil)
@@ -180,35 +220,66 @@ func (driver *MinioDriver) Rename(fromPath string, toPath string) error {
return driver.client.RemoveObject(driver.bucket, buildMinioPath(fromPath))
}

// MakeDir implements Driver
func (driver *MinioDriver) MakeDir(path string) error {
return nil
dirPath := buildMinioDir(path)
_, err := driver.client.PutObject(driver.bucket, dirPath, nil, 0, minio.PutObjectOptions{})
return err
}

// GetFile implements Driver
func (driver *MinioDriver) GetFile(path string, offset int64) (int64, io.ReadCloser, error) {
if offset > 0 {
return 0, nil, ErrNotImplemented
}
object, err := driver.client.GetObject(driver.bucket, buildMinioPath(path), minio.GetObjectOptions{})
var opts = minio.GetObjectOptions{}
object, err := driver.client.GetObject(driver.bucket, buildMinioPath(path), opts)
if err != nil {
return 0, nil, err
}
object.Seek(offset, io.SeekStart)

info, err := object.Stat()
if err != nil {
return 0, nil, err
}

return info.Size, object, nil
return info.Size - offset, object, nil
}

// PutFile implements Driver
func (driver *MinioDriver) PutFile(destPath string, data io.Reader, appendData bool) (int64, error) {
p := buildMinioPath(destPath)
if !appendData {
return driver.client.PutObject(driver.bucket, buildMinioPath(destPath), data, -1, minio.PutObjectOptions{ContentType: "application/octet-stream"})
return driver.client.PutObject(driver.bucket, p, data, -1, minio.PutObjectOptions{ContentType: "application/octet-stream"})
}

tempFile := p + ".tmp"
//tempDstFile := p + ".dst"
defer func() {
if err := driver.DeleteFile(tempFile); err != nil {
log.Println(err)
}
/*if err := driver.DeleteFile(tempDstFile); err != nil {
log.Println(err)
}*/
}()

size, err := driver.client.PutObject(driver.bucket, tempFile, data, -1, minio.PutObjectOptions{ContentType: "application/octet-stream"})
if err != nil {
return size, err
}

var srcs = []minio.SourceInfo{
minio.NewSourceInfo(driver.bucket, tempFile, nil),
minio.NewSourceInfo(driver.bucket, p, nil),
}
dst, err := minio.NewDestinationInfo(driver.bucket, p, nil, nil)
if err != nil {
return 0, err
}

return 0, ErrNotImplemented
return size, driver.client.ComposeObject(dst, srcs)
}

// MinioDriverFactory implements DriverFactory
type MinioDriverFactory struct {
endpoint string
accessKeyID string
@@ -219,6 +290,7 @@ type MinioDriverFactory struct {
perm Perm
}

// NewMinioDriverFactory creates a DriverFactory implementation
func NewMinioDriverFactory(endpoint, accessKeyID, secretAccessKey, location, bucket string, useSSL bool, perm Perm) *MinioDriverFactory {
return &MinioDriverFactory{
endpoint: endpoint,
@@ -231,6 +303,7 @@ func NewMinioDriverFactory(endpoint, accessKeyID, secretAccessKey, location, buc
}
}

// NewDriver implements DriverFactory
func (factory *MinioDriverFactory) NewDriver() (Driver, error) {
// Initialize minio client object.
minioClient, err := minio.New(factory.endpoint, factory.accessKeyID, factory.secretAccessKey, factory.useSSL)


+ 1
- 0
vendor/goftp.io/server/file_info.go View File

@@ -6,6 +6,7 @@ package server

import "os"

// FileInfo represents an file interface
type FileInfo interface {
os.FileInfo



+ 4
- 2
vendor/goftp.io/server/go.mod View File

@@ -3,9 +3,11 @@ module goftp.io/server
go 1.12

require (
code.gitea.io/log v0.0.0-20191208183219-f31613838113
github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf
github.com/minio/minio-go/v6 v6.0.46
github.com/stretchr/testify v1.3.0
gopkg.in/src-d/go-git.v4 v4.13.1
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 // indirect
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e // indirect
golang.org/x/text v0.3.2 // indirect
)

+ 4
- 43
vendor/goftp.io/server/go.sum View File

@@ -1,59 +1,33 @@
code.gitea.io/log v0.0.0-20191208183219-f31613838113 h1:r3gilyTmowpqsnvXRX7Ww1sYWmfR8pbZ1meymLXYCDA=
code.gitea.io/log v0.0.0-20191208183219-f31613838113/go.mod h1:YOBHMQw/14CwuwNStgQyvnzoDJEO6ARjcSdD48QRzhM=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf h1:2IYBd5TD/maMqTU2YUzp2tJL4cNaOYQ9EBullN9t9pk=
github.com/jlaffaye/ftp v0.0.0-20190624084859-c1312a7102bf/go.mod h1:lli8NYPQOFy3O++YmYbqVgOcQ1JPCwdOy+5zSjKJ9qY=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/minio/minio-go v6.0.14+incompatible h1:fnV+GD28LeqdN6vT2XdGKW8Qe/IfjJDswNVuni6km9o=
github.com/minio/minio-go/v6 v6.0.46 h1:waExJtO53xrnsNX//7cSc1h3478wqTryDx4RVD7o26I=
github.com/minio/minio-go/v6 v6.0.46/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU=
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs=
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@@ -63,17 +37,12 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
@@ -82,13 +51,5 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk=
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=

+ 31
- 19
vendor/goftp.io/server/logger.go View File

@@ -9,40 +9,52 @@ import (
"log"
)

// Logger represents an interface to record all ftp information and command
type Logger interface {
Print(sessionId string, message interface{})
Printf(sessionId string, format string, v ...interface{})
PrintCommand(sessionId string, command string, params string)
PrintResponse(sessionId string, code int, message string)
Print(sessionID string, message interface{})
Printf(sessionID string, format string, v ...interface{})
PrintCommand(sessionID string, command string, params string)
PrintResponse(sessionID string, code int, message string)
}

// Use an instance of this to log in a standard format
// StdLogger use an instance of this to log in a standard format
type StdLogger struct{}

func (logger *StdLogger) Print(sessionId string, message interface{}) {
log.Printf("%s %s", sessionId, message)
// Print impelment Logger
func (logger *StdLogger) Print(sessionID string, message interface{}) {
log.Printf("%s %s", sessionID, message)
}

func (logger *StdLogger) Printf(sessionId string, format string, v ...interface{}) {
logger.Print(sessionId, fmt.Sprintf(format, v...))
// Printf impelment Logger
func (logger *StdLogger) Printf(sessionID string, format string, v ...interface{}) {
logger.Print(sessionID, fmt.Sprintf(format, v...))
}

func (logger *StdLogger) PrintCommand(sessionId string, command string, params string) {
// PrintCommand impelment Logger
func (logger *StdLogger) PrintCommand(sessionID string, command string, params string) {
if command == "PASS" {
log.Printf("%s > PASS ****", sessionId)
log.Printf("%s > PASS ****", sessionID)
} else {
log.Printf("%s > %s %s", sessionId, command, params)
log.Printf("%s > %s %s", sessionID, command, params)
}
}

func (logger *StdLogger) PrintResponse(sessionId string, code int, message string) {
log.Printf("%s < %d %s", sessionId, code, message)
// PrintResponse impelment Logger
func (logger *StdLogger) PrintResponse(sessionID string, code int, message string) {
log.Printf("%s < %d %s", sessionID, code, message)
}

// Silent logger, produces no output
// DiscardLogger represents a silent logger, produces no output
type DiscardLogger struct{}

func (logger *DiscardLogger) Print(sessionId string, message interface{}) {}
func (logger *DiscardLogger) Printf(sessionId string, format string, v ...interface{}) {}
func (logger *DiscardLogger) PrintCommand(sessionId string, command string, params string) {}
func (logger *DiscardLogger) PrintResponse(sessionId string, code int, message string) {}
// Print impelment Logger
func (logger *DiscardLogger) Print(sessionID string, message interface{}) {}

// Printf impelment Logger
func (logger *DiscardLogger) Printf(sessionID string, format string, v ...interface{}) {}

// PrintCommand impelment Logger
func (logger *DiscardLogger) PrintCommand(sessionID string, command string, params string) {}

// PrintResponse impelment Logger
func (logger *DiscardLogger) PrintResponse(sessionID string, code int, message string) {}

+ 176
- 0
vendor/goftp.io/server/notifier.go View File

@@ -0,0 +1,176 @@
// Copyright 2020 The goftp Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package server

// Notifier represents a notification operator interface
type Notifier interface {
BeforeLoginUser(conn *Conn, userName string)
BeforePutFile(conn *Conn, dstPath string)
BeforeDeleteFile(conn *Conn, dstPath string)
BeforeChangeCurDir(conn *Conn, oldCurDir, newCurDir string)
BeforeCreateDir(conn *Conn, dstPath string)
BeforeDeleteDir(conn *Conn, dstPath string)
BeforeDownloadFile(conn *Conn, dstPath string)
AfterUserLogin(conn *Conn, userName, password string, passMatched bool, err error)
AfterFilePut(conn *Conn, dstPath string, size int64, err error)
AfterFileDeleted(conn *Conn, dstPath string, err error)
AfterFileDownloaded(conn *Conn, dstPath string, size int64, err error)
AfterCurDirChanged(conn *Conn, oldCurDir, newCurDir string, err error)
AfterDirCreated(conn *Conn, dstPath string, err error)
AfterDirDeleted(conn *Conn, dstPath string, err error)
}

type notifierList []Notifier

var (
_ Notifier = notifierList{}
)

func (notifiers notifierList) BeforeLoginUser(conn *Conn, userName string) {
for _, notifier := range notifiers {
notifier.BeforeLoginUser(conn, userName)
}
}

func (notifiers notifierList) BeforePutFile(conn *Conn, dstPath string) {
for _, notifier := range notifiers {
notifier.BeforePutFile(conn, dstPath)
}
}

func (notifiers notifierList) BeforeDeleteFile(conn *Conn, dstPath string) {
for _, notifier := range notifiers {
notifier.BeforeDeleteFile(conn, dstPath)
}
}

func (notifiers notifierList) BeforeChangeCurDir(conn *Conn, oldCurDir, newCurDir string) {
for _, notifier := range notifiers {
notifier.BeforeChangeCurDir(conn, oldCurDir, newCurDir)
}
}

func (notifiers notifierList) BeforeCreateDir(conn *Conn, dstPath string) {
for _, notifier := range notifiers {
notifier.BeforeCreateDir(conn, dstPath)
}
}

func (notifiers notifierList) BeforeDeleteDir(conn *Conn, dstPath string) {
for _, notifier := range notifiers {
notifier.BeforeDeleteDir(conn, dstPath)
}
}

func (notifiers notifierList) BeforeDownloadFile(conn *Conn, dstPath string) {
for _, notifier := range notifiers {
notifier.BeforeDownloadFile(conn, dstPath)
}
}

func (notifiers notifierList) AfterUserLogin(conn *Conn, userName, password string, passMatched bool, err error) {
for _, notifier := range notifiers {
notifier.AfterUserLogin(conn, userName, password, passMatched, err)
}
}

func (notifiers notifierList) AfterFilePut(conn *Conn, dstPath string, size int64, err error) {
for _, notifier := range notifiers {
notifier.AfterFilePut(conn, dstPath, size, err)
}
}

func (notifiers notifierList) AfterFileDeleted(conn *Conn, dstPath string, err error) {
for _, notifier := range notifiers {
notifier.AfterFileDeleted(conn, dstPath, err)
}
}

func (notifiers notifierList) AfterFileDownloaded(conn *Conn, dstPath string, size int64, err error) {
for _, notifier := range notifiers {
notifier.AfterFileDownloaded(conn, dstPath, size, err)
}
}

func (notifiers notifierList) AfterCurDirChanged(conn *Conn, oldCurDir, newCurDir string, err error) {
for _, notifier := range notifiers {
notifier.AfterCurDirChanged(conn, oldCurDir, newCurDir, err)
}
}

func (notifiers notifierList) AfterDirCreated(conn *Conn, dstPath string, err error) {
for _, notifier := range notifiers {
notifier.AfterDirCreated(conn, dstPath, err)
}
}

func (notifiers notifierList) AfterDirDeleted(conn *Conn, dstPath string, err error) {
for _, notifier := range notifiers {
notifier.AfterDirDeleted(conn, dstPath, err)
}
}

// NullNotifier implements Notifier
type NullNotifier struct{}

var (
_ Notifier = &NullNotifier{}
)

// BeforeLoginUser implements Notifier
func (NullNotifier) BeforeLoginUser(conn *Conn, userName string) {
}

// BeforePutFile implements Notifier
func (NullNotifier) BeforePutFile(conn *Conn, dstPath string) {
}

// BeforeDeleteFile implements Notifier
func (NullNotifier) BeforeDeleteFile(conn *Conn, dstPath string) {
}

// BeforeChangeCurDir implements Notifier
func (NullNotifier) BeforeChangeCurDir(conn *Conn, oldCurDir, newCurDir string) {
}

// BeforeCreateDir implements Notifier
func (NullNotifier) BeforeCreateDir(conn *Conn, dstPath string) {
}

// BeforeDeleteDir implements Notifier
func (NullNotifier) BeforeDeleteDir(conn *Conn, dstPath string) {
}

// BeforeDownloadFile implements Notifier
func (NullNotifier) BeforeDownloadFile(conn *Conn, dstPath string) {
}

// AfterUserLogin implements Notifier
func (NullNotifier) AfterUserLogin(conn *Conn, userName, password string, passMatched bool, err error) {
}

// AfterFilePut implements Notifier
func (NullNotifier) AfterFilePut(conn *Conn, dstPath string, size int64, err error) {
}

// AfterFileDeleted implements Notifier
func (NullNotifier) AfterFileDeleted(conn *Conn, dstPath string, err error) {
}

// AfterFileDownloaded implements Notifier
func (NullNotifier) AfterFileDownloaded(conn *Conn, dstPath string, size int64, err error) {
}

// AfterCurDirChanged implements Notifier
func (NullNotifier) AfterCurDirChanged(conn *Conn, oldCurDir, newCurDir string, err error) {
}

// AfterDirCreated implements Notifier
func (NullNotifier) AfterDirCreated(conn *Conn, dstPath string, err error) {
}

// AfterDirDeleted implements Notifier
func (NullNotifier) AfterDirDeleted(conn *Conn, dstPath string, err error) {
}

+ 9
- 0
vendor/goftp.io/server/perm.go View File

@@ -6,6 +6,7 @@ package server

import "os"

// Perm represents a perm interface
type Perm interface {
GetOwner(string) (string, error)
GetGroup(string) (string, error)
@@ -16,10 +17,12 @@ type Perm interface {
ChMode(string, os.FileMode) error
}

// SimplePerm implements Perm interface that all files are owned by special owner and group
type SimplePerm struct {
owner, group string
}

// NewSimplePerm creates a SimplePerm
func NewSimplePerm(owner, group string) *SimplePerm {
return &SimplePerm{
owner: owner,
@@ -27,26 +30,32 @@ func NewSimplePerm(owner, group string) *SimplePerm {
}
}

// GetOwner returns the file's owner
func (s *SimplePerm) GetOwner(string) (string, error) {
return s.owner, nil
}

// GetGroup returns the group of the file
func (s *SimplePerm) GetGroup(string) (string, error) {
return s.group, nil
}

// GetMode returns the file's mode
func (s *SimplePerm) GetMode(string) (os.FileMode, error) {
return os.ModePerm, nil
}

// ChOwner changed the file's owner
func (s *SimplePerm) ChOwner(string, string) error {
return nil
}

// ChGroup changed the file's group
func (s *SimplePerm) ChGroup(string, string) error {
return nil
}

// ChMode changed the file's mode
func (s *SimplePerm) ChMode(string, os.FileMode) error {
return nil
}

+ 17
- 10
vendor/goftp.io/server/server.go View File

@@ -35,7 +35,7 @@ type ServerOpts struct {
Hostname string

// Public IP of the server
PublicIp string
PublicIP string

// Passive ports
PassivePorts string
@@ -75,6 +75,7 @@ type Server struct {
ctx context.Context
cancel context.CancelFunc
feats string
notifiers notifierList
}

// ErrServerClosed is returned by ListenAndServe() or Serve() when a shutdown
@@ -115,9 +116,10 @@ func serverOptsWithDefaults(opts *ServerOpts) *ServerOpts {
newOpts.Auth = opts.Auth
}

newOpts.Logger = &StdLogger{}
if opts.Logger != nil {
newOpts.Logger = opts.Logger
} else {
newOpts.Logger = &StdLogger{}
}

newOpts.TLS = opts.TLS
@@ -125,7 +127,7 @@ func serverOptsWithDefaults(opts *ServerOpts) *ServerOpts {
newOpts.CertFile = opts.CertFile
newOpts.ExplicitFTPS = opts.ExplicitFTPS

newOpts.PublicIp = opts.PublicIp
newOpts.PublicIP = opts.PublicIP
newOpts.PassivePorts = opts.PassivePorts

return &newOpts
@@ -154,16 +156,27 @@ func NewServer(opts *ServerOpts) *Server {
s.ServerOpts = opts
s.listenTo = net.JoinHostPort(opts.Hostname, strconv.Itoa(opts.Port))
s.logger = opts.Logger
var curFeats = featCmds
if opts.TLS {
curFeats += " AUTH TLS\n PBSZ\n PROT\n"
}
s.feats = fmt.Sprintf(feats, curFeats)

return s
}

// RegisterNotifer registers a notifier
func (server *Server) RegisterNotifer(notifier Notifier) {
server.notifiers = append(server.notifiers, notifier)
}

// NewConn constructs a new object that will handle the FTP protocol over
// an active net.TCPConn. The TCP connection should already be open before
// it is handed to this functions. driver is an instance of FTPDriver that
// will handle all auth and persistence details.
func (server *Server) newConn(tcpConn net.Conn, driver Driver) *Conn {
c := new(Conn)
c.namePrefix = "/"
c.curDir = "/"
c.conn = tcpConn
c.controlReader = bufio.NewReader(tcpConn)
c.controlWriter = bufio.NewWriter(tcpConn)
@@ -173,8 +186,6 @@ func (server *Server) newConn(tcpConn net.Conn, driver Driver) *Conn {
c.sessionID = newSessionID()
c.logger = server.logger
c.tlsConfig = server.tlsConfig

driver.Init(c)
return c
}

@@ -204,7 +215,6 @@ func simpleTLSConfig(certFile, keyFile string) (*tls.Config, error) {
func (server *Server) ListenAndServe() error {
var listener net.Listener
var err error
var curFeats = featCmds

if server.ServerOpts.TLS {
server.tlsConfig, err = simpleTLSConfig(server.CertFile, server.KeyFile)
@@ -212,8 +222,6 @@ func (server *Server) ListenAndServe() error {
return err
}

curFeats += " AUTH TLS\n PBSZ\n PROT\n"

if server.ServerOpts.ExplicitFTPS {
listener, err = net.Listen("tcp", server.listenTo)
} else {
@@ -225,7 +233,6 @@ func (server *Server) ListenAndServe() error {
if err != nil {
return err
}
server.feats = fmt.Sprintf(feats, curFeats)

sessionID := ""
server.logger.Printf(sessionID, "%s listening on %d", server.Name, server.Port)


+ 7
- 6
vendor/goftp.io/server/socket.go View File

@@ -134,24 +134,25 @@ func isErrorAddressAlreadyInUse(err error) bool {
return false
}

func newPassiveSocket(host string, port func() int, logger Logger, sessionID string, tlsConfig *tls.Config) (DataSocket, error) {
func (conn *Conn) newPassiveSocket() (DataSocket, error) {
socket := new(ftpPassiveSocket)
socket.ingress = make(chan []byte)
socket.egress = make(chan []byte)
socket.logger = logger
socket.host = host
socket.tlsConfig = tlsConfig
socket.logger = conn.logger
socket.host = conn.passiveListenIP()
socket.tlsConfig = conn.tlsConfig
const retries = 10
var err error
for i := 1; i <= retries; i++ {
socket.port = port()
err = socket.GoListenAndServe(sessionID)
socket.port = conn.PassivePort()
err = socket.GoListenAndServe(conn.sessionID)
if err != nil && socket.port != 0 && isErrorAddressAlreadyInUse(err) {
// choose a different port on error already in use
continue
}
break
}
conn.dataConn = socket
return socket, err
}



+ 1
- 1
vendor/modules.txt View File

@@ -70,7 +70,7 @@ github.com/syndtr/goleveldb/leveldb/util
github.com/unknwon/com
# github.com/unknwon/goconfig v0.0.0-20190425194916-3dba17dd7b9e
github.com/unknwon/goconfig
# goftp.io/server v0.3.3-0.20200206033707-57b389cc6571
# goftp.io/server v0.3.5-0.20200428022247-5cd49dc54bdb
goftp.io/server
# golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
golang.org/x/crypto/argon2


Loading…
Cancel
Save