mirror of
https://github.com/asmogo/nws.git
synced 2025-01-31 07:11:34 +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 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
|
||||||
|
@ -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)
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user