@@ -24,7 +24,7 @@ import (
2424
2525 "google.golang.org/grpc"
2626 "k8s.io/klog"
27- "sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/agent "
27+ "sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client "
2828)
2929
3030func TestDial (t * testing.T ) {
@@ -48,8 +48,8 @@ func TestDial(t *testing.T) {
4848 t .Fatalf ("expect nil; got %v" , err )
4949 }
5050
51- if ts .packets [0 ].Type != agent .PacketType_DIAL_REQ {
52- t .Fatalf ("expect packet.type %v; got %v" , agent .PacketType_CLOSE_REQ , ts .packets [0 ].Type )
51+ if ts .packets [0 ].Type != client .PacketType_DIAL_REQ {
52+ t .Fatalf ("expect packet.type %v; got %v" , client .PacketType_CLOSE_REQ , ts .packets [0 ].Type )
5353 }
5454
5555 if ts .packets [0 ].GetDialRequest ().Address != "127.0.0.1:80" {
@@ -139,8 +139,8 @@ func TestClose(t *testing.T) {
139139 t .Error (err )
140140 }
141141
142- if ts .packets [1 ].Type != agent .PacketType_CLOSE_REQ {
143- t .Fatalf ("expect packet.type %v; got %v" , agent .PacketType_CLOSE_REQ , ts .packets [1 ].Type )
142+ if ts .packets [1 ].Type != client .PacketType_CLOSE_REQ {
143+ t .Fatalf ("expect packet.type %v; got %v" , client .PacketType_CLOSE_REQ , ts .packets [1 ].Type )
144144 }
145145 if ts .packets [1 ].GetCloseRequest ().ConnectID != 100 {
146146 t .Errorf ("expect connectID=100; got %d" , ts .packets [1 ].GetCloseRequest ().ConnectID )
@@ -152,21 +152,21 @@ func TestClose(t *testing.T) {
152152// fakeStream implements ProxyService_ProxyClient
153153type fakeStream struct {
154154 grpc.ClientStream
155- r <- chan * agent .Packet
156- w chan <- * agent .Packet
155+ r <- chan * client .Packet
156+ w chan <- * client .Packet
157157}
158158
159- var _ agent .ProxyService_ProxyClient = & fakeStream {}
159+ var _ client .ProxyService_ProxyClient = & fakeStream {}
160160
161161func pipe () (* fakeStream , * fakeStream ) {
162- r , w := make (chan * agent .Packet , 2 ), make (chan * agent .Packet , 2 )
162+ r , w := make (chan * client .Packet , 2 ), make (chan * client .Packet , 2 )
163163 s1 , s2 := & fakeStream {}, & fakeStream {}
164164 s1 .r , s1 .w = r , w
165165 s2 .r , s2 .w = w , r
166166 return s1 , s2
167167}
168168
169- func (s * fakeStream ) Send (packet * agent .Packet ) error {
169+ func (s * fakeStream ) Send (packet * client .Packet ) error {
170170 klog .Infof ("[DEBUG] send packet %+v" , packet )
171171 if packet == nil {
172172 return nil
@@ -175,7 +175,7 @@ func (s *fakeStream) Send(packet *agent.Packet) error {
175175 return nil
176176}
177177
178- func (s * fakeStream ) Recv () (* agent .Packet , error ) {
178+ func (s * fakeStream ) Recv () (* client .Packet , error ) {
179179 select {
180180 case pkt := <- s .r :
181181 klog .Infof ("[DEBUG] recv packet %+v" , pkt )
@@ -191,24 +191,24 @@ func (s *fakeStream) Close() {
191191
192192type proxyServer struct {
193193 t testing.T
194- s agent .ProxyService_ProxyClient
195- handlers map [agent .PacketType ]handler
194+ s client .ProxyService_ProxyClient
195+ handlers map [client .PacketType ]handler
196196 connid int64
197197 data bytes.Buffer
198- packets []* agent .Packet
198+ packets []* client .Packet
199199}
200200
201- func testServer (s agent .ProxyService_ProxyClient , connid int64 ) * proxyServer {
201+ func testServer (s client .ProxyService_ProxyClient , connid int64 ) * proxyServer {
202202 server := & proxyServer {
203203 s : s ,
204204 connid : connid ,
205- handlers : make (map [agent .PacketType ]handler ),
206- packets : []* agent .Packet {},
205+ handlers : make (map [client .PacketType ]handler ),
206+ packets : []* client .Packet {},
207207 }
208208
209- server .handlers [agent .PacketType_CLOSE_REQ ] = server .handleClose
210- server .handlers [agent .PacketType_DIAL_REQ ] = server .handleDial
211- server .handlers [agent .PacketType_DATA ] = server .handleData
209+ server .handlers [client .PacketType_CLOSE_REQ ] = server .handleClose
210+ server .handlers [client .PacketType_DIAL_REQ ] = server .handleDial
211+ server .handlers [client .PacketType_DATA ] = server .handleData
212212
213213 return server
214214}
@@ -234,46 +234,46 @@ func (s *proxyServer) serve() {
234234
235235}
236236
237- func (s * proxyServer ) handle (t agent .PacketType , h handler ) * proxyServer {
237+ func (s * proxyServer ) handle (t client .PacketType , h handler ) * proxyServer {
238238 s .handlers [t ] = h
239239 return s
240240}
241241
242- type handler func (pkt * agent .Packet ) * agent .Packet
242+ type handler func (pkt * client .Packet ) * client .Packet
243243
244- func (s * proxyServer ) handleDial (pkt * agent .Packet ) * agent .Packet {
244+ func (s * proxyServer ) handleDial (pkt * client .Packet ) * client .Packet {
245245 s .packets = append (s .packets , pkt )
246- return & agent .Packet {
247- Type : agent .PacketType_DIAL_RSP ,
248- Payload : & agent .Packet_DialResponse {
249- DialResponse : & agent .DialResponse {
246+ return & client .Packet {
247+ Type : client .PacketType_DIAL_RSP ,
248+ Payload : & client .Packet_DialResponse {
249+ DialResponse : & client .DialResponse {
250250 Random : pkt .GetDialRequest ().Random ,
251251 ConnectID : s .connid ,
252252 },
253253 },
254254 }
255255}
256256
257- func (s * proxyServer ) handleClose (pkt * agent .Packet ) * agent .Packet {
257+ func (s * proxyServer ) handleClose (pkt * client .Packet ) * client .Packet {
258258 s .packets = append (s .packets , pkt )
259- return & agent .Packet {
260- Type : agent .PacketType_CLOSE_RSP ,
261- Payload : & agent .Packet_CloseResponse {
262- CloseResponse : & agent .CloseResponse {
259+ return & client .Packet {
260+ Type : client .PacketType_CLOSE_RSP ,
261+ Payload : & client .Packet_CloseResponse {
262+ CloseResponse : & client .CloseResponse {
263263 ConnectID : pkt .GetCloseRequest ().ConnectID ,
264264 },
265265 },
266266 }
267267}
268268
269- func (s * proxyServer ) handleData (pkt * agent .Packet ) * agent .Packet {
269+ func (s * proxyServer ) handleData (pkt * client .Packet ) * client .Packet {
270270 s .packets = append (s .packets , pkt )
271271 s .data .Write (pkt .GetData ().Data )
272272
273- return & agent .Packet {
274- Type : agent .PacketType_DATA ,
275- Payload : & agent .Packet_Data {
276- Data : & agent .Data {
273+ return & client .Packet {
274+ Type : client .PacketType_DATA ,
275+ Payload : & client .Packet_Data {
276+ Data : & client .Data {
277277 ConnectID : pkt .GetData ().ConnectID ,
278278 Data : append ([]byte ("echo: " ), pkt .GetData ().Data ... ),
279279 },
0 commit comments