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

@ -2,9 +2,7 @@ package ssh
import (
"io/ioutil"
"strings"
"github.com/go-gost/gost/pkg/auth"
tls_util "github.com/go-gost/gost/pkg/common/util/tls"
ssh_util "github.com/go-gost/gost/pkg/internal/util/ssh"
mdata "github.com/go-gost/gost/pkg/metadata"
@ -12,32 +10,17 @@ import (
)
type metadata struct {
authenticator auth.Authenticator
signer ssh.Signer
authorizedKeys map[string]bool
}
func (h *forwardHandler) parseMetadata(md mdata.Metadata) (err error) {
const (
users = "users"
authorizedKeys = "authorizedKeys"
privateKeyFile = "privateKeyFile"
passphrase = "passphrase"
)
if auths := mdata.GetStrings(md, users); len(auths) > 0 {
authenticator := auth.NewLocalAuthenticator(nil)
for _, auth := range auths {
ss := strings.SplitN(auth, ":", 2)
if len(ss) == 1 {
authenticator.Add(ss[0], "")
} else {
authenticator.Add(ss[0], ss[1])
}
}
h.md.authenticator = authenticator
}
if key := mdata.GetString(md, privateKeyFile); key != "" {
data, err := ioutil.ReadFile(key)
if err != nil {