Permalink
Browse files

Time.UnixNano() requires all 64 bits but Record stores only 56, so ro…

…und it to microseconds
  • Loading branch information...
1 parent 0267ac1 commit c5f466e2c2085351c09a2c5ebaef857909d0cfbf @temoto committed Dec 9, 2012
Showing with 5 additions and 3 deletions.
  1. +1 −1 oakmole-cat/main.go
  2. +1 −1 oakmole-radar/net.go
  3. +3 −1 oakmole/storage_test.go
View
@@ -97,7 +97,7 @@ func main() {
return
}
- t := time.Unix(int64(record.Timestamp/1e9), int64(record.Timestamp%1e9))
+ t := time.Unix(int64(record.Timestamp/1e6), int64(record.Timestamp%1e6))
s := fmt.Sprintf("%s: %s\n\n", t.Format(time.RFC3339), string(record.Body))
os.Stdout.WriteString(s)
case <-stopWriter:
View
@@ -80,7 +80,7 @@ func connectionHandler(conn *net.TCPConn, out chan *oakmole.Record) {
buffer = buffer[:totalSize]
record := &oakmole.Record{
- Timestamp: uint64(timeBegin.UnixNano()),
+ Timestamp: uint64(timeBegin.UnixNano() / 1000),
LocalIP: addrLocal.IP,
RemoteIP: addrRemote.IP,
Body: buffer,
View
@@ -3,11 +3,13 @@ package oakmole
import (
"net"
"testing"
+ "time"
)
func Test01(t *testing.T) {
r1 := &Record{
- 0x010203, net.ParseIP("4.4.5.5"), net.ParseIP("2.3.3.1"),
+ uint64(time.Now().UnixNano() / 1000),
+ net.ParseIP("4.4.5.5"), net.ParseIP("2.3.3.1"),
[]byte("host12"), []byte("bodyzzz"),
}
b, err := r1.Marshal()

0 comments on commit c5f466e

Please sign in to comment.