Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite: complete overhaul with a more flexible code base #114

Closed
wants to merge 182 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
7d78fbd
refactor: rewrite architecture
haveachin Aug 28, 2021
e1eef47
feat: add conn pool
haveachin Sep 12, 2021
1adad92
refactor: logger
haveachin Sep 25, 2021
fe4afed
chore: update viper
haveachin Sep 26, 2021
352419f
refactor: config init
haveachin Sep 26, 2021
4b2d88b
feat: implement loadGateways
haveachin Oct 3, 2021
a182364
fix(Gateway): remove proxy bind
haveachin Oct 3, 2021
40e36db
feat: implement loadServers
haveachin Oct 3, 2021
61ecd8c
feat: implement loadWebhooks
haveachin Oct 3, 2021
2bea3a2
refactor: config loading
haveachin Oct 3, 2021
dd0ccbd
fix: config loading
haveachin Oct 4, 2021
b2e12e7
refactor: rename variable
haveachin Oct 4, 2021
7ba2bd6
feat: refactor PlayerSamples
haveachin Oct 24, 2021
53cb033
feat: add online status override
haveachin Oct 27, 2021
6a0a0ac
feat: add webhook indexing
haveachin Oct 28, 2021
f6bcbe5
feat: add client deadline
haveachin Nov 12, 2021
1f0fe4f
feat: add bedrock support
haveachin Dec 31, 2021
49a13c1
feat: add event bus system
haveachin Jan 2, 2022
27d9d3d
fix: error unwrapping sideeffect
haveachin Jan 10, 2022
d2be42c
fix: naming and logging consistency
haveachin Jan 18, 2022
8ff279e
fix: go mod
haveachin Jan 18, 2022
39daedb
refactor: project structure
haveachin Jan 28, 2022
8d43db6
refactor: rename var for consistency
haveachin Jan 30, 2022
7842fe9
feat: add wildcard support
haveachin Jan 30, 2022
ae86d3d
fix: config path flag
haveachin Jan 31, 2022
bee5cb0
feat: add default placeholder for non registered server
haveachin Jan 31, 2022
9084ddf
feat: send ping packet too when no config is found for domain and imp…
lhridder Feb 3, 2022
324e6db
feat: implement java SendRealIP
haveachin Feb 3, 2022
d535de4
feat: implement bedrock SendProxyProtocol
haveachin Feb 3, 2022
037b7f3
refactor: remove RealIP from bedrock
haveachin Feb 3, 2022
bbad21b
feat: add chan caps config option
haveachin Feb 3, 2022
f27ab57
fix: default config values and no favicon
haveachin Feb 3, 2022
12535f7
fix: proxy protocol transport protocols
haveachin Feb 3, 2022
b8b53ae
feat: add conn processor client timeout
haveachin Feb 5, 2022
5209284
fix: remove java read deadline reset
haveachin Feb 5, 2022
aa3f18e
feat: add events and logging
haveachin Feb 5, 2022
923f38c
feat: add plugin support
haveachin Feb 6, 2022
a29e1c9
feat: add webhooks via internal plugin
haveachin Feb 6, 2022
595217f
refactor: remove unused code
haveachin Feb 6, 2022
720be27
refactor: clean up interface names
haveachin Feb 8, 2022
7747413
feat: add isLoginRequest to events
haveachin Feb 8, 2022
69d50d2
docs: add basic structure
haveachin Feb 8, 2022
d4cb241
fix: set logger to prod
haveachin Feb 8, 2022
1ef7c9a
refactor: change config to camelcase
haveachin Feb 9, 2022
6598db7
fix: chan caps not loading from config
haveachin Feb 9, 2022
0df53e0
refactor: remove unnecessary methods
haveachin Feb 9, 2022
0716c8c
refactor: add ConnTunnel Metadata
haveachin Feb 9, 2022
911f289
refactor: event system
haveachin Feb 11, 2022
50d5b95
refactor: plugin api
haveachin Feb 11, 2022
74c52d6
refactor: connection processor node
haveachin Feb 13, 2022
6c566c7
test(CPN): ListenAndServe
haveachin Feb 13, 2022
8cb066d
fix: test workflow
haveachin Feb 13, 2022
f074a72
refactor: remove unnecessary clean up
haveachin Feb 14, 2022
6c49d4b
feat: prepare sync locking of CPNs
haveachin Feb 26, 2022
d15f15b
doc: conn, cpn, gateway
haveachin Mar 6, 2022
70e0133
refactor: proxy loading and management
haveachin Mar 6, 2022
5a8070b
refactor: swap logger to zap
haveachin Mar 8, 2022
26415d6
fix: event bus worker race when closing
haveachin Mar 8, 2022
a7095ae
fix: server procressing performance issue
haveachin Mar 8, 2022
141a60f
fix: server connection
haveachin Mar 9, 2022
badc2ac
refactor: event data
haveachin Mar 9, 2022
14b8115
refactor: config loading
haveachin Mar 10, 2022
745cf85
refactor: project structure
haveachin Mar 10, 2022
4b45da9
Merge branch 'master' into rewrite
haveachin Mar 10, 2022
47696df
fix: config env var
haveachin Mar 12, 2022
22e0818
refactor: config structure
haveachin Mar 13, 2022
7085d94
feat: add working path flag
haveachin Mar 13, 2022
5be8bc8
docs: add architecture
haveachin Apr 8, 2022
10bf755
fix: markdown syntax
haveachin Apr 8, 2022
4a63242
feat: make proxy reloadable
haveachin Apr 24, 2022
6c65200
Merge branch 'rewrite' of github.com:haveachin/infrared into rewrite
haveachin Apr 24, 2022
596f27b
refactor: porxy reload
haveachin Apr 24, 2022
f7bc4b4
chore: update example domains
haveachin Apr 24, 2022
aaae5fb
test: ExecuteMessageTemplate
haveachin Apr 25, 2022
b029aed
feat: add Provider interface
haveachin Apr 25, 2022
3e467d7
refactor: config loading
haveachin Apr 28, 2022
7d9302c
refactor: default config creation
haveachin May 11, 2022
6ad9494
feat: add listener manager
haveachin May 17, 2022
e9e9571
fix: config reloading
haveachin May 18, 2022
2ceda7d
fix: empty player sample
haveachin May 18, 2022
3007375
fix: revert to old event system
haveachin May 22, 2022
c5770df
refactor: logging
haveachin May 22, 2022
3d7033c
fix: webhook plugin loading
haveachin May 22, 2022
9b8afb8
fix: data race
haveachin Jun 28, 2022
ee79abf
feat: add event listener helper func
haveachin Jun 28, 2022
4985155
feat: add multiple topics on event push
haveachin Jul 1, 2022
c61e2d8
fix: events
haveachin Jul 4, 2022
deda37d
fix: 1.19 support
haveachin Jul 5, 2022
b20050c
feat: add docker config provider
haveachin Jul 6, 2022
2914add
fix: bedrock listener
haveachin Jul 9, 2022
ee7e584
fix: bedrock support
haveachin Jul 9, 2022
34b63f3
fix: bedrock status response
haveachin Jul 9, 2022
cc6aa5e
fix: sending bedrock proxy protocol
haveachin Jul 11, 2022
9a1bc36
fix: cpn tests
haveachin Jul 11, 2022
b28d946
fix!: bump go version
haveachin Jul 11, 2022
4a5c527
feat: add new version tag dry run
haveachin Jul 11, 2022
18ac701
fix: add required tags
haveachin Jul 11, 2022
c068598
fix: go version
haveachin Jul 11, 2022
9d430e8
Merge branch 'master' into rewrite
haveachin Jul 11, 2022
546fb47
fix: merge
haveachin Jul 11, 2022
a406c2b
feat: rewrite (#148)
haveachin Jul 11, 2022
38b4f29
fix: docker config
haveachin Jul 11, 2022
f405ba0
Merge branch 'pre-release' into rewrite
haveachin Jul 11, 2022
b6e3412
fix: docker config (#149)
haveachin Jul 11, 2022
05d3183
fix: config loading
haveachin Jul 11, 2022
421dd32
Merge branch 'rewrite' of github.com:haveachin/infrared into rewrite
haveachin Jul 11, 2022
1ac860c
Merge branch 'pre-release' into rewrite
haveachin Jul 11, 2022
87ea9d5
refacor: file provider
haveachin Jul 14, 2022
cf32f73
feat: add prometheus (#151)
haveachin Jul 17, 2022
d277335
refactor: plugin config loading
haveachin Jul 18, 2022
82f22f7
refactor: java config loading
haveachin Jul 18, 2022
0650691
refactor: bedrock config loading
haveachin Jul 19, 2022
a101b8d
feat: add player API
haveachin Jul 21, 2022
7c84aa3
fix: config merging
haveachin Jul 22, 2022
ba418d6
feat: add basic upgrade command
haveachin Jul 23, 2022
6a7d120
refactor: tool structure and naming
haveachin Aug 29, 2022
4b79fb6
chore: housekeeping
haveachin Oct 19, 2022
b37a125
feat: add bedrock 1.19.30 support
haveachin Oct 23, 2022
112df3a
fix: docker labels parsing
haveachin Oct 24, 2022
7e23835
feat: make Infrared free software
haveachin Oct 24, 2022
a582f1a
feat!: move compression setting to listener
haveachin Oct 24, 2022
d2ac0a1
feat: add installation instructions
haveachin Oct 26, 2022
1bf9168
fix: prometheus event handler registration (#157)
Szczurowsky Oct 26, 2022
da1e011
feat: add version command
haveachin Oct 27, 2022
0264362
chore: bump ci
haveachin Oct 27, 2022
0335e4c
feat: docker watching
haveachin Oct 27, 2022
c320d83
fix: docker config merge panic
haveachin Oct 27, 2022
ca096fb
fix: do not apply faulty configs
haveachin Oct 28, 2022
d04f30e
fix: windows config generation
haveachin Oct 29, 2022
7b487c2
fix: implement custom config merger (#159)
4kills Oct 30, 2022
3b4b488
feat: add FML and FML2 pass through support
haveachin Oct 31, 2022
5614f60
feat: add rate limiter
haveachin Nov 2, 2022
0aece3a
feat: add bedrock receive proxy protocol
haveachin Nov 3, 2022
87efc08
fix: server icon pass through
haveachin Nov 5, 2022
e3833e1
chore: add proxy protocol header to test tools
haveachin Nov 6, 2022
ae38b3d
refactor: prepare for storage
haveachin Nov 18, 2022
efa81b3
feat: add traffic limiter
haveachin Dec 4, 2022
242702f
refactor: remove hard coded event bus calls
haveachin Dec 10, 2022
6f2ae48
feat: add wildcard support via regular expression
haveachin Dec 15, 2022
e706455
feat: add status caching
haveachin Dec 16, 2022
f2b08ac
refactor: config providers
haveachin Dec 16, 2022
2879f68
fix: example config
haveachin Dec 18, 2022
0b0322f
feat: add 1.19.3 support
haveachin Dec 18, 2022
8747183
feat: add proxy support
haveachin Dec 21, 2022
d08fc4e
fix: reading symlinks
haveachin Dec 21, 2022
3c21a7e
fix: server status with proxy protocol
haveachin Dec 25, 2022
b38fd24
fix: add new chat style support to motd
haveachin Dec 27, 2022
9873d16
refactor: event bus api
haveachin Dec 27, 2022
4329570
refactor: plugin lifecycle
haveachin Dec 27, 2022
6edf3ae
fix: prometheus init
haveachin Dec 27, 2022
db34132
fix: status response provider
haveachin Dec 27, 2022
ea3a8ad
feat: implement session validator 1/2
haveachin Jan 1, 2023
3214dfe
feat: implement session validator 2/2
haveachin Jan 16, 2023
835d967
fix: dial timeout and prometheus
haveachin Jan 19, 2023
a9b22f5
feat(website): add navbar
haveachin Jan 20, 2023
ccd02fc
feat: rework status caching
haveachin Jan 27, 2023
748f8ae
Merge branch 'rewrite' of github.com:haveachin/infrared into rewrite
haveachin Jan 27, 2023
7f9e221
fix: plugin lifecycle
haveachin Jan 28, 2023
3b81e2b
feat: add data to player api
haveachin Jan 28, 2023
8dd3d08
fix: tests
haveachin Jan 28, 2023
cd4e58f
feat(api): add config crud endpoints
haveachin Jan 28, 2023
818a6b0
docs(api): add open api v3 docs
haveachin Jan 29, 2023
cb5c4fb
feat(api): add config reload endpoint
haveachin Jan 29, 2023
9850dee
docs(api): auto generate via annotations
haveachin Jan 31, 2023
e3186e3
fix(ci): add swagger doc generation
haveachin Jan 31, 2023
26f5ee4
fix: api docs and wildcards
haveachin Feb 1, 2023
6b885c9
refactor: logging and better deadline control
haveachin Feb 3, 2023
a6f60eb
refactor: event system for better performace 1/2
haveachin Feb 18, 2023
3abf70d
feat: add agpl logo to readme
haveachin Mar 26, 2023
5019e99
feat: init docs website
haveachin Apr 10, 2023
d893a24
Revert "refactor: event system for better performace 1/2"
haveachin Apr 23, 2023
60ca2c5
fix: branch
haveachin May 12, 2023
d9611bd
feat: add new logo
haveachin May 19, 2023
76e75a0
feat: add open api docs
haveachin May 20, 2023
6d8c5c1
feat: add text logos
haveachin May 20, 2023
7e39fec
fix: empty proxy header
haveachin May 20, 2023
efd6ce5
docs: plan more guides and config docs
haveachin May 26, 2023
61051ad
fix: receive proxy protocol
haveachin Jun 1, 2023
044e72e
fix: ci
haveachin Jun 1, 2023
1ae31ce
feat: add names types
haveachin Jun 25, 2023
bed823f
feat: add kubernetes config provider (#182)
marratj Jul 14, 2023
cd2ce3c
feat: add 1.20.2 support (#190)
Speedy11CZ Sep 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: rework status caching
  • Loading branch information
haveachin committed Jan 27, 2023
commit ccd02fcc9295e7421629a0dd4cc09926a7a8d1d5
3 changes: 2 additions & 1 deletion configs/proxies/defaults.yml
Original file line number Diff line number Diff line change
@@ -100,7 +100,8 @@ defaults:
§6Server at {{serverDomain}} is not responding.

# 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.
# This is the Time To Live of the cache. Set this to <=0 to disable caching.
# For multi version support keep this disabled.
#
#statusCacheTTL: 10s

20 changes: 15 additions & 5 deletions internal/app/infrared/conn.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net"
"strconv"
"strings"
"time"

@@ -49,6 +50,11 @@ type Conn interface {
Pipe(c net.Conn) (n int64, err error)
}

type Version interface {
Name() string
ProtocolNumber() int32
}

// Player is a already processed connection that waits to be handles by a server
// All methods need to be thread-safe
type Player interface {
@@ -64,6 +70,8 @@ type Player interface {
IsLoginRequest() bool
// RemoteIP returns the remote IP address of the player
RemoteIP() net.IP
// Version returns Minecraft Version
Version() Version
}

type PlayerDisconnecter interface {
@@ -116,11 +124,13 @@ func TimeMessageTemplates() map[string]string {

func PlayerMessageTemplates(p Player) map[string]string {
return map[string]string{
"username": p.Username(),
"remoteAddress": p.RemoteAddr().String(),
"localAddress": p.LocalAddr().String(),
"serverDomain": p.ServerAddr(),
"gatewayId": p.GatewayID(),
"username": p.Username(),
"remoteAddress": p.RemoteAddr().String(),
"localAddress": p.LocalAddr().String(),
"serverDomain": p.ServerAddr(),
"gatewayId": p.GatewayID(),
"versionName": p.Version().Name(),
"protocolNumber": strconv.Itoa(int(p.Version().ProtocolNumber())),
}
}

7 changes: 4 additions & 3 deletions internal/app/infrared/event.go
Original file line number Diff line number Diff line change
@@ -43,9 +43,10 @@ type PostConnProcessingEvent struct {
Player Player
}

type PerPlayerJoinEvent struct {
Player Player
Server Server
type PrePlayerJoinEvent struct {
Player Player
Server Server
MatchedDomain string
}

type PlayerJoinEvent struct {
4 changes: 4 additions & 0 deletions internal/app/infrared/gateway.go
Original file line number Diff line number Diff line change
@@ -47,8 +47,12 @@ func ListenAndServe(gw Gateway, cpnChan chan<- Conn) {
c, err := l.Accept()
if err != nil {
if errors.Is(net.ErrClosed, err) {
logger.Debug("listener closed")
break
}
logger.Debug("listener accept error",
zap.Error(err),
)
continue
}

18 changes: 11 additions & 7 deletions internal/app/infrared/listener.go
Original file line number Diff line number Diff line change
@@ -49,35 +49,39 @@ func (l *Listener) Close() error {

type managedListener struct {
net.Listener
connCh chan net.Conn
connChan chan net.Conn
errChan chan error
subscriber atomic.Uint32
}

func newManagedListener(l net.Listener) *managedListener {
connCh := make(chan net.Conn)
connChan := make(chan net.Conn)
errChan := make(chan error)
go func() {
for {
c, err := l.Accept()
if err != nil {
return
errChan <- err
continue
}

connCh <- c
connChan <- c
}
}()

return &managedListener{
Listener: l,
connCh: connCh,
connChan: connChan,
errChan: errChan,
}
}

func (ml *managedListener) newSubscriber() net.Listener {
ml.subscriber.Inc()
return &Listener{
listener: ml.Listener,
connCh: ml.connCh,
errCh: make(chan error),
connCh: ml.connChan,
errCh: ml.errChan,
onClose: func() error {
ml.subscriber.Dec()
return nil
12 changes: 4 additions & 8 deletions internal/app/infrared/plugin.go
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ func (pm PluginManager) LoadPlugins(cfg map[string]any) {
}
}

func (pm PluginManager) loadPlugin(p Plugin, cfg map[string]any) {
func (pm PluginManager) loadPlugin(p Plugin, cfg map[string]any) error {
if err := p.Load(cfg); err != nil {
logger := pm.pluginLogger(p)
if errors.Is(err, ErrPluginViaConfigDisabled) {
@@ -149,19 +149,15 @@ func (pm PluginManager) loadPlugin(p Plugin, cfg map[string]any) {
zap.Error(err),
)
}
return
return err
}

pm.plugins[p] = PluginStateLoaded
return nil
}

func (pm *PluginManager) ReloadPlugins(cfg map[string]any) {
for p, s := range pm.plugins {
if s == PluginStateDisabled {
pm.loadPlugin(p, cfg)
return
}

for p := range pm.plugins {
pm.reloadPlugin(p, cfg)
}
}
14 changes: 13 additions & 1 deletion internal/app/infrared/pool.go
Original file line number Diff line number Diff line change
@@ -18,15 +18,17 @@ type ConnPoolConfig struct {
type ConnPool struct {
ConnPoolConfig

mu sync.Mutex
reload chan func()
quit chan bool
mu sync.Mutex
pool map[net.Addr]ConnTunnel
}

func (cp *ConnPool) Start() {
cp.mu.Lock()
cp.reload = make(chan func())
cp.quit = make(chan bool)
cp.mu.Unlock()
cp.pool = map[net.Addr]ConnTunnel{}

for {
@@ -96,12 +98,22 @@ func (cp *ConnPool) handlePlayerLogin(ct ConnTunnel) {
}

func (cp *ConnPool) Reload(cfg ConnPoolConfig) {
cp.mu.Lock()
defer cp.mu.Unlock()

if cp.reload == nil {
return
}

cp.reload <- func() {
cp.ConnPoolConfig = cfg
}
}

func (cp *ConnPool) Close() error {
cp.mu.Lock()
defer cp.mu.Unlock()

if cp.quit == nil {
return errors.New("server gateway was not running")
}
9 changes: 8 additions & 1 deletion internal/app/infrared/proxy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package infrared

import (
"sync"
"time"

"github.com/haveachin/infrared/pkg/event"
@@ -58,6 +59,7 @@ type proxy struct {
poolCh chan ConnTunnel
logger *zap.Logger
eventBus event.Bus
mu sync.Mutex
}

func NewProxy(cfg ProxyConfig) (*proxy, error) {
@@ -156,6 +158,7 @@ func (p *proxy) setLogger(logger *zap.Logger) {
}

func (p *proxy) ListenAndServe(bus event.Bus, logger *zap.Logger) {
p.mu.Lock()
p.setEventBus(bus)
p.setLogger(logger)
p.cpnPool.SetSize(p.settings.CPNCount)
@@ -164,12 +167,16 @@ func (p *proxy) ListenAndServe(bus event.Bus, logger *zap.Logger) {
gw.SetListenersManager(&p.listenersManager)
go ListenAndServe(gw, p.cpnCh)
}
p.mu.Unlock()

go p.connPool.Start()
p.serverGateway.Start()
}

func (p *proxy) Reload(cfg ProxyConfig) error {
p.mu.Lock()
defer p.mu.Unlock()

np, err := NewProxy(cfg)
if err != nil {
return err
@@ -201,7 +208,7 @@ func (p *proxy) Reload(cfg ProxyConfig) error {
gw.SetLogger(p.logger)
go ListenAndServe(gw, p.cpnCh)
}
p.listenersManager.prune()
//p.listenersManager.prune()

return nil
}
18 changes: 15 additions & 3 deletions internal/app/infrared/server.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package infrared
import (
"errors"
"net"
"sync"

"github.com/haveachin/infrared/pkg/event"
"github.com/haveachin/infrared/pkg/wildcard"
@@ -31,6 +32,7 @@ type ServerGatewayConfig struct {
type ServerGateway struct {
ServerGatewayConfig

mu sync.Mutex
reloadChan chan func()
quitChan chan bool
gwIDSrvIDs map[string][]string
@@ -85,8 +87,10 @@ func (sg *ServerGateway) findServer(gatewayID, domain string) (Server, string) {
}

func (sg *ServerGateway) Start() {
sg.mu.Lock()
sg.reloadChan = make(chan func())
sg.quitChan = make(chan bool)
sg.mu.Unlock()
sg.init()

for {
@@ -109,9 +113,10 @@ func (sg *ServerGateway) Start() {
logger = logger.With(logServer(srv)...)
logger.Debug("found server")

replyChan := sg.EventBus.Request(PerPlayerJoinEvent{
Player: player,
Server: srv,
replyChan := sg.EventBus.Request(PrePlayerJoinEvent{
Player: player,
Server: srv,
MatchedDomain: matchedDomain,
}, PrePlayerJoinEventTopic)

if isEventCanceled(replyChan, logger) {
@@ -135,6 +140,9 @@ func (sg *ServerGateway) Start() {
}

func (sg *ServerGateway) Reload(cfg ServerGatewayConfig) {
sg.mu.Lock()
defer sg.mu.Unlock()

if sg.reloadChan == nil {
return
}
@@ -145,9 +153,13 @@ func (sg *ServerGateway) Reload(cfg ServerGatewayConfig) {
}

func (sg *ServerGateway) Close() error {
sg.mu.Lock()
defer sg.mu.Unlock()

if sg.quitChan == nil {
return errors.New("server gateway was not running")
}

sg.quitChan <- true
return nil
}
15 changes: 15 additions & 0 deletions internal/pkg/bedrock/conn.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package bedrock
import (
"bytes"
"net"
"strconv"

"github.com/haveachin/infrared/internal"
"github.com/haveachin/infrared/internal/app/infrared"
@@ -86,6 +87,16 @@ func (c *Conn) Edition() infrared.Edition {
return infrared.BedrockEdition
}

type Version int32

func (v Version) ProtocolNumber() int32 {
return int32(v)
}

func (v Version) Name() string {
return strconv.Itoa(int(v))
}

type Player struct {
Conn
remoteAddr net.Addr
@@ -98,6 +109,10 @@ type Player struct {
loginPkData packet.Data
}

func (p Player) Version() infrared.Version {
return Version(p.version)
}

func (p Player) RemoteAddr() net.Addr {
return p.remoteAddr
}
7 changes: 5 additions & 2 deletions internal/pkg/java/config.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import (

"github.com/haveachin/infrared/internal/app/infrared"
"github.com/haveachin/infrared/internal/pkg/config"
"github.com/haveachin/infrared/internal/pkg/java/protocol"
)

type ServerConfig struct {
@@ -320,8 +321,10 @@ func newServer(id string, cfg ServerConfig) (infrared.Server, error) {
}

srv.statusResponseJSONProvider = &statusResponseJSONProvider{
server: srv,
cacheTTL: cfg.StatusCacheTTL,
server: srv,
cacheTTL: cfg.StatusCacheTTL,
statusHash: map[protocol.Version]uint64{},
statusResponseCache: map[uint64]*statusCacheEntry{},
}

return srv, nil
Loading
Oops, something went wrong.