Skip to content

Commit

Permalink
Add 'useProxy' setting to gRPC client channel to disable use of proxy…
Browse files Browse the repository at this point in the history
… for connecting.
  • Loading branch information
KIProtect GmbH committed Mar 18, 2022
1 parent 39f3768 commit dbe4263
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions channels/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ func (c *GRPCClientChannel) DeliverRequest(request *eps.Request) (*eps.Response,
var dialer grpc.Dialer

if settings.Proxy != "" {

if !c.Settings.UseProxy {
return nil, fmt.Errorf("destination is only reachable via proxy but proxying is disabled")
}

dialer = func(context context.Context, addr string) (net.Conn, error) {
eps.Log.Tracef("Dialing to %s through proxy...", address.Operator)

Expand Down
7 changes: 7 additions & 0 deletions grpc/forms.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ var AnnouncementForm = forms.Form{

var GRPCClientSettingsForm = forms.Form{
Fields: []forms.Field{
{
Name: "useProxy",
Validators: []forms.Validator{
forms.IsOptional{Default: true},
forms.IsBoolean{},
},
},
{
Name: "tls",
Validators: []forms.Validator{
Expand Down
5 changes: 3 additions & 2 deletions grpc/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import (

// Settings for the gRPC client
type GRPCClientSettings struct {
TLS *tls.TLSSettings `json:"tls"`
Enabled bool `json:"enabled"`
TLS *tls.TLSSettings `json:"tls"`
UseProxy bool `json:"useProxy"`
Enabled bool `json:"enabled"`
}

// Settings for the gRPC server
Expand Down

0 comments on commit dbe4263

Please sign in to comment.