release v0.3.0

This commit is contained in:
2018-04-20 20:40:37 +08:00
parent e79842be6f
commit fe8e7eacfd
15 changed files with 93 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
Copyright (c) 2008 James Healy
Copyright (c) 2018 Goftp Authors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

23
auth.go
View File

@@ -1,5 +1,28 @@
// Copyright 2018 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
// Auth is an interface to auth your ftp user login.
type Auth interface {
CheckPasswd(string, string) (bool, error)
}
var (
_ Auth = &SimpleAuth{}
)
// SimpleAuth implements Auth interface to provide a memory user login auth
type SimpleAuth struct {
Name string
Password string
}
// CheckPasswd will check user's password
func (a *SimpleAuth) CheckPasswd(name, pass string) (bool, error) {
if name != a.Name || pass != a.Password {
return false, nil
}
return true, nil
}

10
cmd.go
View File

@@ -1,11 +1,7 @@
/*
http://tools.ietf.org/html/rfc959
// Copyright 2018 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.
http://www.faqs.org/rfcs/rfc2389.html
http://www.faqs.org/rfcs/rfc959.html
http://tools.ietf.org/html/rfc2428
*/
package server
import (

View File

@@ -1,3 +1,7 @@
// Copyright 2018 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
import "testing"

View File

@@ -1,3 +1,7 @@
// Copyright 2018 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
import (
@@ -9,12 +13,11 @@ import (
"fmt"
"io"
"log"
mrand "math/rand"
"net"
"path/filepath"
"strconv"
"strings"
mrand "math/rand"
)
const (

View File

@@ -1,3 +1,7 @@
// Copyright 2018 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
import (

14
doc.go Normal file
View File

@@ -0,0 +1,14 @@
// Copyright 2018 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.
/*
http://tools.ietf.org/html/rfc959
http://www.faqs.org/rfcs/rfc2389.html
http://www.faqs.org/rfcs/rfc959.html
http://tools.ietf.org/html/rfc2428
*/
package server

View File

@@ -1,14 +1,18 @@
// Copyright 2018 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
import "io"
// For each client that connects to the server, a new FTPDriver is required.
// DriverFactory is a driver factory to create driver. For each client that connects to the server, a new FTPDriver is required.
// Create an implementation if this interface and provide it to FTPServer.
type DriverFactory interface {
NewDriver() (Driver, error)
}
// You will create an implementation of this interface that speaks to your
// Driver is an interface that you will create an implementation that speaks to your
// 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 {
@@ -52,6 +56,6 @@ type Driver interface {
GetFile(string, int64) (int64, io.ReadCloser, error)
// params - destination path, an io.Reader containing the file data
// returns - the number of bytes writen and the first error encountered while writing, if any.
// returns - the number of bytes writen and the first error encountered while writing, if any.
PutFile(string, io.Reader, bool) (int64, error)
}

View File

@@ -1,3 +1,7 @@
// Copyright 2018 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
import "os"

View File

@@ -1,3 +1,7 @@
// Copyright 2018 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
import (

View File

@@ -1,3 +1,7 @@
// Copyright 2018 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
import (

View File

@@ -1,3 +1,7 @@
// Copyright 2018 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
import "os"

View File

@@ -1,3 +1,7 @@
// Copyright 2018 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
import (
@@ -9,7 +13,7 @@ import (
// Version returns the library version
func Version() string {
return "0.2.3"
return "0.3.0"
}
// ServerOpts contains parameters for server.NewServer()
@@ -230,7 +234,7 @@ func (server *Server) ListenAndServe() error {
return nil
}
// Gracefully stops a server. Already connected clients will retain their connections
// Shutdown will gracefully stop a server. Already connected clients will retain their connections
func (server *Server) Shutdown() error {
if server.listener != nil {
return server.listener.Close()

View File

@@ -1,3 +1,7 @@
// Copyright 2018 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_test
import (
@@ -12,18 +16,6 @@ import (
"github.com/stretchr/testify/assert"
)
type TestAuth struct {
Name string
Password string
}
func (a *TestAuth) CheckPasswd(name, pass string) (bool, error) {
if name != a.Name || pass != a.Password {
return false, nil
}
return true, nil
}
func runServer(t *testing.T, execute func()) {
os.MkdirAll("./testdata", os.ModePerm)
@@ -35,7 +27,7 @@ func runServer(t *testing.T, execute func()) {
Perm: perm,
},
Port: 2121,
Auth: &TestAuth{
Auth: &server.SimpleAuth{
Name: "admin",
Password: "admin",
},

View File

@@ -1,3 +1,7 @@
// Copyright 2018 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
import (
@@ -8,7 +12,7 @@ import (
"sync"
)
// A data socket is used to send non-control data between the client and
// DataSocket describes a data socket is used to send non-control data between the client and
// server.
type DataSocket interface {
Host() string