2022-04-20 09:17:20 +00:00
|
|
|
package resolver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
|
2022-12-14 15:59:24 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-sdk-go/pool"
|
2022-04-20 09:17:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// NeoFSResolver represents virtual connection to the NeoFS network.
|
|
|
|
// It implements resolver.NeoFS.
|
|
|
|
type NeoFSResolver struct {
|
|
|
|
pool *pool.Pool
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewNeoFSResolver creates new NeoFSResolver using provided pool.Pool.
|
|
|
|
func NewNeoFSResolver(p *pool.Pool) *NeoFSResolver {
|
|
|
|
return &NeoFSResolver{pool: p}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SystemDNS implements resolver.NeoFS interface method.
|
|
|
|
func (x *NeoFSResolver) SystemDNS(ctx context.Context) (string, error) {
|
|
|
|
networkInfo, err := x.pool.NetworkInfo(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return "", fmt.Errorf("read network info via client: %w", err)
|
|
|
|
}
|
|
|
|
|
2022-07-25 09:47:48 +00:00
|
|
|
domain := networkInfo.RawNetworkParameter("SystemDNS")
|
|
|
|
if domain == nil {
|
2022-04-20 09:17:20 +00:00
|
|
|
return "", errors.New("system DNS parameter not found or empty")
|
|
|
|
}
|
|
|
|
|
2022-07-25 09:47:48 +00:00
|
|
|
return string(domain), nil
|
2022-04-20 09:17:20 +00:00
|
|
|
}
|