restructure stuff

This commit is contained in:
dd dd 2024-07-26 21:21:50 +02:00
parent 4f2f788c11
commit 1dc506a1f7
4 changed files with 6 additions and 8 deletions

View File

@ -11,8 +11,7 @@ const KindEphemeralEvent int = 38333
// EventSigner represents a signer that can create and sign events. // EventSigner represents a signer that can create and sign events.
// //
// EventSigner provides methods for creating unsigned events, creating signed events, // EventSigner provides methods for creating unsigned events, creating signed events
// and decrypting and writing events received from an exit node.
type EventSigner struct { type EventSigner struct {
PublicKey string PublicKey string
privateKey string privateKey string

View File

@ -166,16 +166,15 @@ func (s *Server) handleConnect(ctx context.Context, conn net.Conn, req *Request)
} else { } else {
ctx = ctx_ ctx = ctx_
} }
// Attempt to connect
dial := s.config.Dial
ch := make(chan net.Conn) ch := make(chan net.Conn)
// Attempt to connect
connectionID := uuid.New() connectionID := uuid.New()
options := netstr.DialOptions{ options := netstr.DialOptions{
Pool: s.pool, Pool: s.pool,
PublicAddress: s.config.entryConfig.PublicAddress, PublicAddress: s.config.entryConfig.PublicAddress,
ConnectionID: connectionID, ConnectionID: connectionID,
} }
dial := s.config.Dial
if dial == nil { if dial == nil {
if s.tcpListener != nil { if s.tcpListener != nil {
s.tcpListener.AddConnectChannel(connectionID, ch) s.tcpListener.AddConnectChannel(connectionID, ch)

View File

@ -99,7 +99,7 @@ func New(conf *Config, pool *nostr.SimplePool, config *config.EntryConfig) (*Ser
pool: pool, pool: pool,
} }
if conf.entryConfig.PublicAddress != "" { if conf.entryConfig.PublicAddress != "" {
listener, err := NewTCPListener() listener, err := NewTCPListener(conf.entryConfig.PublicAddress)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -12,8 +12,8 @@ type TCPListener struct {
connectChannels *xsync.MapOf[string, chan net.Conn] // todo -- use [16]byte for uuid instead of string connectChannels *xsync.MapOf[string, chan net.Conn] // todo -- use [16]byte for uuid instead of string
} }
func NewTCPListener() (*TCPListener, error) { func NewTCPListener(address string) (*TCPListener, error) {
l, err := net.Listen("tcp", ":1234") l, err := net.Listen("tcp", address)
if err != nil { if err != nil {
return nil, err return nil, err
} }