From 1dc506a1f732ce8f4eb870c9b3b122c98fc02805 Mon Sep 17 00:00:00 2001 From: dd dd Date: Fri, 26 Jul 2024 21:21:50 +0200 Subject: [PATCH] restructure stuff --- protocol/signer.go | 3 +-- socks5/request.go | 5 ++--- socks5/socks5.go | 2 +- socks5/tcp.go | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/protocol/signer.go b/protocol/signer.go index f696b97..68050a3 100644 --- a/protocol/signer.go +++ b/protocol/signer.go @@ -11,8 +11,7 @@ const KindEphemeralEvent int = 38333 // EventSigner represents a signer that can create and sign events. // -// EventSigner provides methods for creating unsigned events, creating signed events, -// and decrypting and writing events received from an exit node. +// EventSigner provides methods for creating unsigned events, creating signed events type EventSigner struct { PublicKey string privateKey string diff --git a/socks5/request.go b/socks5/request.go index b1d74af..194115f 100644 --- a/socks5/request.go +++ b/socks5/request.go @@ -166,16 +166,15 @@ func (s *Server) handleConnect(ctx context.Context, conn net.Conn, req *Request) } else { ctx = ctx_ } - - // Attempt to connect - dial := s.config.Dial ch := make(chan net.Conn) + // Attempt to connect connectionID := uuid.New() options := netstr.DialOptions{ Pool: s.pool, PublicAddress: s.config.entryConfig.PublicAddress, ConnectionID: connectionID, } + dial := s.config.Dial if dial == nil { if s.tcpListener != nil { s.tcpListener.AddConnectChannel(connectionID, ch) diff --git a/socks5/socks5.go b/socks5/socks5.go index 475ecf6..dca76a0 100644 --- a/socks5/socks5.go +++ b/socks5/socks5.go @@ -99,7 +99,7 @@ func New(conf *Config, pool *nostr.SimplePool, config *config.EntryConfig) (*Ser pool: pool, } if conf.entryConfig.PublicAddress != "" { - listener, err := NewTCPListener() + listener, err := NewTCPListener(conf.entryConfig.PublicAddress) if err != nil { return nil, err } diff --git a/socks5/tcp.go b/socks5/tcp.go index 9edef36..813dfe8 100644 --- a/socks5/tcp.go +++ b/socks5/tcp.go @@ -12,8 +12,8 @@ type TCPListener struct { connectChannels *xsync.MapOf[string, chan net.Conn] // todo -- use [16]byte for uuid instead of string } -func NewTCPListener() (*TCPListener, error) { - l, err := net.Listen("tcp", ":1234") +func NewTCPListener(address string) (*TCPListener, error) { + l, err := net.Listen("tcp", address) if err != nil { return nil, err }