Skip to content

Commit e2e7b91

Browse files
committed
fix: fmt
1 parent b0a5a2e commit e2e7b91

File tree

6 files changed

+123
-120
lines changed

6 files changed

+123
-120
lines changed

cmd/mc-router/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ type Config struct {
7171

7272
SimplifySRV bool `default:"false" usage:"Simplify fully qualified SRV records for mapping"`
7373

74-
FakeOnline bool `default:"false" usage:"Enable fake online MOTD when backend is offline and auto-scale-up is enabled"`
75-
FakeOnlineMOTD string `default:"Server is sleeping\nJoin to wake it up" usage:"Custom MOTD to show when backend is offline and auto-scale-up is enabled"`
74+
FakeOnline bool `default:"false" usage:"Enable fake online MOTD when backend is offline and auto-scale-up is enabled"`
75+
FakeOnlineMOTD string `default:"Server is sleeping\nJoin to wake it up" usage:"Custom MOTD to show when backend is offline and auto-scale-up is enabled"`
7676

7777
Webhook WebhookConfig `usage:"Webhook configuration"`
7878
}
@@ -171,14 +171,14 @@ func main() {
171171
}
172172

173173
connectorConfig := server.ConnectorConfig{
174-
SendProxyProto: config.UseProxyProtocol,
175-
ReceiveProxyProto: config.ReceiveProxyProtocol,
176-
TrustedProxyNets: trustedIpNets,
177-
RecordLogins: config.RecordLogins,
174+
SendProxyProto: config.UseProxyProtocol,
175+
ReceiveProxyProto: config.ReceiveProxyProtocol,
176+
TrustedProxyNets: trustedIpNets,
177+
RecordLogins: config.RecordLogins,
178178
AutoScaleUpAllowDenyConfig: autoScaleUpAllowDenyConfig,
179-
AutoScaleUp: config.AutoScaleUp,
180-
FakeOnline: config.FakeOnline,
181-
FakeOnlineMOTD: config.FakeOnlineMOTD,
179+
AutoScaleUp: config.AutoScaleUp,
180+
FakeOnline: config.FakeOnline,
181+
FakeOnlineMOTD: config.FakeOnlineMOTD,
182182
}
183183

184184
connector := server.NewConnector(metricsBuilder.BuildConnectorMetrics(), connectorConfig)

mcproto/types.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,28 @@ const (
8686
)
8787

8888
type StatusResponse struct {
89-
Version StatusVersion `json:"version"`
90-
Players StatusPlayers `json:"players"`
91-
Description StatusText `json:"description"`
92-
Favicon string `json:"favicon,omitempty"`
89+
Version StatusVersion `json:"version"`
90+
Players StatusPlayers `json:"players"`
91+
Description StatusText `json:"description"`
92+
Favicon string `json:"favicon,omitempty"`
9393
}
9494

9595
type StatusVersion struct {
96-
Name string `json:"name"`
97-
Protocol int `json:"protocol"`
96+
Name string `json:"name"`
97+
Protocol int `json:"protocol"`
9898
}
9999

100100
type StatusPlayers struct {
101-
Max int `json:"max"`
102-
Online int `json:"online"`
103-
Sample []PlayerEntry `json:"sample,omitempty"`
101+
Max int `json:"max"`
102+
Online int `json:"online"`
103+
Sample []PlayerEntry `json:"sample,omitempty"`
104104
}
105105

106106
type PlayerEntry struct {
107-
Name string `json:"name"`
108-
ID string `json:"id"`
107+
Name string `json:"name"`
108+
ID string `json:"id"`
109109
}
110110

111111
type StatusText struct {
112-
Text string `json:"text"`
113-
}
112+
Text string `json:"text"`
113+
}

mcproto/write.go

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,49 @@ import (
66
)
77

88
func WriteStatusResponse(w io.Writer, motd string) error {
9-
resp := StatusResponse{
10-
Version: StatusVersion{
11-
Name: "1.21.5",
12-
Protocol: 770,
13-
},
14-
Players: StatusPlayers{
15-
Max: 0,
16-
Online: 0,
17-
},
18-
Description: StatusText{
19-
Text: motd,
20-
},
21-
}
22-
data, err := json.Marshal(resp)
23-
if err != nil {
24-
return err
25-
}
9+
resp := StatusResponse{
10+
Version: StatusVersion{
11+
Name: "1.21.5",
12+
Protocol: 770,
13+
},
14+
Players: StatusPlayers{
15+
Max: 0,
16+
Online: 0,
17+
},
18+
Description: StatusText{
19+
Text: motd,
20+
},
21+
}
22+
data, err := json.Marshal(resp)
23+
if err != nil {
24+
return err
25+
}
2626

27-
jsonLen := encodeVarInt(len(data))
28-
payload := append(jsonLen, data...)
29-
return WritePacket(w, 0x00, payload)
27+
jsonLen := encodeVarInt(len(data))
28+
payload := append(jsonLen, data...)
29+
return WritePacket(w, 0x00, payload)
3030
}
3131

