Skip to content

Commit

Permalink
Putting everything at the root
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Clairambault committed May 9, 2020
1 parent ac634bd commit bb1a7ee
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 49 deletions.
4 changes: 2 additions & 2 deletions server/client_handler.go → client_handler.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package server is the core of the library
package server
package ftpserver

import (
"bufio"
Expand All @@ -10,7 +10,7 @@ import (
"strings"
"time"

"github.com/fclairamb/ftpserver/server/log"
"github.com/fclairamb/ftpserver/log"

"github.com/spf13/afero"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/client_handler_test.go → client_handler_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests
package ftpserver

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion server/consts.go → consts.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package server provides all the tools to build your own FTP server: The core library and the driver.
package server
package ftpserver

// from @stevenh's PR proposal
// https://github.com/fclairamb/ftpserver/blob/becc125a0770e3b670c4ced7e7bd12594fb024ff/server/consts.go
Expand Down
2 changes: 1 addition & 1 deletion server/driver.go → driver.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package server provides all the tools to build your own FTP server: The core library and the driver.
package server
package ftpserver

import (
"crypto/tls"
Expand Down
23 changes: 11 additions & 12 deletions tests/test_driver.go → driver_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package tests brings all the logic to test the server without messing up the main code
package tests
package ftpserver

import (
"crypto/tls"
Expand All @@ -10,26 +10,25 @@ import (
gklog "github.com/go-kit/kit/log"
"github.com/spf13/afero"

"github.com/fclairamb/ftpserver/server"
"github.com/fclairamb/ftpserver/server/log"
"github.com/fclairamb/ftpserver/log"
)

// NewTestServer provides a test server with or without debugging
func NewTestServer(debug bool) *server.FtpServer {
func NewTestServer(debug bool) *FtpServer {
return NewTestServerWithDriver(&ServerDriver{Debug: debug})
}

// NewTestServerWithDriver provides a server instantiated with some settings
func NewTestServerWithDriver(driver *ServerDriver) *server.FtpServer {
func NewTestServerWithDriver(driver *ServerDriver) *FtpServer {
if driver.Settings == nil {
driver.Settings = &server.Settings{}
driver.Settings = &Settings{}
}

if driver.Settings.ListenAddr == "" {
driver.Settings.ListenAddr = "127.0.0.1:0"
}

s := server.NewFtpServer(driver)
s := NewFtpServer(driver)

// If we are in debug mode, we should log things
if driver.Debug {
Expand All @@ -53,7 +52,7 @@ type ServerDriver struct {
Debug bool // To display connection logs information
TLS bool

Settings *server.Settings // Settings
Settings *Settings // Settings
FileOverride afero.File
}

Expand All @@ -76,14 +75,14 @@ func NewClientDriver() *ClientDriver {
}

// WelcomeUser is the very first message people will see
func (driver *ServerDriver) WelcomeUser(cc server.ClientContext) (string, error) {
func (driver *ServerDriver) WelcomeUser(cc ClientContext) (string, error) {
cc.SetDebug(driver.Debug)
// This will remain the official name for now
return "TEST Server", nil
}

// AuthUser with authenticate users
func (driver *ServerDriver) AuthUser(cc server.ClientContext, user, pass string) (afero.Fs, error) {
func (driver *ServerDriver) AuthUser(cc ClientContext, user, pass string) (afero.Fs, error) {
if user == "test" && pass == "test" {
clientdriver := NewClientDriver()

Expand All @@ -98,12 +97,12 @@ func (driver *ServerDriver) AuthUser(cc server.ClientContext, user, pass string)
}

// UserLeft is called when the user disconnects
func (driver *ServerDriver) UserLeft(cc server.ClientContext) {
func (driver *ServerDriver) UserLeft(cc ClientContext) {

}

// GetSettings fetches the basic server settings
func (driver *ServerDriver) GetSettings() (*server.Settings, error) {
func (driver *ServerDriver) GetSettings() (*Settings, error) {
return driver.Settings, nil
}

Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ require (
github.com/go-kit/kit v0.10.0
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/naoina/go-stringutil v0.1.0 // indirect
github.com/naoina/toml v0.1.1
github.com/secsy/goftp v0.0.0-20190720192957-f31499d7c79a
github.com/spf13/afero v1.2.2
gopkg.in/dutchcoders/goftp.v1 v1.0.0-20170301105846-ed59a591ce14
Expand Down
2 changes: 1 addition & 1 deletion server/handle_auth.go → handle_auth.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package server provides all the tools to build your own FTP server: The core library and the driver.
package server
package ftpserver

import "fmt"

Expand Down
2 changes: 1 addition & 1 deletion tests/handle_auth_test.go → handle_auth_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests
package ftpserver

import (
"crypto/tls"
Expand Down
2 changes: 1 addition & 1 deletion server/handle_dirs.go → handle_dirs.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package server provides all the tools to build your own FTP server: The core library and the driver.
package server
package ftpserver

import (
"fmt"
Expand Down
8 changes: 3 additions & 5 deletions tests/handle_dirs_test.go → handle_dirs_test.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package tests
package ftpserver

import (
"runtime"
"strings"
"testing"

"gopkg.in/dutchcoders/goftp.v1"

"github.com/fclairamb/ftpserver/server"
)

const DirKnown = "known"

// TestDirAccess relies on LIST of files listing
func TestDirListing(t *testing.T) {
s := NewTestServerWithDriver(&ServerDriver{Debug: true, Settings: &server.Settings{DisableMLSD: true}})
s := NewTestServerWithDriver(&ServerDriver{Debug: true, Settings: &Settings{DisableMLSD: true}})
defer s.Stop()

var connErr error
Expand Down Expand Up @@ -60,7 +58,7 @@ func TestDirListing(t *testing.T) {
}

func TestDirListingPathArg(t *testing.T) {
s := NewTestServerWithDriver(&ServerDriver{Debug: true, Settings: &server.Settings{DisableMLSD: true}})
s := NewTestServerWithDriver(&ServerDriver{Debug: true, Settings: &Settings{DisableMLSD: true}})
defer s.Stop()

var connErr error
Expand Down
2 changes: 1 addition & 1 deletion server/handle_files.go → handle_files.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package server provides all the tools to build your own FTP server: The core library and the driver.
package server
package ftpserver

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion tests/validation_test.go → handle_files_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests
package ftpserver

import (
"regexp"
Expand Down
2 changes: 1 addition & 1 deletion server/handle_misc.go → handle_misc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package server provides all the tools to build your own FTP server: The core library and the driver.
package server
package ftpserver

import (
"bufio"
Expand Down
6 changes: 2 additions & 4 deletions tests/misc_commands_test.go → handle_misc_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests
package ftpserver

import (
"strings"
Expand All @@ -7,8 +7,6 @@ import (
"time"

"github.com/secsy/goftp"

"github.com/fclairamb/ftpserver/server"
)

func TestSiteCommand(t *testing.T) {
Expand Down Expand Up @@ -50,7 +48,7 @@ func TestSiteCommand(t *testing.T) {

// florent(2018-01-14): #58: IDLE timeout: Testing timeout
func TestIdleTimeout(t *testing.T) {
s := NewTestServerWithDriver(&ServerDriver{Debug: true, Settings: &server.Settings{IdleTimeout: 2}})
s := NewTestServerWithDriver(&ServerDriver{Debug: true, Settings: &Settings{IdleTimeout: 2}})
defer s.Stop()

conf := goftp.Config{
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions server/server.go → server.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Package server provides all the tools to build your own FTP server: The core library and the driver.
package server
package ftpserver

import (
"fmt"
"net"

"github.com/fclairamb/ftpserver/server/log"
"github.com/fclairamb/ftpserver/log"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion server/server_test.go → server_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package ftpserver

import "testing"

Expand Down
5 changes: 0 additions & 5 deletions tests/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion server/transfer_active.go → transfer_active.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package server provides all the tools to build your own FTP server: The core library and the driver.
package server
package ftpserver

import (
"errors"
Expand Down
4 changes: 2 additions & 2 deletions server/transfer_pasv.go → transfer_pasv.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package server provides all the tools to build your own FTP server: The core library and the driver.
package server
package ftpserver

import (
"crypto/tls"
Expand All @@ -9,7 +9,7 @@ import (
"strings"
"time"

"github.com/fclairamb/ftpserver/server/log"
"github.com/fclairamb/ftpserver/log"
)

// Active/Passive transfer connection handler
Expand Down
8 changes: 3 additions & 5 deletions tests/transfer_test.go → transfer_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests
package ftpserver

import (
"crypto/sha256"
Expand All @@ -12,8 +12,6 @@ import (
"testing"

"github.com/secsy/goftp"

"github.com/fclairamb/ftpserver/server"
)

func createTemporaryFile(t *testing.T, targetSize int) *os.File {
Expand Down Expand Up @@ -107,14 +105,14 @@ func ftpDelete(t *testing.T, ftp *goftp.Client, filename string) {

// TestTransfer validates the upload of file in both active and passive mode
func TestTransfer(t *testing.T) {
s := NewTestServerWithDriver(&ServerDriver{Debug: true, Settings: &server.Settings{ActiveTransferPortNon20: true}})
s := NewTestServerWithDriver(&ServerDriver{Debug: true, Settings: &Settings{ActiveTransferPortNon20: true}})
defer s.Stop()

testTransferOnConnection(t, s, false)
testTransferOnConnection(t, s, true)
}

func testTransferOnConnection(t *testing.T, server *server.FtpServer, active bool) {
func testTransferOnConnection(t *testing.T, server *FtpServer, active bool) {
conf := goftp.Config{
User: "test",
Password: "test",
Expand Down

0 comments on commit bb1a7ee

Please sign in to comment.