Skip to content
This repository was archived by the owner on Jul 8, 2020. It is now read-only.

Commit fe8e7ea

Browse files
committed
release v0.3.0
1 parent e79842b commit fe8e7ea

15 files changed

+93
-29
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2008 James Healy
1+
Copyright (c) 2018 Goftp Authors
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the

auth.go

+23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

7+
// Auth is an interface to auth your ftp user login.
38
type Auth interface {
49
CheckPasswd(string, string) (bool, error)
510
}
11+
12+
var (
13+
_ Auth = &SimpleAuth{}
14+
)
15+
16+
// SimpleAuth implements Auth interface to provide a memory user login auth
17+
type SimpleAuth struct {
18+
Name string
19+
Password string
20+
}
21+
22+
// CheckPasswd will check user's password
23+
func (a *SimpleAuth) CheckPasswd(name, pass string) (bool, error) {
24+
if name != a.Name || pass != a.Password {
25+
return false, nil
26+
}
27+
return true, nil
28+
}

cmd.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
/*
2-
http://tools.ietf.org/html/rfc959
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
34

4-
http://www.faqs.org/rfcs/rfc2389.html
5-
http://www.faqs.org/rfcs/rfc959.html
6-
7-
http://tools.ietf.org/html/rfc2428
8-
*/
95
package server
106

117
import (

cmd_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

37
import "testing"

conn.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

37
import (
@@ -9,12 +13,11 @@ import (
913
"fmt"
1014
"io"
1115
"log"
16+
mrand "math/rand"
1217
"net"
1318
"path/filepath"
1419
"strconv"
1520
"strings"
16-
17-
mrand "math/rand"
1821
)
1922

2023
const (

conn_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

37
import (

doc.go

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
/*
6+
http://tools.ietf.org/html/rfc959
7+
8+
http://www.faqs.org/rfcs/rfc2389.html
9+
http://www.faqs.org/rfcs/rfc959.html
10+
11+
http://tools.ietf.org/html/rfc2428
12+
*/
13+
14+
package server

driver.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

37
import "io"
48

5-
// For each client that connects to the server, a new FTPDriver is required.
9+
// DriverFactory is a driver factory to create driver. For each client that connects to the server, a new FTPDriver is required.
610
// Create an implementation if this interface and provide it to FTPServer.
711
type DriverFactory interface {
812
NewDriver() (Driver, error)
913
}
1014

11-
// You will create an implementation of this interface that speaks to your
15+
// Driver is an interface that you will create an implementation that speaks to your
1216
// chosen persistence layer. graval will create a new instance of your
1317
// driver for each client that connects and delegate to it as required.
1418
type Driver interface {
@@ -52,6 +56,6 @@ type Driver interface {
5256
GetFile(string, int64) (int64, io.ReadCloser, error)
5357

5458
// params - destination path, an io.Reader containing the file data
55-
// returns - the number of bytes writen and the first error encountered while writing, if any.
59+
// returns - the number of bytes writen and the first error encountered while writing, if any.
5660
PutFile(string, io.Reader, bool) (int64, error)
5761
}

fileinfo.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

37
import "os"

listformatter.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

37
import (

logger.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

37
import (

perm.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

37
import "os"

server.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

37
import (
@@ -9,7 +13,7 @@ import (
913

1014
// Version returns the library version
1115
func Version() string {
12-
return "0.2.3"
16+
return "0.3.0"
1317
}
1418

1519
// ServerOpts contains parameters for server.NewServer()
@@ -230,7 +234,7 @@ func (server *Server) ListenAndServe() error {
230234
return nil
231235
}
232236

233-
// Gracefully stops a server. Already connected clients will retain their connections
237+
// Shutdown will gracefully stop a server. Already connected clients will retain their connections
234238
func (server *Server) Shutdown() error {
235239
if server.listener != nil {
236240
return server.listener.Close()

server_test.go

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server_test
26

37
import (
@@ -12,18 +16,6 @@ import (
1216
"github.com/stretchr/testify/assert"
1317
)
1418

15-
type TestAuth struct {
16-
Name string
17-
Password string
18-
}
19-
20-
func (a *TestAuth) CheckPasswd(name, pass string) (bool, error) {
21-
if name != a.Name || pass != a.Password {
22-
return false, nil
23-
}
24-
return true, nil
25-
}
26-
2719
func runServer(t *testing.T, execute func()) {
2820
os.MkdirAll("./testdata", os.ModePerm)
2921

@@ -35,7 +27,7 @@ func runServer(t *testing.T, execute func()) {
3527
Perm: perm,
3628
},
3729
Port: 2121,
38-
Auth: &TestAuth{
30+
Auth: &server.SimpleAuth{
3931
Name: "admin",
4032
Password: "admin",
4133
},

socket.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2018 The goftp Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
15
package server
26

37
import (
@@ -8,7 +12,7 @@ import (
812
"sync"
913
)
1014

11-
// A data socket is used to send non-control data between the client and
15+
// DataSocket describes a data socket is used to send non-control data between the client and
1216
// server.
1317
type DataSocket interface {
1418
Host() string

0 commit comments

Comments
 (0)