fix compile error
This commit is contained in:
parent
a1255e52d8
commit
bd7da26c42
@ -2,7 +2,6 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"hash/crc32"
|
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -140,10 +139,8 @@ func (s *defaultService) Serve() error {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := sx.ContextWithHash(context.Background(), &sx.Hash{
|
host, _, _ := net.SplitHostPort(conn.RemoteAddr().String())
|
||||||
Source: conn.RemoteAddr().String(),
|
ctx := sx.ContextWithHash(context.Background(), &sx.Hash{Source: host})
|
||||||
Value: ipHash(conn.RemoteAddr()),
|
|
||||||
})
|
|
||||||
|
|
||||||
if err := s.handler.Handle(ctx, conn); err != nil {
|
if err := s.handler.Handle(ctx, conn); err != nil {
|
||||||
s.options.logger.Error(err)
|
s.options.logger.Error(err)
|
||||||
@ -155,15 +152,3 @@ func (s *defaultService) Serve() error {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ipHash(addr net.Addr) uint64 {
|
|
||||||
if addr == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
host, _, _ := net.SplitHostPort(addr.String())
|
|
||||||
if ip := net.ParseIP(host); ip != nil {
|
|
||||||
return uint64(crc32.ChecksumIEEE(ip.To16()))
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user