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 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

View File

@ -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)

View File

@ -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
}

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
}
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
}