update handler options
This commit is contained in:
@ -1,42 +1,21 @@
|
||||
package tap
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"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
|
||||
retryCount int
|
||||
key string
|
||||
bufferSize int
|
||||
}
|
||||
|
||||
func (h *tapHandler) parseMetadata(md mdata.Metadata) (err error) {
|
||||
const (
|
||||
users = "users"
|
||||
key = "key"
|
||||
readTimeout = "readTimeout"
|
||||
bufferSize = "bufferSize"
|
||||
key = "key"
|
||||
bufferSize = "bufferSize"
|
||||
)
|
||||
|
||||
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.bufferSize = mdata.GetInt(md, bufferSize)
|
||||
if h.md.bufferSize <= 0 {
|
||||
h.md.bufferSize = 1024
|
||||
|
Reference in New Issue
Block a user