update handler options

This commit is contained in:
ginuerzh
2022-01-04 21:56:58 +08:00
parent 566e930010
commit c428b37a36
36 changed files with 468 additions and 524 deletions

View File

@ -1,41 +1,23 @@
package ss
import (
"strings"
"time"
"github.com/go-gost/gost/pkg/common/util/ss"
mdata "github.com/go-gost/gost/pkg/metadata"
"github.com/shadowsocks/go-shadowsocks2/core"
)
type metadata struct {
cipher core.Cipher
key string
readTimeout time.Duration
}
func (h *ssHandler) parseMetadata(md mdata.Metadata) (err error) {
const (
users = "users"
key = "key"
readTimeout = "readTimeout"
)
var method, password string
if auths := mdata.GetStrings(md, users); len(auths) > 0 {
auth := auths[0]
ss := strings.SplitN(auth, ":", 2)
if len(ss) == 1 {
method = ss[0]
} else {
method, password = ss[0], ss[1]
}
}
h.md.cipher, err = ss.ShadowCipher(method, password, mdata.GetString(md, key))
if err != nil {
return
}
h.md.key = mdata.GetString(md, key)
h.md.readTimeout = mdata.GetDuration(md, readTimeout)
return