@@ -116,7 +116,6 @@ func NewConnector(metrics *ConnectorMetrics, sendProxyProto bool, receiveProxyPr
116116
117117 return & Connector {
118118 metrics : metrics ,
119- sendProxyProto : sendProxyProto ,
120119 connectionsCond : sync .NewCond (& sync.Mutex {}),
121120 receiveProxyProto : receiveProxyProto ,
122121 trustedProxyNets : trustedProxyNets ,
@@ -129,20 +128,14 @@ func NewConnector(metrics *ConnectorMetrics, sendProxyProto bool, receiveProxyPr
129128type Connector struct {
130129 state mcproto.State
131130 metrics * ConnectorMetrics
132- sendProxyProto bool
133- receiveProxyProto bool
134- recordLogins bool
135- trustedProxyNets []* net.IPNet
136131
137132 activeConnections int32
138133 serverMetrics * ServerMetrics
139134 connectionsCond * sync.Cond
140135 ngrokToken string
141136 clientFilter * ClientFilter
142- autoScaleUpAllowDenyConfig * AllowDenyConfig
143137
144- fakeOnline bool
145- fakeOnlineMOTD string
138+ config ConnectorConfig
146139
147140 connectionNotifier ConnectionNotifier
148141}
@@ -187,7 +180,7 @@ func (c *Connector) createListener(ctx context.Context, listenAddress string) (n
187180 }
188181 logrus .WithField ("listenAddress" , listenAddress ).Info ("Listening for Minecraft client connections" )
189182
190- if c .receiveProxyProto {
183+ if c .config . ReceiveProxyProto {
191184 proxyListener := & proxyproto.Listener {
192185 Listener : listener ,
193186 Policy : c .createProxyProtoPolicy (),
@@ -201,7 +194,7 @@ func (c *Connector) createListener(ctx context.Context, listenAddress string) (n
201194
202195func (c * Connector ) createProxyProtoPolicy () func (upstream net.Addr ) (proxyproto.Policy , error ) {
203196 return func (upstream net.Addr ) (proxyproto.Policy , error ) {
204- trustedIpNets := c .trustedProxyNets
197+ trustedIpNets := c .config . TrustedProxyNets
205198
206199 if len (trustedIpNets ) == 0 {
207200 logrus .Debug ("No trusted proxy networks configured, using the PROXY header by default" )
@@ -497,7 +490,7 @@ func (c *Connector) findAndConnectBackend(ctx context.Context, frontendConn net.
497490 case mcproto .StateLogin :
498491 backendTry = retry .NewConstant (backendRetryInterval )
499492 // Connect request: if autoscaler is enabled, try to connect until backendTimeout is reached
500- if waker != nil {
493+ if c . config . AutoScaleUp {
501494 // Autoscaler enabled: retry until backendTimeout is reached
502495 backendTry = retry .WithMaxDuration (backendTimeout , backendTry )
503496 } else {
@@ -539,11 +532,11 @@ func (c *Connector) findAndConnectBackend(ctx context.Context, frontendConn net.
539532 }
540533 }
541534
542- if nextState == mcproto .StateStatus && c .fakeOnline && waker != nil {
535+ if nextState == mcproto .StateStatus && c .config . FakeOnline && c . config . AutoScaleUp {
543536 logrus .Info ("Server is offline, sending fakeOnlineMOTD for status request" )
544537 writeStatusErr := mcproto .WriteStatusResponse (
545538 frontendConn ,
546- c .fakeOnlineMOTD ,
539+ c .config . FakeOnlineMOTD ,
547540 )
548541
549542 if writeStatusErr != nil {
@@ -600,7 +593,7 @@ func (c *Connector) findAndConnectBackend(ctx context.Context, frontendConn net.
600593 cleanupMetrics = true
601594
602595 // PROXY protocol implementation
603- if c .sendProxyProto {
596+ if c .config . SendProxyProto {
604597
605598 // Determine transport protocol for the PROXY header by "analyzing" the frontend connection's address
606599 transportProtocol := proxyproto .TCPv4
0 commit comments