diff --git a/configs/proxies/defaults.yml b/configs/proxies/defaults.yml index 91e7f952..499278f7 100644 --- a/configs/proxies/defaults.yml +++ b/configs/proxies/defaults.yml @@ -102,7 +102,7 @@ defaults: # Infrared caches the server ping response so that status pings don't spam the minecraft server. # This is the Time To Live of the cache. # - statusCacheTTL: 10s + #statusCacheTTL: 10s java: # Channel Capacity (ChanCap) is the capacity of a single channel @@ -145,11 +145,11 @@ java: rateLimiter: # The request limit it the amount of requests a single IP can make in a specific window of time. # - requestLimit: 1 + requestLimit: 10 # This is the window of time in that a single IP can make a specific amount of requests. # - windowLength: 50ms + windowLength: 500ms # See Java above # diff --git a/internal/pkg/java/config.go b/internal/pkg/java/config.go index a6b46d9a..16c42012 100644 --- a/internal/pkg/java/config.go +++ b/internal/pkg/java/config.go @@ -16,9 +16,6 @@ import ( "github.com/haveachin/infrared/internal/app/infrared" "github.com/haveachin/infrared/internal/pkg/config" - "github.com/haveachin/infrared/internal/pkg/java/protocol" - "github.com/haveachin/infrared/internal/pkg/java/protocol/handshaking" - "github.com/haveachin/infrared/internal/pkg/java/protocol/status" ) type ServerConfig struct { @@ -328,15 +325,8 @@ func newServer(id string, cfg ServerConfig) (infrared.Server, error) { } srv.statusResponseJSONProvider = &statusResponseJSONProvider{ - server: srv, - handshakePk: handshaking.ServerBoundHandshake{ - ProtocolVersion: 0, - ServerAddress: protocol.String(host), - ServerPort: protocol.UnsignedShort(port), - NextState: handshaking.StateStatusServerBoundHandshake, - }.Marshal(), - statusRequestPk: status.ServerBoundRequest{}.Marshal(), - cacheTTL: cfg.StatusCacheTTL, + server: srv, + cacheTTL: cfg.StatusCacheTTL, } return &InfraredServer{ diff --git a/internal/pkg/java/server.go b/internal/pkg/java/server.go index f8bec81a..106b18ad 100644 --- a/internal/pkg/java/server.go +++ b/internal/pkg/java/server.go @@ -18,9 +18,7 @@ import ( ) type statusResponseJSONProvider struct { - server Server - handshakePk protocol.Packet - statusRequestPk protocol.Packet + server Server mu sync.Mutex cacheTTL time.Duration @@ -43,7 +41,7 @@ func (s *statusResponseJSONProvider) requestNewStatusResponseJSON(pc *ProcessedC return status.ResponseJSON{}, err } - if err := rc.WritePackets(s.handshakePk, s.statusRequestPk); err != nil { + if err := rc.WritePackets(pc.readPks...); err != nil { return status.ResponseJSON{}, err }