From 698be9359ec9cccaa4693bf5b9eaac6ae6ecf261 Mon Sep 17 00:00:00 2001 From: Yves Junqueira Date: Sat, 30 Jun 2012 23:45:02 +0200 Subject: [PATCH] Move auxiliary methods to "nettools". Run gofmt --- addresses.go | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 addresses.go diff --git a/addresses.go b/addresses.go deleted file mode 100644 index 6092098..0000000 --- a/addresses.go +++ /dev/null @@ -1,23 +0,0 @@ -package bencode - -import "fmt" - -// These are not strictly bencode features, but often needed by both DHT and -// Torrent clients. - -func BinaryToDottedPort(port string) string { - return fmt.Sprintf("%d.%d.%d.%d:%d", port[0], port[1], port[2], port[3], - (uint16(port[4])<<8)|uint16(port[5])) -} - -// 97.98.99.100:25958 becames "abcdef". -func DottedPortToBinary(b string) string { - a := make([]byte, 6, 6) - var c uint16 - - fmt.Sscanf(b, "%d.%d.%d.%d:%d", &a[0], &a[1], &a[2], &a[3], &c) - a[4] = uint8(c >> 8) - a[5] = uint8(c) - - return string(a) -}