Skip to content

Commit df9c498

Browse files
committed
draft 2nd
Signed-off-by: Songpon Srisawai <[email protected]>
1 parent 7c958e2 commit df9c498

File tree

12 files changed

+521
-216
lines changed

12 files changed

+521
-216
lines changed

pkg/guestagent/api/client/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,11 @@ func (c *GuestAgentClient) Tunnel(ctx context.Context) (api.GuestService_TunnelC
7676
}
7777
return stream, nil
7878
}
79+
80+
func (c *GuestAgentClient) IPv4(ctx context.Context) (*api.CommandOutput, error) {
81+
return c.cli.GetIPv4(ctx, &emptypb.Empty{})
82+
}
83+
84+
func (c *GuestAgentClient) IPv6(ctx context.Context) (*api.CommandOutput, error) {
85+
return c.cli.GetIPv6(ctx, &emptypb.Empty{})
86+
}

pkg/guestagent/api/guestservice.pb.desc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11

2-

2+

33
guestservice.protogoogle/protobuf/empty.protogoogle/protobuf/timestamp.proto"0
44
Info(
55
local_ports ( 2.IPPortR
6-
localPorts"�
6+
localPorts"�
77
Event.
88
time ( 2.google.protobuf.TimestampRtime3
99
local_ports_added ( 2.IPPortRlocalPortsAdded7
1010
local_ports_removed ( 2.IPPortRlocalPortsRemoved
11-
errors ( Rerrors
12-
13-
json_bytes ( R jsonBytes"H
11+
errors ( Rerrors"H
1412
IPPort
1513
protocol ( Rprotocol
1614
ip ( Rip
17-
port (Rport"X
15+
port (Rport"B
16+
CommandOutput
17+
is_json (RisJson
18+
payload ( Rpayload"X
1819
Inotify
1920

2021
mount_path ( R mountPath.
@@ -24,9 +25,11 @@ mount_path ( R mountPath.
2425
protocol ( Rprotocol
2526
data ( Rdata
2627
guestAddr ( R guestAddr$
27-
udpTargetAddr ( RudpTargetAddr2�
28+
udpTargetAddr ( RudpTargetAddr2�
2829
GuestService(
2930
GetInfo.google.protobuf.Empty.Info-
3031
GetEvents.google.protobuf.Empty.Event01
3132
PostInotify.Inotify.google.protobuf.Empty(,
32-
Tunnel.TunnelMessage.TunnelMessage(0B!Zgithub.com/lima-vm/lima/pkg/apibproto3
33+
Tunnel.TunnelMessage.TunnelMessage(01
34+
GetIPv4.google.protobuf.Empty.CommandOutput1
35+
GetIPv6.google.protobuf.Empty.CommandOutputB!Zgithub.com/lima-vm/lima/pkg/apibproto3

pkg/guestagent/api/guestservice.pb.go

Lines changed: 164 additions & 92 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/guestagent/api/guestservice.proto

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ service GuestService {
1010
rpc PostInotify(stream Inotify) returns (google.protobuf.Empty);
1111

1212
rpc Tunnel(stream TunnelMessage) returns (stream TunnelMessage);
13+
rpc GetIPv4(google.protobuf.Empty) returns (CommandOutput);
14+
rpc GetIPv6(google.protobuf.Empty) returns (CommandOutput);
1315
}
1416

1517
message Info {
@@ -21,7 +23,6 @@ message Event {
2123
repeated IPPort local_ports_added = 2;
2224
repeated IPPort local_ports_removed = 3;
2325
repeated string errors = 4;
24-
bytes json_bytes = 5;
2526
}
2627

2728
message IPPort {
@@ -30,6 +31,11 @@ message IPPort {
3031
int32 port = 3;
3132
}
3233

34+
message CommandOutput {
35+
bool is_json = 1;
36+
bytes payload = 2;
37+
}
38+
3339
message Inotify {
3440
string mount_path = 1;
3541
google.protobuf.Timestamp time = 2;

pkg/guestagent/api/guestservice_grpc.pb.go

Lines changed: 90 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/guestagent/api/server/server.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,11 @@ func (s *GuestServer) PostInotify(server api.GuestService_PostInotifyServer) err
5656
func (s *GuestServer) Tunnel(stream api.GuestService_TunnelServer) error {
5757
return s.TunnelS.Start(stream)
5858
}
59+
60+
func (s *GuestServer) GetIPv4(ctx context.Context, _ *emptypb.Empty) (*api.CommandOutput, error) {
61+
return s.Agent.IPv4(ctx)
62+
}
63+
64+
func (s *GuestServer) GetIPv6(ctx context.Context, _ *emptypb.Empty) (*api.CommandOutput, error) {
65+
return s.Agent.IPv6(ctx)
66+
}

pkg/guestagent/guestagent.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ type Agent interface {
1414
Events(ctx context.Context, ch chan *api.Event)
1515
LocalPorts(ctx context.Context) ([]*api.IPPort, error)
1616
HandleInotify(event *api.Inotify)
17+
IPv4(ctx context.Context) (*api.CommandOutput, error)
18+
IPv6(ctx context.Context) (*api.CommandOutput, error)
19+
}
20+
21+
type RouteEntry struct {
22+
Dev string `json:"dev"`
1723
}

0 commit comments

Comments
 (0)