Skip to content

Commit 202d132

Browse files
committed
prefix interface methods with Socks5
1 parent 66c98c1 commit 202d132

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

server/authenticator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (a UserPassAuthenticator) Socks5Authenticate(r io.Reader, w io.Writer, am s
4747
if _, err = io.ReadFull(r, pwdBytes); err == nil {
4848
usr := string(usrBytes)
4949
err = socks5.ErrAuthFailed
50-
if a.Credentials.Valid(usr, string(pwdBytes), userAddr) {
50+
if a.Credentials.Socks5ValidateCredentials(usr, string(pwdBytes), userAddr) {
5151
err = nil
5252
resultcode = socks5.AuthSuccess
5353
username = usr

server/credentialstore.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ package server
33
// CredentialStore is used to support user/pass authentication optional network addr
44
// if you want to limit user network addr,you can refuse it.
55
type CredentialStore interface {
6-
Valid(user, password, userAddr string) bool
6+
Socks5ValidateCredentials(user, password, userAddr string) bool
77
}
88

99
// StaticCredentials enables using a map directly as a credential store
1010
type StaticCredentials map[string]string
1111

12-
// Valid implement interface CredentialStore
13-
func (s StaticCredentials) Valid(user, password, _ string) bool {
12+
// Socks5ValidateCredentials implement interface CredentialStore
13+
func (s StaticCredentials) Socks5ValidateCredentials(user, password, _ string) bool {
1414
pass, ok := s[user]
1515
return ok && password == pass
1616
}

server/dialerselector.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package server
22

33
import "github.com/linkdata/socks5"
44

5-
// DialerSelector returns the ContextDialer to use.
5+
// A socks5.DialerSelector returns the ContextDialer to use.
66
type DialerSelector interface {
7-
// SelectDialer returns the ContextDialer to use.
8-
SelectDialer(am socks5.AuthMethod, username, network, address string) (cd socks5.ContextDialer, err error)
7+
// Socks5SelectDialer returns the ContextDialer to use.
8+
Socks5SelectDialer(am socks5.AuthMethod, username, network, address string) (cd socks5.ContextDialer, err error)
99
}

server/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
type dialerselector struct{}
1919

20-
func (dialerselector) SelectDialer(am socks5.AuthMethod, username, network, address string) (cd socks5.ContextDialer, err error) {
20+
func (dialerselector) Socks5SelectDialer(am socks5.AuthMethod, username, network, address string) (cd socks5.ContextDialer, err error) {
2121
return
2222
}
2323

server/session.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type session struct {
1717
func (sess *session) DialContext(ctx context.Context, network, addr string) (conn net.Conn, err error) {
1818
var dialer socks5.ContextDialer
1919
if sess.Server.DialerSelector != nil {
20-
dialer, err = sess.Server.DialerSelector.SelectDialer(sess.authMethod, sess.username, network, addr)
20+
dialer, err = sess.Server.DialerSelector.Socks5SelectDialer(sess.authMethod, sess.username, network, addr)
2121
}
2222
if err == nil {
2323
if dialer == nil {

0 commit comments

Comments
 (0)