Refactor the Authenticator interface to a struct

This commit is contained in:
世界 2023-12-08 14:52:58 +08:00
parent 231d7607bc
commit 0f7de716ac
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 17 additions and 25 deletions

View file

@ -21,7 +21,7 @@ import (
type Handler = N.TCPConnectionHandler
func HandleConnection(ctx context.Context, conn net.Conn, reader *std_bufio.Reader, authenticator auth.Authenticator, handler Handler, metadata M.Metadata) error {
func HandleConnection(ctx context.Context, conn net.Conn, reader *std_bufio.Reader, authenticator *auth.Authenticator, handler Handler, metadata M.Metadata) error {
var httpClient *http.Client
for {
request, err := ReadRequest(reader)

View file

@ -93,7 +93,7 @@ func ClientHandshake5(conn io.ReadWriter, command byte, destination M.Socksaddr,
return response, err
}
func HandleConnection(ctx context.Context, conn net.Conn, authenticator auth.Authenticator, handler Handler, metadata M.Metadata) error {
func HandleConnection(ctx context.Context, conn net.Conn, authenticator *auth.Authenticator, handler Handler, metadata M.Metadata) error {
version, err := rw.ReadByte(conn)
if err != nil {
return err
@ -101,7 +101,7 @@ func HandleConnection(ctx context.Context, conn net.Conn, authenticator auth.Aut
return HandleConnection0(ctx, conn, version, authenticator, handler, metadata)
}
func HandleConnection0(ctx context.Context, conn net.Conn, version byte, authenticator auth.Authenticator, handler Handler, metadata M.Metadata) error {
func HandleConnection0(ctx context.Context, conn net.Conn, version byte, authenticator *auth.Authenticator, handler Handler, metadata M.Metadata) error {
switch version {
case socks4.Version:
request, err := socks4.ReadRequest0(conn)