mirror of
https://github.com/Alexey71/opera-proxy.git
synced 2026-05-13 22:20:59 +00:00
proper logging of selected endpoint
This commit is contained in:
@@ -221,6 +221,10 @@ func (d *ProxyDialer) Dial(network, address string) (net.Conn, error) {
|
|||||||
return d.DialContext(context.Background(), network, address)
|
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) {
|
func readResponse(r io.Reader, req *http.Request) (*http.Response, error) {
|
||||||
endOfResponse := []byte("\r\n\r\n")
|
endOfResponse := []byte("\r\n\r\n")
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
|
|||||||
@@ -343,7 +343,6 @@ func run() int {
|
|||||||
err = try("discover", func() error {
|
err = try("discover", func() error {
|
||||||
ctx, cl := context.WithTimeout(context.Background(), args.timeout)
|
ctx, cl := context.WithTimeout(context.Background(), args.timeout)
|
||||||
defer cl()
|
defer cl()
|
||||||
// TODO: learn about requested_geo value format
|
|
||||||
res, err := seclient.Discover(ctx, fmt.Sprintf("\"%s\",,", args.country))
|
res, err := seclient.Discover(ctx, fmt.Sprintf("\"%s\",,", args.country))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -355,6 +354,8 @@ func run() int {
|
|||||||
ips = res
|
ips = res
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mainLogger.Info("Discovered endpoints: %v. Starting server selection routine %q.", res, args.serverSelection.value)
|
||||||
var ss dialer.SelectionFunc
|
var ss dialer.SelectionFunc
|
||||||
switch args.serverSelection.value {
|
switch args.serverSelection.value {
|
||||||
case dialer.ServerSelectionFirst:
|
case dialer.ServerSelectionFirst:
|
||||||
@@ -376,7 +377,15 @@ func run() int {
|
|||||||
ctx, cl = context.WithTimeout(context.Background(), args.serverSelectionTimeout)
|
ctx, cl = context.WithTimeout(context.Background(), args.serverSelectionTimeout)
|
||||||
defer cl()
|
defer cl()
|
||||||
handlerDialer, err = ss(ctx, dialers)
|
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 {
|
if err != nil {
|
||||||
return 12
|
return 12
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ func (e *SEIPEntry) NetAddr() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e SEIPEntry) String() string {
|
||||||
|
return e.NetAddr()
|
||||||
|
}
|
||||||
|
|
||||||
type SEDiscoverResponse struct {
|
type SEDiscoverResponse struct {
|
||||||
Data struct {
|
Data struct {
|
||||||
IPs []SEIPEntry `json:"ips"`
|
IPs []SEIPEntry `json:"ips"`
|
||||||
|
|||||||
Reference in New Issue
Block a user