Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug/marshall/file upload corruption #3

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
cf87fd3
First draft of MLST support
fclairamb Sep 1, 2017
c7d8f22
Merge branch 'master' into mlst-support
fclairamb Sep 23, 2017
4f96a7b
Merge branch 'master' into mlst-support
fclairamb Oct 9, 2017
7555550
Merge branch 'master' into mlst-support
fclairamb Oct 13, 2017
2c4c78f
Merge branch 'master' into mlst-support
fclairamb Oct 21, 2017
514b4bb
Merge branch 'master' into mlst-support
fclairamb Oct 30, 2017
589b031
Merge branch 'master' into mlst-support
fclairamb Nov 4, 2017
828e6a4
Merge branch 'master' into mlst-support
fclairamb Nov 5, 2017
d5c824b
Merge branch 'master' into mlst-support
fclairamb Nov 5, 2017
64ab784
Merge branch 'master' into mlst-support
fclairamb Nov 9, 2017
4fe1c5c
Merge branch 'master' of github.com:fclairamb/ftpserver into mlst-sup…
fclairamb Nov 10, 2017
ce30477
MLST support
fclairamb Nov 10, 2017
53b6596
Merge remote-tracking branch 'origin/mlst-support' into mlst-support
fclairamb Nov 10, 2017
4143650
Multi-arch build
fclairamb Nov 27, 2017
bc1643d
Multi-arch build
fclairamb Nov 27, 2017
5890a0b
Allow passing in an existing net.Listener and a public ip resolver.
marshallbrekka Dec 25, 2017
976aca6
Merge pull request #53 from wearefair/injectable-listener
fclairamb Dec 28, 2017
ac82983
Merge branches 'master' and 'win-test' of github.com:fclairamb/ftpser…
fclairamb Jan 9, 2018
5ca87f5
Cleanup
fclairamb Jan 9, 2018
50a52c1
Merge branches 'master' and 'mlst-support' of github.com:fclairamb/ft…
fclairamb Jan 9, 2018
873cdcc
Merge branches 'master' and 'mlst-support' of github.com:fclairamb/ft…
fclairamb Jan 9, 2018
f55c2eb
Fix: Replacing "-only-conf" by "-conf-only"
fclairamb Jan 9, 2018
7b9fad2
README: Fixing docker command
fclairamb Jan 10, 2018
48ab7ce
Merge branch 'master' into win-test
fclairamb Jan 10, 2018
89c32f8
Merge branch 'master' into mlst-support
fclairamb Jan 10, 2018
d9c9f68
Merge pull request #55 from fclairamb/win-test
fclairamb Jan 10, 2018
8ca0efb
#58: IDLE timeout: Default IDLE timeout will be set at 900 seconds
fclairamb Jan 14, 2018
cebc384
Fixed test
fclairamb Jan 14, 2018
c735603
Simplification
fclairamb Jan 14, 2018
5473343
Import rollback
fclairamb Jan 14, 2018
799977b
Merge branch 'master' into mlst-support
fclairamb Jan 16, 2018
bf70602
Merge pull request #59 from fclairamb/issue-58-idle-timeout
fclairamb Jan 16, 2018
8d78b1c
Merge branch 'master' into mlst-support
fclairamb Jan 16, 2018
e240d79
Issue #31: MLST Support
fclairamb Jan 20, 2018
4cb70aa
Issue #31: Changing listing of files through STAT command
fclairamb Jan 20, 2018
ff0b99d
Merge pull request #61 from fclairamb/issue-31-mlst-support
fclairamb Jan 20, 2018
d2ce42e
Merge pull request #31 from fclairamb/mlst-support
fclairamb Jan 22, 2018
9786c8b
add MLSx validation test
Feb 13, 2018
a8a712a
make a failing closer return the error to the client
Feb 13, 2018
d85caa4
Issue #64: Disabling bogus empty lines
fclairamb Feb 13, 2018
519c3d7
Restoring the debug mode in tests
fclairamb Feb 13, 2018
597bf07
refactor
Feb 13, 2018
d06e1a0
Merge pull request #68 from fclairamb/restore-debug-in-tests
fclairamb Feb 14, 2018
01ff65e
Merge branch 'master' into issue-64-MLSx-validation
fclairamb Feb 14, 2018
2868719
Merge branch 'master' into failing-closer-err
fclairamb Feb 14, 2018
348f5ea
Issue #66: Dealing with file issues
fclairamb Feb 15, 2018
d45c2d4
Integrated @mgenov proposed changes
fclairamb Feb 15, 2018
14874f3
Integrated @mgenov proposed changes
fclairamb Feb 15, 2018
97e59a1
Merge pull request #67 from fclairamb/issue-64-MLSx-validation
fclairamb Feb 16, 2018
9bf8796
Merge branch 'master' into pull-request-66
fclairamb Feb 16, 2018
e8c6168
Merge PR #71: Dealing with file access errors
fclairamb Feb 19, 2018
2612f74
Modify 226 transfer message to match what a vendor expects.
marshallbrekka Mar 22, 2018
712b740
Merge pull request #1 from wearefair/transfer-close-msg
marshallbrekka Mar 22, 2018
e537ecf
Allow passing in a listener wrapper function.
marshallbrekka Jan 22, 2018
4701835
Merge pull request #2 from wearefair/injectable-data-port-listener
marshallbrekka Mar 22, 2018
2e0b6ea
Debug: also write the file to a temporary disk location when uploading.
Jun 26, 2018
94b413e
Fix the logs
Jun 27, 2018
d1fe649
Fix logger
Jun 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .build-all-archs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

