Skip to content

Commit

Permalink
update vendors
Browse files Browse the repository at this point in the history
  • Loading branch information
markus621 committed Aug 25, 2024
1 parent 27f610b commit 450ddf6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 55 deletions.
14 changes: 3 additions & 11 deletions epoll/epoll.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"go.osspkg.com/errors"
"go.osspkg.com/ioutils"
"go.osspkg.com/logx"
netfd "go.osspkg.com/network/fd"
"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -133,9 +132,7 @@ func (v *_epoll) getWaited(list *[]int32) (int, error) {
*list = append(*list, v.events[i].Fd)
default:
if err = v.closeConn(v.events[i].Fd); err != nil {
v.cfg.Logger.WithFields(logx.Fields{
"err": err.Error(),
}).Errorf("Epoll close connect")
v.cfg.Logger.Error("Epoll close connect", "err", err)
}
}
}
Expand Down Expand Up @@ -198,19 +195,14 @@ func (v *_epoll) piping(ctx context.Context) {
return
}
if !isClosedError(e) {
v.cfg.Logger.WithFields(logx.Fields{
"err": e.Error(),
"ip": conn.Conn().RemoteAddr().String(),
}).Warnf("Epoll handling connect")
v.cfg.Logger.Warn("Epoll handling connect", "err", e, "ip", conn.Conn().RemoteAddr())
return
}
e = v.closeConn(conn.FD())
if e == nil || isClosedError(e) {
return
}
v.cfg.Logger.WithFields(logx.Fields{
"err": e.Error(),
}).Errorf("Epoll close connect")
v.cfg.Logger.Error("Epoll close connect", "err", e)
}()
}
}
Expand Down
21 changes: 5 additions & 16 deletions epoll/server_tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ func (s *ServerTCP) init() (err error) {
func (s *ServerTCP) ListenAndServe(ctx xc.Context) (err error) {
defer func() {
ctx.Close()
s.Logger.WithFields(logx.Fields{
"err": err.Error(),
"ip": s.Config.Addr,
}).Errorf("Epoll server stopped")
s.Logger.Error("Epoll server stopped", "err", err, "ip", s.Config.Addr)
}()

if err = s.init(); err != nil {
Expand All @@ -88,9 +85,7 @@ func (s *ServerTCP) ListenAndServe(ctx xc.Context) (err error) {
s.wg.Background(func() {
s.epollListen(ctx)
})
s.Logger.WithFields(logx.Fields{
"ip": s.Config.Addr,
}).Infof("Epoll server started")
s.Logger.Info("Epoll server started", "ip", s.Config.Addr)
s.wg.Wait()
return
}
Expand All @@ -106,16 +101,12 @@ func (s *ServerTCP) connAccept(ctx xc.Context) {
case <-ctx.Done():
return
default:
s.Logger.WithFields(logx.Fields{
"err": err.Error(),
}).Errorf("Epoll conn accept")
s.Logger.Error("Epoll conn accept", "err", err)
return
}
}
if err = s.epoll.Accept(conn); err != nil {
s.Logger.WithFields(logx.Fields{
"err": err.Error(), "ip": conn.RemoteAddr().String(),
}).Errorf("Epoll append connect")
s.Logger.Error("Epoll append connect", "err", err, "ip", conn.RemoteAddr())
}
}
}
Expand All @@ -126,9 +117,7 @@ func (s *ServerTCP) epollListen(ctx xc.Context) {
}()

if err := s.epoll.Listen(ctx.Context()); err != nil {
s.Logger.WithFields(logx.Fields{
"err": err.Error(),
}).Errorf("Epoll listen connects")
s.Logger.Error("Epoll listen connects", "err", err)
}
fmt.Println(1)
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ go 1.21

require (
go.osspkg.com/errors v0.3.1
go.osspkg.com/ioutils v0.4.2
go.osspkg.com/logx v0.3.3
go.osspkg.com/ioutils v0.4.4
go.osspkg.com/logx v0.4.1
go.osspkg.com/routine v0.3.1
go.osspkg.com/syncing v0.3.0
go.osspkg.com/xc v0.3.1
golang.org/x/sys v0.22.0
golang.org/x/sys v0.24.0
)

