add tun/tap
This commit is contained in:
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-gost/gost/pkg/common/util/ss"
|
||||
md "github.com/go-gost/gost/pkg/metadata"
|
||||
mdata "github.com/go-gost/gost/pkg/metadata"
|
||||
"github.com/shadowsocks/go-shadowsocks2/core"
|
||||
)
|
||||
|
||||
@ -15,7 +15,7 @@ type metadata struct {
|
||||
retryCount int
|
||||
}
|
||||
|
||||
func (h *ssHandler) parseMetadata(md md.Metadata) (err error) {
|
||||
func (h *ssHandler) parseMetadata(md mdata.Metadata) (err error) {
|
||||
const (
|
||||
users = "users"
|
||||
key = "key"
|
||||
@ -24,26 +24,22 @@ func (h *ssHandler) parseMetadata(md md.Metadata) (err error) {
|
||||
)
|
||||
|
||||
var method, password string
|
||||
if v, _ := md.Get(users).([]interface{}); len(v) > 0 {
|
||||
h.logger.Info(v)
|
||||
for _, auth := range v {
|
||||
if s, _ := auth.(string); s != "" {
|
||||
ss := strings.SplitN(s, ":", 2)
|
||||
if len(ss) == 1 {
|
||||
method = ss[0]
|
||||
} else {
|
||||
method, password = ss[0], ss[1]
|
||||
}
|
||||
}
|
||||
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, md.GetString(key))
|
||||
h.md.cipher, err = ss.ShadowCipher(method, password, mdata.GetString(md, key))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
h.md.readTimeout = md.GetDuration(readTimeout)
|
||||
h.md.retryCount = md.GetInt(retryCount)
|
||||
h.md.readTimeout = mdata.GetDuration(md, readTimeout)
|
||||
h.md.retryCount = mdata.GetInt(md, retryCount)
|
||||
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user