socks5-server/credentials.go
2024-01-12 03:29:25 -08:00

28 lines
506 B
Go

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
}