socks5-server/credentials.go

28 lines
506 B
Go
Raw Normal View History

2024-01-12 14:27:55 +03:00
package main
import (
"encoding/json"
"github.com/armon/go-socks5"
)
type credentials struct {
username string `json:"username"`
password string `json:"password"`
}
func parseCredentials(credsString string) (socks5.StaticCredentials, error) {
var creds []credentials
err := json.Unmarshal([]byte(credsString), &creds)
if err != nil {
return nil, err
}
var credsMap socks5.StaticCredentials
for _, cred := range creds {
credsMap[cred.username] = cred.password
}
return credsMap, nil
}