type ServerConfig struct {
// Listen address. Used if Conn is nil.
Addr string
+
+ // Set NodeId Manually. Caller must ensure that, if NodeId does not
+ // conform to DHT Security Extensions, that NoSecurity is also set. This
+ // should be given as a HEX string.
+ NodeIdHex string
+
Conn net.PacketConn
// Don't respond to queries from other nodes.
Passive bool
}
}
+func TestServerCustomNodeId(t *testing.T) {
+ customId := "5a3ce1c14e7a08645677bbd1cfe7d8f956d53256"
+ id, err := hex.DecodeString(customId)
+ assert.NoError(t, err)
+ // How to test custom *secure* Id when tester computers will have
+ // different Ids? Generate custom ids for local IPs and use
+ // mini-Id?
+ s, err := NewServer(&ServerConfig{
+ NodeIdHex: customId,
+ NoDefaultBootstrap: true,
+ })
+ require.NoError(t, err)
+ defer s.Close()
+ assert.Equal(t, string(id), s.ID())
+}
+
func TestAnnounceTimeout(t *testing.T) {
s, err := NewServer(&ServerConfig{
BootstrapNodes: []string{"1.2.3.4:5"},