Skip to content

Commit 12459bb

Browse files
committed
make logs more secure
1 parent c597c2b commit 12459bb

File tree

6 files changed

+9
-10
lines changed

6 files changed

+9
-10
lines changed

README.MD

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,12 @@ webdav-users:
232232
# 密码
233233
password: example-password
234234

235-
# 以下为高级选项, 通常用于调试. ** 如果不理解其工作原理请不要碰 **
235+
# 以下为高级选项, 通常用于调试. ** 如果不理解其工作原理请不要碰 **
236236
advanced:
237237
# 是否打印调试日志
238238
debug-log: false
239+
# 是否记录 socket.io 流的日志 (仅在打开 debug-log 后才会输出到标准输出)
240+
socket-io-log: false
239241
# 是否仅从主服务器下载文件
240242
noopen: false
241243
# 跳过文件哈希值校验
@@ -252,6 +254,8 @@ advanced:
252254
exit-when-disconnected: false
253255
# 不执行快速上线
254256
no-fast-enable: false
257+
# 上线前等待几秒
258+
wait-before-enable: 0
255259

256260
```
257261

api.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ func (cr *Cluster) generateAuthToken(cliId string) (string, error) {
104104
}
105105

106106
func (cr *Cluster) verifyAuthToken(cliId string, token string) (id string) {
107-
logDebugf("Authorizing %q", token)
108107
t, err := jwt.Parse(
109108
token,
110109
func(t *jwt.Token) (interface{}, error) {
@@ -135,7 +134,6 @@ func (cr *Cluster) verifyAuthToken(cliId string, token string) (id string) {
135134
logDebugf("Cannot verity auth token: jti not exists")
136135
return ""
137136
}
138-
logDebugf("JTI is %s", jti)
139137
return jti
140138
}
141139

@@ -162,7 +160,6 @@ func (cr *Cluster) generateAPIToken(cliId string, path string) (string, error) {
162160
}
163161

164162
func (cr *Cluster) verifyAPIToken(cliId string, token string, path string) (id string) {
165-
logDebugf("Authorizing %q for %q", token, path)
166163
t, err := jwt.Parse(
167164
token,
168165
func(t *jwt.Token) (interface{}, error) {
@@ -193,7 +190,6 @@ func (cr *Cluster) verifyAPIToken(cliId string, token string, path string) (id s
193190
logDebugf("Cannot verity api token: jti not exists")
194191
return ""
195192
}
196-
logDebugf("JTI is %s", jti)
197193
return jti
198194
}
199195

cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (cr *Cluster) Connect(ctx context.Context) bool {
214214

215215
cr.reconnectCount = 0
216216

217-
if config.Advanced.DebugLog {
217+
if config.Advanced.SocketIOLog {
218218
engio.OnRecv(func(_ *engine.Socket, data []byte) {
219219
logDebugf("Engine.IO recv: %q", (string)(data))
220220
})

config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
type AdvancedConfig struct {
3434
DebugLog bool `yaml:"debug-log"`
35+
SocketIOLog bool `yaml:"socket-io-log"`
3536
NoOpen bool `yaml:"noopen"`
3637
NoHeavyCheck bool `yaml:"no-heavy-check"`
3738
HeavyCheckInterval int `yaml:"heavy-check-interval"`

config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ webdav-users:
3737
password: example-password
3838
advanced:
3939
debug-log: false
40+
socket-io-log: false
4041
noopen: false
4142
no-heavy-check: false
4243
heavy-check-interval: 120
@@ -45,3 +46,4 @@ advanced:
4546
skip-signature-check: false
4647
exit-when-disconnected: false
4748
no-fast-enable: false
49+
wait-before-enable: 0

token.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ func (cr *Cluster) fetchToken(ctx context.Context) (token *ClusterToken, err err
8181
return
8282
}
8383

84-
logDebugf("Token Challenge: %s", res1.Challenge)
85-
8684
var buf [32]byte
8785
hs := hmac.New(crypto.SHA256.New, ([]byte)(cr.clusterSecret))
8886
hs.Write(([]byte)(res1.Challenge))
@@ -98,8 +96,6 @@ func (cr *Cluster) fetchToken(ctx context.Context) (token *ClusterToken, err err
9896
Signature: signature,
9997
})
10098

101-
logDebugf("Payload: %s", (string)(payload))
102-
10399
req, err = cr.makeReqWithBody(ctx, http.MethodPost, "/openbmclapi-agent/token", nil, bytes.NewReader(payload))
104100
if err != nil {
105101
return

0 commit comments

Comments
 (0)