Skip to content

Commit

Permalink
Update handler.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Mengke15 authored Mar 8, 2024
1 parent 69794b7 commit ef80d1f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions service/minecraft/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,27 @@ func NewConnHandler(s *config.ConfigProxyService,
return nil, err
}

if accessibility == "NEW" {
msg, err := generateNewMessage(s, playerName).MarshalJSON()
buffer.Reset(mcprotocol.MaxVarIntLen)
common.Must0(mcprotocol.WriteToPacket(buffer,
byte(0x00), // Client bound : Disconnect (login)
mcprotocol.VarInt(len(msg)),
))
err = conn.WriteVectorizedPacket(buffer, msg)
if err != nil {
return nil, err
}

c.(*net.TCPConn).SetLinger(10) //nolint:errcheck
c.Close()
return nil, ErrRejectedLoginAccessControl
}

if accessibility == "NEW" {
msg, err := generateNewMessage(s, playerName).MarshalJSON()
if err != nil {
return nil, err
}

buffer.Reset(mcprotocol.MaxVarIntLen)
common.Must0(mcprotocol.WriteToPacket(buffer,
byte(0x00), // Client bound : Disconnect (login)
Expand All @@ -247,7 +262,7 @@ func NewConnHandler(s *config.ConfigProxyService,
c.Close()
return nil, ErrRejectedLoginAccessControl
}

remote, err := options.Out.Dial("tcp", net.JoinHostPort(s.TargetAddress, strconv.FormatInt(int64(s.TargetPort), 10)))
if err != nil {
conn.Close()
Expand Down

0 comments on commit ef80d1f

Please sign in to comment.