Skip to content

Commit 9cd43bd

Browse files
committed
Fix extra newline in GET /config, fix deepsource
1 parent 172b5cd commit 9cd43bd

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# configuration files
2+
*config.toml
23
*config.json
34
users.json
45
logs/

auth/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func CreateUserStore(usersJsonPath string) *xsync.MapOf[string, string] {
5757
}
5858
// Remove users that are no longer present.
5959
usersToRemove := make([]string, 0)
60-
users.Range(func(key string, value string) bool {
60+
users.Range(func(key string, _ string) bool {
6161
if _, exists := usersJson[key]; !exists {
6262
usersToRemove = append(usersToRemove, key)
6363
}

connector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func InitializeConnector(config *Config) *Connector {
156156
http.Handle("/config/reload", WrapEndpointWithCtx(connector, configReloadEndpoint))
157157
http.Handle("/servers", WrapEndpointWithCtx(connector, serversEndpoint))
158158
http.Handle("/server/{id}", WrapEndpointWithCtx(connector, serverEndpoint))
159-
connector.Upgrader.CheckOrigin = func(r *http.Request) bool { return true }
159+
connector.Upgrader.CheckOrigin = func(_ *http.Request) bool { return true }
160160
http.Handle("/server/{id}/console", WrapEndpointWithCtx(connector, consoleEndpoint))
161161

162162
http.Handle("/server/{id}/files", WrapEndpointWithCtx(connector, filesEndpoint))
@@ -195,7 +195,7 @@ func (connector *Connector) AddProcess(proc *Process) {
195195
process.Console = strings.Join(truncate[len(truncate)-2500:], "\n")
196196
}
197197
process.Console = process.Console + "\n" + m
198-
process.Clients.Range(func(connection chan interface{}, token string) bool {
198+
process.Clients.Range(func(connection chan interface{}, _ string) bool {
199199
connection <- m
200200
return true
201201
})

endpoints_misc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ func configEndpoint(connector *Connector, w http.ResponseWriter, r *http.Request
3939
return
4040
}
4141
connector.Info("config.view", "ip", GetIP(r), "user", user)
42-
writeJsonStringRes(w, string(contents))
42+
w.Header().Set("content-type", "application/json")
43+
_, _ = w.Write(contents)
4344
} else if r.Method == "PATCH" {
4445
var buffer bytes.Buffer
4546
_, err := buffer.ReadFrom(r.Body)

process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (process *Process) MonitorProcess(connector *Connector) error {
149149
"stopped/crashed, and has now been removed.")
150150
if process, loaded := connector.Processes.LoadAndDelete(process.Name); loaded {
151151
<-time.After(5 * time.Second)
152-
process.Clients.Range(func(connection chan interface{}, token string) bool {
152+
process.Clients.Range(func(connection chan interface{}, _ string) bool {
153153
connection <- nil
154154
return true
155155
})

0 commit comments

Comments
 (0)