require (
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ go.osspkg.com/casecheck v0.3.0 h1:x15blEszElbrHrEH5H02JIIhGIg/lGZzIt1kQlD3pwM=
go.osspkg.com/casecheck v0.3.0/go.mod h1:TRFXDMFJEOtnlp3ET2Hix3osbxwPWhvaiT/HfD3+gBA=
go.osspkg.com/errors v0.3.1 h1:F9m/EEd/Ot2jba/TV7tvVRIpWXzIpNLc7vRJKcBD86A=
go.osspkg.com/errors v0.3.1/go.mod h1:dKXe6Rt07nzY7OyKQNZ8HGBicZ2uQ5TKEoVFnVFOK44=
go.osspkg.com/ioutils v0.4.2 h1:02b3bCweFFqWoNrnylIbrdfzQWwuL2tUI0wF0VOs/V4=
go.osspkg.com/ioutils v0.4.2/go.mod h1:HybMFgE1PtVhLL23YJ6T7F9js7cmPgHoJL6Z02V7BOI=
go.osspkg.com/logx v0.3.3 h1:txZj9e/DtZL7TVi3nk+lswYa/viQxbZzFButl6GlYSc=
go.osspkg.com/logx v0.3.3/go.mod h1:+aKGveYkgnL3eJCg2lhiiKCfwjB1izU5QD8ZDuMAOk0=
go.osspkg.com/ioutils v0.4.4 h1:1DCGtlPn0/OaoRgUxNzRcH1L3K90WyFRY6CPcKbWuMU=
go.osspkg.com/ioutils v0.4.4/go.mod h1:58HhG2NHf9JUtixAH3R2XISlUmJruwVIUZ3039QVjOY=
go.osspkg.com/logx v0.4.1 h1:EAzp6EfUmx3YurJrIO2heXIGLimi/RwlnxbM8Lpe8jY=
go.osspkg.com/logx v0.4.1/go.mod h1:hz0oh9mu6Wo4+K6Yk59EbqYVj504FWqSDhEi71btM5g=
go.osspkg.com/routine v0.3.1 h1:R0o4P0Ml5eoeHc2DiHjRvHBo/XXrW5nJNqIj3ToRzjg=
go.osspkg.com/routine v0.3.1/go.mod h1:z5AvvTbB19/tt1E5JOb4POhK1tOPgmejajgao/IWn4s=
go.osspkg.com/syncing v0.3.0 h1:yBkCsDPEt12a+qagInFFt7+ZongfT+GjSQl7nBmcybI=
go.osspkg.com/syncing v0.3.0/go.mod h1:Dpe0ljlEG6cI2Y9PxEjKiYEX2sgs1eUjWNVjFu4/iB0=
go.osspkg.com/xc v0.3.1 h1:6De75eXdP9CVXqgQOcCWLPyAqFw9zP5lM6rV9MLGiCE=
go.osspkg.com/xc v0.3.1/go.mod h1:6dUG4Y/Q2NMhc5vYrNy0ehWIaHQtAi+MFfc22onQHEs=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
24 changes: 5 additions & 19 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ func (v *_server) handlingUDP(ctx context.Context, l net.PacketConn) error {
t := time.Now().Add(v.conf.Timeout)
err := errors.Wrap(l.SetDeadline(t), l.SetReadDeadline(t), l.SetWriteDeadline(t))
if err != nil {
v.log.WithFields(logx.Fields{
"err": err.Error(),
}).Warnf("update deadline")
v.log.Warn("UDP server: update deadline", "err", err)
cancel()
return
}
Expand Down Expand Up @@ -157,10 +155,7 @@ func (v *_server) handlingUDP(ctx context.Context, l net.PacketConn) error {

v.handler.Handler(wBuff, rBuff, addr.String())
if _, err0 := l.WriteTo(wBuff.Bytes(), addr); err0 != nil {
v.log.WithFields(logx.Fields{
"err": err0.Error(),
"addr": addr.String(),
}).Warnf("send message")
v.log.Warn("UDP server: send message", "err", err0, "addr", addr)
}
})
}
Expand Down Expand Up @@ -193,20 +188,14 @@ func (v *_server) handlingTCP(ctx context.Context, l net.Listener) error {
t := time.Now().Add(v.conf.Timeout)
err = errors.Wrap(conn.SetDeadline(t), conn.SetReadDeadline(t), conn.SetWriteDeadline(t))
if err != nil {
v.log.WithFields(logx.Fields{
"err": err.Error(),
"addr": conn.RemoteAddr().String(),
}).Warnf("update deadline")
v.log.Warn("TCP server: update deadline", "err", err, "addr", conn.RemoteAddr())
conn.Close() // nolint: errcheck
continue
}

if tc, ok := conn.(*tls.Conn); ok {
if err = tc.HandshakeContext(ctx); err != nil {
v.log.WithFields(logx.Fields{
"err": err.Error(),
"addr": conn.RemoteAddr().String(),
}).Warnf("handshake")
v.log.Warn("TCP server: handshake", "err", err, "addr", conn.RemoteAddr())
conn.Close() // nolint: errcheck
continue
}
Expand All @@ -229,10 +218,7 @@ func (v *_server) handlingTCP(ctx context.Context, l net.Listener) error {
v.handler.Handler(cp, cp, cp.Addr())
return
} else {
v.log.WithFields(logx.Fields{
"err": err.Error(),
"addr": conn.RemoteAddr().String(),
}).Warnf("read message")
v.log.Warn("TCP server: read message", "err", err, "addr", conn.RemoteAddr())
}
conn.Close() // nolint: errcheck
})
Expand Down

0 comments on commit 450ddf6

Please sign in to comment.