@@ -70,6 +70,7 @@ type GrpcProxyClientOptions struct {
70
70
proxyPort int
71
71
proxyUdsName string
72
72
mode string
73
+ userAgent string
73
74
}
74
75
75
76
func (o * GrpcProxyClientOptions ) Flags () * pflag.FlagSet {
@@ -85,6 +86,7 @@ func (o *GrpcProxyClientOptions) Flags() *pflag.FlagSet {
85
86
flags .IntVar (& o .proxyPort , "proxy-port" , o .proxyPort , "The port the proxy server is listening on." )
86
87
flags .StringVar (& o .proxyUdsName , "proxy-uds" , o .proxyUdsName , "The UDS name to connect to." )
87
88
flags .StringVar (& o .mode , "mode" , o .mode , "Mode can be either 'grpc' or 'http-connect'." )
89
+ flags .StringVar (& o .userAgent , "user-agent" , o .userAgent , "User agent to pass to the proxy server" )
88
90
89
91
return flags
90
92
}
@@ -168,6 +170,7 @@ func newGrpcProxyClientOptions() *GrpcProxyClientOptions {
168
170
proxyPort : 8090 ,
169
171
proxyUdsName : "" ,
170
172
mode : "grpc" ,
173
+ userAgent : "test-client" ,
171
174
}
172
175
return & o
173
176
}
@@ -261,7 +264,7 @@ func (c *Client) getUDSDialer(o *GrpcProxyClientOptions) (func(ctx context.Conte
261
264
}
262
265
return c , err
263
266
})
264
- tunnel , err := client .CreateGrpcTunnel (o .proxyUdsName , dialOption , grpc .WithInsecure ())
267
+ tunnel , err := client .CreateGrpcTunnel (o .proxyUdsName , dialOption , grpc .WithInsecure (), grpc . WithUserAgent ( o . userAgent ) )
265
268
if err != nil {
266
269
return nil , fmt .Errorf ("failed to create tunnel %s, got %v" , o .proxyUdsName , err )
267
270
}
@@ -278,7 +281,7 @@ func (c *Client) getUDSDialer(o *GrpcProxyClientOptions) (func(ctx context.Conte
278
281
if err != nil {
279
282
return nil , fmt .Errorf ("dialing proxy %q failed: %v" , o .proxyUdsName , err )
280
283
}
281
- fmt .Fprintf (proxyConn , "CONNECT %s HTTP/1.1\r \n Host: %s\r \n \r \n " , requestAddress , "127.0.0.1" )
284
+ fmt .Fprintf (proxyConn , "CONNECT %s HTTP/1.1\r \n Host: %s\r \n User-Agent: %s \r \ n\r \n " , requestAddress , "127.0.0.1" , o . userAgent )
282
285
br := bufio .NewReader (proxyConn )
283
286
res , err := http .ReadResponse (br , nil )
284
287
if err != nil {
0 commit comments