version=$(go version|grep -Eo go[0-9]\.[0-9])

if [ "$version" != "go1.9" ]; then
echo "Docker images are only generated for Go 1.9 and you have ${version}."
exit 0
fi

for params in "GOOS=linux GOARCH=amd64 EXT=" "GOOS=linux GOARCH=386" "GOOS=linux GOARCH=arm" "GOOS=darwin GOARCH=amd64" "GOOS=windows GOARCH=amd64 EXT=.exe" "GOOS=windows GOARCH=386"
do
export $params
echo -n "Building for OS=${GOOS} and ARCH=${GOARCH} ."
go get && echo -n "."
go build -o ftpserver-${GOOS}-${GOARCH}${EXT}
echo .
done
3 changes: 3 additions & 0 deletions .docker-create-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ echo "Docker repo: ${DOCKER_REPO}:${TRAVIS_COMMIT}"

DOCKER_NAME=${DOCKER_REPO}:${TRAVIS_COMMIT}

# Creating the settings.toml file
./ftpserver -conf-only -conf=settings.toml

docker build -t ${DOCKER_NAME} .

docker tag ${DOCKER_NAME} ${DOCKER_REPO}:travis-${TRAVIS_BUILD_NUMBER}
Expand Down
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ script:
- go test -race -v ./...
- go build -v
- ./.docker-create-upload.sh
- ./.build-all-archs.sh
deploy:
provider: releases
api_key:
secure: K2o6tz2pw9OeIqVMu0sO01+9QFXA6GxG90PG3les4FOMqOUxyYZDPorMqlXpmAKD0mJWzP8PuWPSBfT9zSN3FkUHsjKA3mwvpab04rjFGr5ccmm90EfVttFyzAY45fokSA3fJo5T3iGjPbmg8Qtey2ST7X8dmuTt2i2kzv30cE2rmCE2wUfGWmq2r43ygaJBTjYtUCowxkDYsm/86qx0NB9SAD7LRDEWc62bcc0+CJZtRE5XXG4YhDJxDJWgMSEdwPt3i/c4NqYhOGCoLpBAh77mgHLJKf0NaThLa3Z6vVKog4/dBxJGSu+QvqA7jS6S6Pm72wWvcUqSPzL2TMk8zvD2KND9q6RPdTn1MuzvARn+IZOf5ndGgDjilcNgCXuC2adOzuo7rbecmTSkbzgux+RGRixr93p13Vn4Nt/WqLMq2ftqAv/gvmAi3OntShcKv9487zML/tDIxdvXXf7fmJDKl59eBKVddrY1GjzdcNVU8l+UoenrXIJh6+sTKcxLDVoqGb34T9QLWLYEK9bqGcmSHy9MFmjE/vh4vu8K8Fgrcpb/GHruRCqpFWIS2SxQaPawc8zVtBMXOvpnb8839Bi0HtdbInE6FynOUgHQ87UyFgwwB6v5YFAOgSpStpPqVX5O4UWZ2vNI1N83qSnxZfOmiayAA1Z7zlPPZTNq4rY=
file: ftpserver
file_glob: true
file: ftpserver-*
skip_cleanup: true
on:
tags: true
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
FROM alpine:latest
EXPOSE 2121-2200
RUN mkdir -p /data
COPY sample/conf/settings.toml /etc/ftpserver.conf
COPY settings.toml /etc/ftpserver.conf
COPY ftpserver /bin/ftpserver
ENTRYPOINT [ "/bin/ftpserver", "-conf=/etc/ftpserver.conf", "-data=/data" ]
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ Note: this is a fork of [andrewarrow/paradise_ftp](https://github.com/andrewarro
* Small memory footprint
* Only relies on the standard library except for logging which uses [go-kit log](https://github.com/go-kit/kit/tree/master/log).
* Supported extensions:
* [MDTM](https://tools.ietf.org/html/rfc3659#page-8) - File Modification Time
* [MLST](https://tools.ietf.org/html/rfc3659#page-23) - Directory listing for maching processing
* [REST](https://tools.ietf.org/html/rfc3659#page-13) - Restart of interrupted transfer
* [SIZE](https://tools.ietf.org/html/rfc3659#page-11) - Size of a string
* [AUTH](https://tools.ietf.org/html/rfc2228#page-6) - Control session protection
* [PROT](https://tools.ietf.org/html/rfc2228#page-8) - Transfer protection
* [MDTM](https://tools.ietf.org/html/rfc3659#page-8) - File Modification Time
* [SIZE](https://tools.ietf.org/html/rfc3659#page-11) - Size of a file
* [REST](https://tools.ietf.org/html/rfc3659#page-13) - Restart of interrupted transfer
* [MLST](https://tools.ietf.org/html/rfc3659#page-23) - Simple file listing for machine processing
* [MLSD](https://tools.ietf.org/html/rfc3659#page-23) - Directory listing for machine processing

## Quick test with docker

Expand All @@ -41,7 +42,7 @@ container (less than 15MB image, based on alpine):
mkdir data

# Starting the sample FTP server
docker run -d -p 2121-2200:2121-2200 -v $(pwd)/data:/data fclairamb/ftpserver:travis-171
docker run --rm -d -p 2121-2200:2121-2200 -v $(pwd)/data:/data fclairamb/ftpserver

# Connecting to it and uploading a file
ftp ftp://test:test@localhost:2121
Expand Down
85 changes: 82 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main

import (
"flag"
"io/ioutil"
"os"
"os/signal"
"syscall"
Expand All @@ -18,9 +19,14 @@ var (
)

func main() {
// Arguments vars
var confFile, dataDir string
var onlyConf bool

// Parsing arguments
confFile := flag.String("conf", "sample/conf/settings.toml", "Configuration file")
dataDir := flag.String("data", "", "Data directory")
flag.StringVar(&confFile, "conf", "", "Configuration file")
flag.StringVar(&dataDir, "data", "", "Data directory")
flag.BoolVar(&onlyConf, "conf-only", false, "Only create the config")
flag.Parse()

// Setting up the logger
Expand All @@ -30,8 +36,27 @@ func main() {
"caller", log.DefaultCaller,
)

autoCreate := onlyConf

// The general idea here is that if you start it without any arg, you're probably doing a local quick&dirty run
// possibly on a windows machine, so we're better of just using a default file name and create the file.
if confFile == "" {
confFile = "settings.toml"
autoCreate = true
}

if autoCreate {
if _, err := os.Stat(confFile); err != nil && os.IsNotExist(err) {
level.Info(logger).Log("msg", "Not config file, creating one", "action", "conf_file.create", "confFile", confFile)

if err := ioutil.WriteFile(confFile, confFileContent(), 0644); err != nil {
level.Error(logger).Log("msg", "Couldn't create config file", "action", "conf_file.could_not_create", "confFile", confFile)
}
}
}

// Loading the driver
driver, err := sample.NewSampleDriver(*dataDir, *confFile)
driver, err := sample.NewSampleDriver(dataDir, confFile)

if err != nil {
level.Error(logger).Log("msg", "Could not load the driver", "err", err)
Expand All @@ -51,6 +76,11 @@ func main() {
go signalHandler()

// Blocking call, behaving similarly to the http.ListenAndServe
if onlyConf {
level.Error(logger).Log("msg", "Only creating conf")
return
}

if err := ftpServer.ListenAndServe(); err != nil {
level.Error(logger).Log("msg", "Problem listening", "err", err)
}
Expand All @@ -67,3 +97,52 @@ func signalHandler() {
}
}
}

func confFileContent() []byte {
str := `# ftpserver configuration file
#
# These are all the config parameters with their default values. If not present,

# Max number of control connections to accept
# max_connections = 0
max_connections = 10

[server]
# Address to listen on
# listen_host = "0.0.0.0"

# Port to listen on
# listen_port = 2121

# Public host to expose in the passive connection
# public_host = ""

# Idle timeout time
# idle_timeout = 900

# Data port range from 10000 to 15000
# [dataPortRange]
# start = 2122
# end = 2200

[server.dataPortRange]
start = 2122
end = 2200

[[users]]
user="fclairamb"
pass="floflo"
dir="shared"

[[users]]
user="test"
pass="test"
dir="shared"

[[users]]
user="mcardon"
pass="marmar"
dir="marie"
`
return []byte(str)
}
30 changes: 0 additions & 30 deletions sample/certs/mycert.crt

This file was deleted.

51 changes: 0 additions & 51 deletions sample/certs/mycert.key

This file was deleted.

41 changes: 0 additions & 41 deletions sample/conf/settings.toml

This file was deleted.

Loading