add auther config

This commit is contained in:
ginuerzh
2022-02-12 00:33:20 +08:00
parent c1bf501734
commit a8a6bbc3a3
37 changed files with 261 additions and 183 deletions

View File

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

View File

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