mirror of
https://github.com/asmogo/nws.git
synced 2025-01-18 18:11:33 +00:00
restructure stuff
This commit is contained in:
parent
4f2f788c11
commit
1dc506a1f7
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user