WIP: refactor incoming
This commit is contained in:
@@ -31,7 +31,7 @@ func (a *App) _signin(s *api.Session, w http.ResponseWriter, r *http.Request) er
|
|||||||
func (a *App) _signinSubmit(s *api.Session, w http.ResponseWriter, r *http.Request) error {
|
func (a *App) _signinSubmit(s *api.Session, w http.ResponseWriter, r *http.Request) error {
|
||||||
host, _, _ := net.SplitHostPort(r.RemoteAddr)
|
host, _, _ := net.SplitHostPort(r.RemoteAddr)
|
||||||
if !a.signInLock.TryLock(host) {
|
if !a.signInLock.TryLock(host) {
|
||||||
time.Sleep(time.Duration(rand.Int64N(int64(4 * time.Second))))
|
time.Sleep(time.Second + time.Duration(rand.Int64N(int64(3*time.Second))))
|
||||||
return errs.ErrNotAuthorized
|
return errs.ErrNotAuthorized
|
||||||
}
|
}
|
||||||
defer a.signInLock.Unlock(host)
|
defer a.signInLock.Unlock(host)
|
||||||
|
|||||||
@@ -73,12 +73,12 @@ func Unmarshal(buf [Size]byte) (Ping, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addr := netip.AddrFrom4([4]byte(buf[9:13]))
|
addr := netip.AddrFrom4([4]byte(buf[9:13]))
|
||||||
if !addr.IsUnspecified() && addr.Is4() {
|
if !addr.IsUnspecified() {
|
||||||
p.SrcV4 = netip.AddrPortFrom(addr, binary.BigEndian.Uint16(buf[13:15]))
|
p.SrcV4 = netip.AddrPortFrom(addr, binary.BigEndian.Uint16(buf[13:15]))
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = netip.AddrFrom16([16]byte(buf[15:31])).Unmap()
|
addr = netip.AddrFrom16([16]byte(buf[15:31])).Unmap()
|
||||||
if !addr.IsUnspecified() && addr.Is6() {
|
if !addr.IsUnspecified() {
|
||||||
p.SrcV6 = netip.AddrPortFrom(addr, binary.BigEndian.Uint16(buf[31:33]))
|
p.SrcV6 = netip.AddrPortFrom(addr, binary.BigEndian.Uint16(buf[31:33]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user