diff --git a/README.md b/README.md
index 3d046d8..531db2c 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ Exit node [domain names](#nws-domain-names) make private services accessible to
### NWS main components
1. **Exit node**: A TCP reverse proxy that listens for incoming Nostr subscriptions and forwards the payload to your designated backend service.
-2. **Entry node**: Forwards TCP packets to the exit node using a SOCKS proxy and creates encrypted events for the exit node.
+2. **Entry node**: A SOCKS5 proxy that forwards TCP packets and creates encrypted events for the exit node.
@@ -117,5 +117,5 @@ If you don't want to use the `PUBLIC_ADDRESS` feature, no further configuration
PUBLIC_ADDRESS=':'
```
-- `PUBLIC_ADDRESS`: This can be set if the entry node is publicly available. When set, the entry node will additionally bind to this address. Exit node discovery will still be done using Nostr. Once a connection is established, this public address will be used to transmit further data.
+- `PUBLIC_ADDRESS`: This can be set if the entry node is publicly available. Exit node discovery will still be done using Nostr. Once a connection is established, this public address will be used to transmit further data. (`:`)
- `NOSTR_RELAYS`: A list of Nostr relays to publish events to. Used only if there is no relay data in the request.
diff --git a/config/config.go b/config/config.go
index cc9cec1..7c247dd 100644
--- a/config/config.go
+++ b/config/config.go
@@ -10,9 +10,8 @@ import (
)
type EntryConfig struct {
- NostrRelays []string `env:"NOSTR_RELAYS" envSeparator:";"`
- PublicAddress string `env:"PUBLIC_ADDRESS"`
- PublicAddressBind string `env:"PUBLIC_ADDRESS_BIND"`
+ NostrRelays []string `env:"NOSTR_RELAYS" envSeparator:";"`
+ PublicAddress string `env:"PUBLIC_ADDRESS"`
}
type ExitConfig struct {
diff --git a/socks5/socks5.go b/socks5/socks5.go
index 2667481..59aa00a 100644
--- a/socks5/socks5.go
+++ b/socks5/socks5.go
@@ -99,9 +99,14 @@ func New(conf *Config, pool *nostr.SimplePool, config *config.EntryConfig) (*Ser
pool: pool,
}
if conf.entryConfig.PublicAddress != "" {
- listener, err := NewTCPListener(conf.entryConfig.PublicAddressBind)
+ // parse host port
+ _, port, err := net.SplitHostPort(conf.entryConfig.PublicAddress)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf("failed to parse public address: %w", err)
+ }
+ listener, err := NewTCPListener(net.JoinHostPort(net.IP{0, 0, 0, 0}.String(), port))
+ if err != nil {
+ return nil, fmt.Errorf("failed to create tcp listener: %w", err)
}
go listener.Start()
server.tcpListener = listener
@@ -114,6 +119,7 @@ func New(conf *Config, pool *nostr.SimplePool, config *config.EntryConfig) (*Ser
return server, nil
}
+
func (s *Server) Configuration() (*Config, error) {
if s.config != nil {
return s.config, nil