2024-01-12 14:27:55 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/armon/go-socks5"
|
|
|
|
)
|
|
|
|
|
|
|
|
type credentials struct {
|
2024-01-12 14:29:25 +03:00
|
|
|
Username string `json:"username"`
|
|
|
|
Password string `json:"password"`
|
2024-01-12 14:27:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2024-01-12 14:29:25 +03:00
|
|
|
credsMap[cred.Username] = cred.Password
|
2024-01-12 14:27:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return credsMap, nil
|
|
|
|
}
|