Skip to content

Commit f67c74d

Browse files
committed
fix: update passwords config for trojan
1 parent 89b50b8 commit f67c74d

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

ui/builtin.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package ui
22

33
import (
4+
"crypto/sha256"
5+
"encoding/hex"
46
"errors"
57
"fmt"
68
"net/url"
@@ -1698,6 +1700,10 @@ var _builtin_refs = map[string]Inst{
16981700
},
16991701
"builtin::trojan::server": func(spec *ArgNode) (any, error) {
17001702
passwords := spec.MustGet("passwords").ToStringList()
1703+
for i, password := range passwords {
1704+
sum := sha256.Sum224([]byte(password))
1705+
passwords[i] = hex.EncodeToString(sum[:])
1706+
}
17011707
return &trojan.Server{
17021708
Passwords: passwords,
17031709
}, nil

ui/parser.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,11 @@ func (node *ArgNode) ToStringList() []string {
237237
var ret []string
238238
for _, v := range node.ToList() {
239239
if v.Type == "string" {
240-
ret = append(ret, v.Value.(string))
240+
if v.Value == nil {
241+
ret = append(ret, "")
242+
} else {
243+
ret = append(ret, v.Value.(string))
244+
}
241245
}
242246
}
243247
return ret

0 commit comments

Comments
 (0)