aboutsummaryrefslogtreecommitdiff
path: root/dht/options.go
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2018-02-09 08:42:22 +0000
committerFelix Hanley <felix@userspace.com.au>2018-02-09 08:42:22 +0000
commit2ded0704c8f675c3d92cf2b4874a32c65faf2553 (patch)
treec3b437cbe7129ea300d7a98e438b0f5fd3fd8344 /dht/options.go
parentbe4f4b36cc7fb46c70364d524d64c7188c1ae0f3 (diff)
downloaddhtsearch-2ded0704c8f675c3d92cf2b4874a32c65faf2553.tar.gz
dhtsearch-2ded0704c8f675c3d92cf2b4874a32c65faf2553.tar.bz2
Basic DHT functions
Diffstat (limited to 'dht/options.go')
-rw-r--r--dht/options.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/dht/options.go b/dht/options.go
new file mode 100644
index 0000000..03a85bf
--- /dev/null
+++ b/dht/options.go
@@ -0,0 +1,47 @@
+package dht
+
+import (
+ "github.com/felix/logger"
+)
+
+type Option func(*Node) error
+
+// SetAddress sets the IP address to listen on
+func SetAddress(ip string) Option {
+ return func(n *Node) error {
+ n.address = ip
+ return nil
+ }
+}
+
+// SetPort sets the port to listen on
+func SetPort(p int) Option {
+ return func(n *Node) error {
+ n.port = p
+ return nil
+ }
+}
+
+// SetWorkers sets the number of workers
+func SetWorkers(c int) Option {
+ return func(n *Node) error {
+ n.workers = make([]*dhtWorker, c)
+ return nil
+ }
+}
+
+// SetUDPTimeout sets the number of seconds to wait for UDP connections
+func SetUDPTimeout(s int) Option {
+ return func(n *Node) error {
+ n.udpTimeout = s
+ return nil
+ }
+}
+
+// SetLogger sets the number of workers
+func SetLogger(l logger.Logger) Option {
+ return func(n *Node) error {
+ n.log = l
+ return nil
+ }
+}