proper logging of selected endpoint

This commit is contained in:
Vladislav Yarmak
2025-09-14 22:56:19 +03:00
parent 6eb2054faf
commit ddea656d94
3 changed files with 19 additions and 2 deletions
+4
View File
@@ -221,6 +221,10 @@ func (d *ProxyDialer) Dial(network, address string) (net.Conn, error) {
return d.DialContext(context.Background(), network, address)
}
func (d *ProxyDialer) Address() (string, error) {
return d.address()
}
func readResponse(r io.Reader, req *http.Request) (*http.Response, error) {
endOfResponse := []byte("\r\n\r\n")
buf := &bytes.Buffer{}
+11 -2
View File
@@ -343,7 +343,6 @@ func run() int {
err = try("discover", func() error {
ctx, cl := context.WithTimeout(context.Background(), args.timeout)
defer cl()
// TODO: learn about requested_geo value format
res, err := seclient.Discover(ctx, fmt.Sprintf("\"%s\",,", args.country))
if err != nil {
return err
@@ -355,6 +354,8 @@ func run() int {
ips = res
return nil
}
mainLogger.Info("Discovered endpoints: %v. Starting server selection routine %q.", res, args.serverSelection.value)
var ss dialer.SelectionFunc
switch args.serverSelection.value {
case dialer.ServerSelectionFirst:
@@ -376,7 +377,15 @@ func run() int {
ctx, cl = context.WithTimeout(context.Background(), args.serverSelectionTimeout)
defer cl()
handlerDialer, err = ss(ctx, dialers)
return err
if err != nil {
return err
}
if addresser, ok := handlerDialer.(interface{ Address() (string, error) }); ok {
if epAddr, err := addresser.Address(); err == nil {
mainLogger.Info("Selected endpoint address: %s", epAddr)
}
}
return nil
})
if err != nil {
return 12
+4
View File
@@ -97,6 +97,10 @@ func (e *SEIPEntry) NetAddr() string {
}
}
func (e SEIPEntry) String() string {
return e.NetAddr()
}
type SEDiscoverResponse struct {
Data struct {
IPs []SEIPEntry `json:"ips"`