aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2017-06-19 06:12:49 +0000
committerFelix Hanley <felix@userspace.com.au>2017-06-19 06:12:49 +0000
commit9e19584ff19a9dbdf6c024e21ff29383400fa80f (patch)
treede9f3c6b6b6996c6e91dd98b66a7c134dbea11c8
parent3c1f5a701982383d57a4e14add182a2ce6f5c18d (diff)
downloaddhtsearch-1.0.0.tar.gz
dhtsearch-1.0.0.tar.bz2
Minor clean ups1.0.0
-rw-r--r--config.go2
-rwxr-xr-xdht.go20
2 files changed, 9 insertions, 13 deletions
diff --git a/config.go b/config.go
index b4b9c81..099ce7f 100644
--- a/config.go
+++ b/config.go
@@ -45,7 +45,7 @@ func loadConfig() {
NoHttp: false,
HttpAddress: "localhost:6880",
Advanced: advancedConfig{
- RoutingTableSize: 1000,
+ RoutingTableSize: 4000,
MaxBtWorkers: 256,
MaxDhtWorkers: 256,
PeerCacheSize: 200,
diff --git a/dht.go b/dht.go
index 3e73122..01f511c 100755
--- a/dht.go
+++ b/dht.go
@@ -57,13 +57,13 @@ func (d *DHTNode) run(done <-chan struct{}) error {
d.conn = listener.(*net.UDPConn)
d.port = d.conn.LocalAddr().(*net.UDPAddr).Port
- if Config.Debug {
- fmt.Printf("We are node %x\n", d.id)
- fmt.Printf("Listening at %s:%d\n", d.address, d.port)
+ if !Config.Quiet {
+ fmt.Printf("DHT node listening at %s:%d\n", d.address, d.port)
}
// Packets off the network
d.packetsIn = make(chan packet)
+ // Packets onto the network
d.packetsOut = make(chan packet)
// Create a slab for allocation
@@ -78,16 +78,15 @@ func (d *DHTNode) run(done <-chan struct{}) error {
fmt.Println("UDP read error", err)
continue
}
+ // Chop and send
+ d.packetsIn <- packet{b[0:c], *addr}
+ byteSlab.Free(b)
dhtBytesIn.Add(int64(c))
dhtPacketsIn.Add(1)
- // Chop
- b = b[0:c]
- d.packetsIn <- packet{b, *addr}
- byteSlab.Free(b)
}
}()
- // Start writing packets from channel to conn
+ // Start writing packets from channel to DHT
go func() {
var p packet
for {
@@ -97,7 +96,7 @@ func (d *DHTNode) run(done <-chan struct{}) error {
b, err := d.conn.WriteToUDP(p.b, &p.raddr)
if err != nil {
dhtErrorPackets.Add(1)
- // TODO remove from kTAble
+ // TODO remove from kTable or add to blacklist?
if Config.Debug {
fmt.Printf("Error writing packet %s\n", err)
}
@@ -206,7 +205,6 @@ func (d *DHTNode) processFindNodeResults(rn *remoteNode, nodeList string) {
}
// We got a byte array in groups of 26 or 38
- var count int = 0
for i := 0; i < len(nodeList); i += nodeLength {
id := nodeList[i : i+ihLength]
addr := compactNodeInfoToString(nodeList[i+ihLength : i+nodeLength])
@@ -235,7 +233,5 @@ func (d *DHTNode) processFindNodeResults(rn *remoteNode, nodeList string) {
}
rn := newRemoteNode(*address, id)
d.kTable.add(rn)
- count = count + 1
- // TODO check size of kTable
}
}