update config

This commit is contained in:
ginuerzh
2022-01-03 23:45:49 +08:00
parent 14537d16ea
commit 566e930010
42 changed files with 412 additions and 521 deletions

View File

@ -79,10 +79,10 @@ func (c *relayConnector) bind(conn net.Conn, cmd uint8, network, address string)
Flags: cmd,
}
if c.md.user != nil {
pwd, _ := c.md.user.Password()
if c.user != nil {
pwd, _ := c.user.Password()
req.Features = append(req.Features, &relay.UserAuthFeature{
Username: c.md.user.Username(),
Username: c.user.Username(),
Password: pwd,
})
}

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net"
"net/url"
"time"
"github.com/go-gost/gost/pkg/common/util/socks"
@ -19,6 +20,7 @@ func init() {
}
type relayConnector struct {
user *url.Userinfo
logger logger.Logger
md metadata
}
@ -30,6 +32,7 @@ func NewConnector(opts ...connector.Option) connector.Connector {
}
return &relayConnector{
user: options.User,
logger: options.Logger,
}
}
@ -71,10 +74,10 @@ func (c *relayConnector) Connect(ctx context.Context, conn net.Conn, network, ad
}
}
if c.md.user != nil {
pwd, _ := c.md.user.Password()
if c.user != nil {
pwd, _ := c.user.Password()
req.Features = append(req.Features, &relay.UserAuthFeature{
Username: c.md.user.Username(),
Username: c.user.Username(),
Password: pwd,
})
}

View File

@ -1,8 +1,6 @@
package relay
import (
"net/url"
"strings"
"time"
mdata "github.com/go-gost/gost/pkg/metadata"
@ -10,25 +8,15 @@ import (
type metadata struct {
connectTimeout time.Duration
user *url.Userinfo
noDelay bool
}
func (c *relayConnector) parseMetadata(md mdata.Metadata) (err error) {
const (
user = "user"
connectTimeout = "connectTimeout"
noDelay = "nodelay"
)
if v := mdata.GetString(md, user); v != "" {
ss := strings.SplitN(v, ":", 2)
if len(ss) == 1 {
c.md.user = url.User(ss[0])
} else {
c.md.user = url.UserPassword(ss[0], ss[1])
}
}
c.md.connectTimeout = mdata.GetDuration(md, connectTimeout)
c.md.noDelay = mdata.GetBool(md, noDelay)