3232
func WritePacket(w io.Writer, packetID int, data []byte) error {
33-
packet := append(encodeVarInt(packetID), data...)
34-
length := encodeVarInt(len(packet))
35-
_, err := w.Write(append(length, packet...))
36-
return err
33+
packet := append(encodeVarInt(packetID), data...)
34+
length := encodeVarInt(len(packet))
35+
_, err := w.Write(append(length, packet...))
36+
return err
3737
}
3838

3939
// encodeVarInt encodes an int as a Minecraft VarInt.
4040
func encodeVarInt(value int) []byte {
41-
var buf []byte
42-
for {
43-
temp := byte(value & 0x7F)
44-
value >>= 7
45-
if value != 0 {
46-
temp |= 0x80
47-
}
48-
buf = append(buf, temp)
49-
if value == 0 {
50-
break
51-
}
52-
}
53-
return buf
54-
}
41+
var buf []byte
42+
for {
43+
temp := byte(value & 0x7F)
44+
value >>= 7
45+
if value != 0 {
46+
temp |= 0x80
47+
}
48+
buf = append(buf, temp)
49+
if value == 0 {
50+
break
51+
}
52+
}
53+
return buf
54+
}

server/allow_deny_list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88

99
type AllowDenyLists struct {
1010
Allowlist []PlayerInfo
11-
Denylist []PlayerInfo
11+
Denylist []PlayerInfo
1212
}
1313

1414
type AllowDenyConfig struct {
15-
Global AllowDenyLists
15+
Global AllowDenyLists
1616
Servers map[string]AllowDenyLists
1717
}
1818

@@ -35,7 +35,7 @@ func entryMatchesPlayer(entry *PlayerInfo, userInfo *PlayerInfo) bool {
3535
if entry.Name == "" && entry.Uuid == uuid.Nil {
3636
return false
3737
}
38-
38+
3939
if entry.Name != "" && entry.Uuid != uuid.Nil {
4040
return *entry == *userInfo
4141
}

server/allow_deny_list_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
1111
type args struct {
1212
serverAddress string
13-
userInfo *PlayerInfo
13+
userInfo *PlayerInfo
1414
}
1515
validUserInfo := &PlayerInfo{
1616
Name: "player_name",
@@ -27,20 +27,20 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
2727
want bool
2828
}{
2929
{
30-
name: "nil config",
30+
name: "nil config",
3131
allowDenyConfig: nil,
3232
args: args{
3333
serverAddress: "server.my.domain",
34-
userInfo: validUserInfo,
34+
userInfo: validUserInfo,
3535
},
3636
want: true,
3737
},
3838
{
39-
name: "empty config",
39+
name: "empty config",
4040
allowDenyConfig: &AllowDenyConfig{},
4141
args: args{
4242
serverAddress: "server.my.domain",
43-
userInfo: validUserInfo,
43+
userInfo: validUserInfo,
4444
},
4545
want: true,
4646
},
@@ -58,7 +58,7 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
5858
},
5959
args: args{
6060
serverAddress: "server.my.domain",
61-
userInfo: validUserInfo,
61+
userInfo: validUserInfo,
6262
},
6363
want: false,
6464
},
@@ -73,7 +73,7 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
7373
},
7474
args: args{
7575
serverAddress: "server.my.domain",
76-
userInfo: validUserInfo,
76+
userInfo: validUserInfo,
7777
},
7878
want: true,
7979
},
@@ -88,7 +88,7 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
8888
},
8989
args: args{
9090
serverAddress: "server.my.domain",
91-
userInfo: validUserInfo,
91+
userInfo: validUserInfo,
9292
},
9393
want: false,
9494
},
@@ -103,7 +103,7 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
103103
},
104104
args: args{
105105
serverAddress: "server.my.domain",
106-
userInfo: validUserInfo,
106+
userInfo: validUserInfo,
107107
},
108108
want: false,
109109
},
@@ -121,7 +121,7 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
121121
},
122122
args: args{
123123
serverAddress: "server.my.domain",
124-
userInfo: validUserInfo,
124+
userInfo: validUserInfo,
125125
},
126126
want: true,
127127
},
@@ -138,7 +138,7 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
138138
},
139139
args: args{
140140
serverAddress: "server.my.domain",
141-
userInfo: validUserInfo,
141+
userInfo: validUserInfo,
142142
},
143143
want: true,
144144
},
@@ -155,7 +155,7 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
155155
},
156156
args: args{
157157
serverAddress: "server.my.domain",
158-
userInfo: validUserInfo,
158+
userInfo: validUserInfo,
159159
},
160160
want: false,
161161
},
@@ -172,7 +172,7 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
172172
},
173173
args: args{
174174
serverAddress: "server.my.domain",
175-
userInfo: validUserInfo,
175+
userInfo: validUserInfo,
176176
},
177177
want: false,
178178
},
@@ -194,7 +194,7 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
194194
},
195195
args: args{
196196
serverAddress: "server.my.domain",
197-
userInfo: validUserInfo,
197+
userInfo: validUserInfo,
198198
},
199199
want: true,
200200
},
@@ -216,7 +216,7 @@ func Test_allowDenyConfig_ServerAllowsPlayer(t *testing.T) {
216216
},
217217
args: args{
218218
serverAddress: "server.my.domain",
219-
userInfo: validUserInfo,
219+
userInfo: validUserInfo,
220220
},
221221
want: true,
222222
},

0 commit comments

Comments
 (0)