mirror of
https://github.com/lima-vm/lima.git
synced 2026-10-28 11:44:35 +08:00
Fix proto style issues; enable protolint
Signed-off-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
This commit is contained in:
10 files changed
+113
-94
No files matched your search
@@ -66,6 +66,10 @@ jobs:
|
||||
run: go install github.com/containerd/ltag@v0.3.0
|
||||
- name: Check license boilerplates
|
||||
run: ltag -t ./hack/ltag --check -v
|
||||
- name: Install protolint
|
||||
run: go install github.com/yoheimuta/protolint/cmd/protolint@v0.55.6
|
||||
- name: Check protobuf files
|
||||
run: protolint .
|
||||
|
||||
lint-go:
|
||||
name: "Lint Go"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# This is the configuration for protolint.
|
||||
# See https://github.com/yoheimuta/protolint/blob/v0.55.6/_example/config/.protolint.yaml for details.
|
||||
---
|
||||
lint:
|
||||
rules:
|
||||
# Enable all default rules.
|
||||
no_default: false
|
||||
rules_option:
|
||||
# MAX_LINE_LENGTH rule option.
|
||||
max_line_length:
|
||||
max_chars: 100
|
||||
@@ -514,6 +514,7 @@ lint: check-generated
|
||||
find . -name '*.sh' ! -path "./.git/*" | xargs shfmt -s -d
|
||||
go-licenses check --include_tests ./... --allowed_licenses=$$(cat ./hack/allowed-licenses.txt)
|
||||
ltag -t ./hack/ltag --check -v
|
||||
protolint .
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
|
||||
Vendored
+32
-32
@@ -1,74 +1,74 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "github.com/lima-vm/lima/v2/pkg/driver/external";
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
|
||||
option go_package = "github.com/lima-vm/lima/v2/pkg/driver/external";
|
||||
|
||||
service Driver {
|
||||
rpc Validate(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc Initialize(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc CreateDisk(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc Start(google.protobuf.Empty) returns (stream StartResponse);
|
||||
rpc Stop(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc Validate(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc Initialize(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc CreateDisk(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc Start(google.protobuf.Empty) returns (stream StartResponse);
|
||||
rpc Stop(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
|
||||
rpc RunGUI(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc ChangeDisplayPassword(ChangeDisplayPasswordRequest) returns (google.protobuf.Empty);
|
||||
rpc GetDisplayConnection(google.protobuf.Empty) returns (GetDisplayConnectionResponse);
|
||||
rpc RunGUI(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc ChangeDisplayPassword(ChangeDisplayPasswordRequest) returns (google.protobuf.Empty);
|
||||
rpc GetDisplayConnection(google.protobuf.Empty) returns (GetDisplayConnectionResponse);
|
||||
|
||||
rpc CreateSnapshot(CreateSnapshotRequest) returns (google.protobuf.Empty);
|
||||
rpc ApplySnapshot(ApplySnapshotRequest) returns (google.protobuf.Empty);
|
||||
rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty);
|
||||
rpc ListSnapshots(google.protobuf.Empty) returns (ListSnapshotsResponse);
|
||||
rpc CreateSnapshot(CreateSnapshotRequest) returns (google.protobuf.Empty);
|
||||
rpc ApplySnapshot(ApplySnapshotRequest) returns (google.protobuf.Empty);
|
||||
rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty);
|
||||
rpc ListSnapshots(google.protobuf.Empty) returns (ListSnapshotsResponse);
|
||||
|
||||
rpc Register(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc Unregister(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc Register(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc Unregister(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
|
||||
rpc ForwardGuestAgent(google.protobuf.Empty) returns (ForwardGuestAgentResponse);
|
||||
rpc GuestAgentConn(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
rpc ForwardGuestAgent(google.protobuf.Empty) returns (ForwardGuestAgentResponse);
|
||||
rpc GuestAgentConn(google.protobuf.Empty) returns (google.protobuf.Empty);
|
||||
|
||||
rpc SetConfig(SetConfigRequest) returns (google.protobuf.Empty);
|
||||
rpc SetConfig(SetConfigRequest) returns (google.protobuf.Empty);
|
||||
|
||||
rpc GetInfo(google.protobuf.Empty) returns (InfoResponse);
|
||||
rpc GetInfo(google.protobuf.Empty) returns (InfoResponse);
|
||||
}
|
||||
|
||||
message InfoResponse{
|
||||
bytes info_json = 1;
|
||||
bytes info_json = 1;
|
||||
}
|
||||
|
||||
message StartResponse {
|
||||
bool success = 1;
|
||||
string error = 2;
|
||||
bool success = 1;
|
||||
string error = 2;
|
||||
}
|
||||
|
||||
message SetConfigRequest {
|
||||
bytes instance_config_json = 1;
|
||||
int64 ssh_local_port = 3;
|
||||
bytes instance_config_json = 1;
|
||||
int64 ssh_local_port = 3;
|
||||
}
|
||||
|
||||
message ChangeDisplayPasswordRequest {
|
||||
string password = 1;
|
||||
string password = 1;
|
||||
}
|
||||
|
||||
message GetDisplayConnectionResponse {
|
||||
string connection = 1;
|
||||
string connection = 1;
|
||||
}
|
||||
|
||||
message CreateSnapshotRequest {
|
||||
string tag = 1;
|
||||
string tag = 1;
|
||||
}
|
||||
|
||||
message ApplySnapshotRequest {
|
||||
string tag = 1;
|
||||
string tag = 1;
|
||||
}
|
||||
|
||||
message DeleteSnapshotRequest {
|
||||
string tag = 1;
|
||||
string tag = 1;
|
||||
}
|
||||
|
||||
message ListSnapshotsResponse {
|
||||
string snapshots = 1;
|
||||
string snapshots = 1;
|
||||
}
|
||||
|
||||
message ForwardGuestAgentResponse {
|
||||
bool should_forward = 1;
|
||||
bool should_forward = 1;
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
÷
|
||||
…
|
||||
guestservice.protogoogle/protobuf/empty.protogoogle/protobuf/timestamp.proto"0
|
||||
Info(
|
||||
local_ports (2.IPPortR
|
||||
localPorts"˝
|
||||
Event.
|
||||
time (2.google.protobuf.TimestampRtime3
|
||||
local_ports_added (2.IPPortRlocalPortsAdded7
|
||||
local_ports_removed (2.IPPortRlocalPortsRemoved
|
||||
added_local_ports (2.IPPortRaddedLocalPorts7
|
||||
removed_local_ports (2.IPPortRremovedLocalPorts
|
||||
errors ( Rerrors"H
|
||||
IPPort
|
||||
protocol ( Rprotocol
|
||||
@@ -16,15 +16,16 @@ localPorts"
|
||||
Inotify
|
||||
|
||||
mount_path ( R mountPath.
|
||||
time (2.google.protobuf.TimestampRtime"“
|
||||
time (2.google.protobuf.TimestampRtime"–
|
||||
␍TunnelMessage
|
||||
id ( Rid
|
||||
protocol ( Rprotocol
|
||||
data (Rdata
|
||||
guestAddr ( R guestAddr$
|
||||
␍udpTargetAddr ( R␍udpTargetAddr2Č
|
||||
data (Rdata
|
||||
|
||||
guest_addr ( R guestAddr&
|
||||
udp_target_addr ( R␍udpTargetAddr2Č
|
||||
GuestService(
|
||||
GetInfo.google.protobuf.Empty.Info-
|
||||
GetEvents.google.protobuf.Empty.Event01
|
||||
PostInotify.Inotify.google.protobuf.Empty(,
|
||||
Tunnel.TunnelMessage.TunnelMessage(0B$Z"github.com/lima-vm/lima/v2/pkg/apibproto3
|
||||
Tunnel.TunnelMessage.TunnelMessage(0B/Z-github.com/lima-vm/lima/v2/pkg/guestagent/apibproto3
|
||||
@@ -75,8 +75,8 @@ type Event struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Time *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"`
|
||||
LocalPortsAdded []*IPPort `protobuf:"bytes,2,rep,name=local_ports_added,json=localPortsAdded,proto3" json:"local_ports_added,omitempty"`
|
||||
LocalPortsRemoved []*IPPort `protobuf:"bytes,3,rep,name=local_ports_removed,json=localPortsRemoved,proto3" json:"local_ports_removed,omitempty"`
|
||||
AddedLocalPorts []*IPPort `protobuf:"bytes,2,rep,name=added_local_ports,json=addedLocalPorts,proto3" json:"added_local_ports,omitempty"`
|
||||
RemovedLocalPorts []*IPPort `protobuf:"bytes,3,rep,name=removed_local_ports,json=removedLocalPorts,proto3" json:"removed_local_ports,omitempty"`
|
||||
Errors []string `protobuf:"bytes,4,rep,name=errors,proto3" json:"errors,omitempty"`
|
||||
}
|
||||
|
||||
@@ -119,16 +119,16 @@ func (x *Event) GetTime() *timestamppb.Timestamp {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Event) GetLocalPortsAdded() []*IPPort {
|
||||
func (x *Event) GetAddedLocalPorts() []*IPPort {
|
||||
if x != nil {
|
||||
return x.LocalPortsAdded
|
||||
return x.AddedLocalPorts
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Event) GetLocalPortsRemoved() []*IPPort {
|
||||
func (x *Event) GetRemovedLocalPorts() []*IPPort {
|
||||
if x != nil {
|
||||
return x.LocalPortsRemoved
|
||||
return x.RemovedLocalPorts
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -145,7 +145,7 @@ type IPPort struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Protocol string `protobuf:"bytes,1,opt,name=protocol,proto3" json:"protocol,omitempty"` //tcp, udp
|
||||
Protocol string `protobuf:"bytes,1,opt,name=protocol,proto3" json:"protocol,omitempty"` // tcp, udp
|
||||
Ip string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"`
|
||||
Port int32 `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"`
|
||||
}
|
||||
@@ -264,10 +264,10 @@ type TunnelMessage struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Protocol string `protobuf:"bytes,2,opt,name=protocol,proto3" json:"protocol,omitempty"` //tcp, udp
|
||||
Protocol string `protobuf:"bytes,2,opt,name=protocol,proto3" json:"protocol,omitempty"` // tcp, udp
|
||||
Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
|
||||
GuestAddr string `protobuf:"bytes,4,opt,name=guestAddr,proto3" json:"guestAddr,omitempty"`
|
||||
UdpTargetAddr string `protobuf:"bytes,5,opt,name=udpTargetAddr,proto3" json:"udpTargetAddr,omitempty"`
|
||||
GuestAddr string `protobuf:"bytes,4,opt,name=guest_addr,json=guestAddr,proto3" json:"guest_addr,omitempty"`
|
||||
UdpTargetAddr string `protobuf:"bytes,5,opt,name=udp_target_addr,json=udpTargetAddr,proto3" json:"udp_target_addr,omitempty"`
|
||||
}
|
||||
|
||||
func (x *TunnelMessage) Reset() {
|
||||
@@ -352,13 +352,13 @@ var file_guestservice_proto_rawDesc = []byte{
|
||||
0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67,
|
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54,
|
||||
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x33,
|
||||
0x0a, 0x11, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x5f, 0x61, 0x64,
|
||||
0x64, 0x65, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x49, 0x50, 0x50, 0x6f,
|
||||
0x72, 0x74, 0x52, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x50, 0x6f, 0x72, 0x74, 0x73, 0x41, 0x64,
|
||||
0x64, 0x65, 0x64, 0x12, 0x37, 0x0a, 0x13, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x70, 0x6f, 0x72,
|
||||
0x74, 0x73, 0x5f, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b,
|
||||
0x32, 0x07, 0x2e, 0x49, 0x50, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x11, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
|
||||
0x50, 0x6f, 0x72, 0x74, 0x73, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x0a, 0x11, 0x61, 0x64, 0x64, 0x65, 0x64, 0x5f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x70, 0x6f,
|
||||
0x72, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x49, 0x50, 0x50, 0x6f,
|
||||
0x72, 0x74, 0x52, 0x0f, 0x61, 0x64, 0x64, 0x65, 0x64, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x50, 0x6f,
|
||||
0x72, 0x74, 0x73, 0x12, 0x37, 0x0a, 0x13, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x5f, 0x6c,
|
||||
0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b,
|
||||
0x32, 0x07, 0x2e, 0x49, 0x50, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x76,
|
||||
0x65, 0x64, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x50, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72,
|
||||
0x72, 0x6f, 0x72, 0x73, 0x22, 0x48, 0x0a, 0x06, 0x49, 0x50, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
@@ -370,32 +370,33 @@ var file_guestservice_proto_rawDesc = []byte{
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x50, 0x61, 0x74, 0x68, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
|
||||
0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x93, 0x01, 0x0a, 0x0d, 0x54, 0x75, 0x6e,
|
||||
0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x96, 0x01, 0x0a, 0x0d, 0x54, 0x75, 0x6e,
|
||||
0x6e, 0x65, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x75,
|
||||
0x65, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67,
|
||||
0x75, 0x65, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x12, 0x24, 0x0a, 0x0d, 0x75, 0x64, 0x70, 0x54,
|
||||
0x61, 0x72, 0x67, 0x65, 0x74, 0x41, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x0d, 0x75, 0x64, 0x70, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x41, 0x64, 0x64, 0x72, 0x32, 0xc8,
|
||||
0x01, 0x0a, 0x0c, 0x47, 0x75, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
|
||||
0x28, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70,
|
||||
0x74, 0x79, 0x1a, 0x05, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2d, 0x0a, 0x09, 0x47, 0x65, 0x74,
|
||||
0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x06,
|
||||
0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x12, 0x31, 0x0a, 0x0b, 0x50, 0x6f, 0x73, 0x74,
|
||||
0x49, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x12, 0x08, 0x2e, 0x49, 0x6e, 0x6f, 0x74, 0x69, 0x66,
|
||||
0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x28, 0x01, 0x12, 0x2c, 0x0a, 0x06, 0x54,
|
||||
0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x0e, 0x2e, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x4d, 0x65,
|
||||
0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x0e, 0x2e, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x4d, 0x65,
|
||||
0x73, 0x73, 0x61, 0x67, 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74,
|
||||
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x6d, 0x61, 0x2d, 0x76, 0x6d, 0x2f,
|
||||
0x6c, 0x69, 0x6d, 0x61, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x75,
|
||||
0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
||||
0x67, 0x75, 0x65, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x12, 0x26, 0x0a, 0x0f, 0x75, 0x64, 0x70,
|
||||
0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0d, 0x75, 0x64, 0x70, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x41, 0x64, 0x64,
|
||||
0x72, 0x32, 0xc8, 0x01, 0x0a, 0x0c, 0x47, 0x75, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69,
|
||||
0x63, 0x65, 0x12, 0x28, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e,
|
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||
0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x05, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2d, 0x0a, 0x09,
|
||||
0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
|
||||
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74,
|
||||
0x79, 0x1a, 0x06, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x12, 0x31, 0x0a, 0x0b, 0x50,
|
||||
0x6f, 0x73, 0x74, 0x49, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x12, 0x08, 0x2e, 0x49, 0x6e, 0x6f,
|
||||
0x74, 0x69, 0x66, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x28, 0x01, 0x12, 0x2c,
|
||||
0x0a, 0x06, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x0e, 0x2e, 0x54, 0x75, 0x6e, 0x6e, 0x65,
|
||||
0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x0e, 0x2e, 0x54, 0x75, 0x6e, 0x6e, 0x65,
|
||||
0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x2f, 0x5a, 0x2d,
|
||||
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x6d, 0x61, 0x2d,
|
||||
0x76, 0x6d, 0x2f, 0x6c, 0x69, 0x6d, 0x61, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x67,
|
||||
0x75, 0x65, 0x73, 0x74, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -423,8 +424,8 @@ var file_guestservice_proto_goTypes = []interface{}{
|
||||
var file_guestservice_proto_depIdxs = []int32{
|
||||
2, // 0: Info.local_ports:type_name -> IPPort
|
||||
5, // 1: Event.time:type_name -> google.protobuf.Timestamp
|
||||
2, // 2: Event.local_ports_added:type_name -> IPPort
|
||||
2, // 3: Event.local_ports_removed:type_name -> IPPort
|
||||
2, // 2: Event.added_local_ports:type_name -> IPPort
|
||||
2, // 3: Event.removed_local_ports:type_name -> IPPort
|
||||
5, // 4: Inotify.time:type_name -> google.protobuf.Timestamp
|
||||
6, // 5: GuestService.GetInfo:input_type -> google.protobuf.Empty
|
||||
6, // 6: GuestService.GetEvents:input_type -> google.protobuf.Empty
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "github.com/lima-vm/lima/v2/pkg/api";
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/lima-vm/lima/v2/pkg/guestagent/api";
|
||||
|
||||
service GuestService {
|
||||
rpc GetInfo(google.protobuf.Empty) returns (Info);
|
||||
rpc GetEvents(google.protobuf.Empty) returns (stream Event);
|
||||
rpc PostInotify(stream Inotify) returns (google.protobuf.Empty);
|
||||
|
||||
|
||||
rpc Tunnel(stream TunnelMessage) returns (stream TunnelMessage);
|
||||
}
|
||||
|
||||
@@ -18,13 +19,13 @@ message Info {
|
||||
|
||||
message Event {
|
||||
google.protobuf.Timestamp time = 1;
|
||||
repeated IPPort local_ports_added = 2;
|
||||
repeated IPPort local_ports_removed = 3;
|
||||
repeated IPPort added_local_ports = 2;
|
||||
repeated IPPort removed_local_ports = 3;
|
||||
repeated string errors = 4;
|
||||
}
|
||||
|
||||
message IPPort {
|
||||
string protocol = 1; //tcp, udp
|
||||
string protocol = 1; // tcp, udp
|
||||
string ip = 2;
|
||||
int32 port = 3;
|
||||
}
|
||||
@@ -36,8 +37,8 @@ message Inotify {
|
||||
|
||||
message TunnelMessage {
|
||||
string id = 1;
|
||||
string protocol = 2; //tcp, udp
|
||||
string protocol = 2; // tcp, udp
|
||||
bytes data = 3;
|
||||
string guestAddr = 4;
|
||||
string udpTargetAddr = 5;
|
||||
string guest_addr = 4;
|
||||
string udp_target_addr = 5;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ func (a *agent) collectEvent(ctx context.Context, st eventState) (*api.Event, ev
|
||||
ev.Time = timestamppb.Now()
|
||||
return ev, newSt
|
||||
}
|
||||
ev.LocalPortsAdded, ev.LocalPortsRemoved = comparePorts(st.ports, newSt.ports)
|
||||
ev.AddedLocalPorts, ev.RemovedLocalPorts = comparePorts(st.ports, newSt.ports)
|
||||
ev.Time = timestamppb.Now()
|
||||
return ev, newSt
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (pf *portForwarder) forwardingAddresses(guest *api.IPPort) (hostAddr, guest
|
||||
}
|
||||
|
||||
func (pf *portForwarder) OnEvent(ctx context.Context, ev *api.Event) {
|
||||
for _, f := range ev.LocalPortsRemoved {
|
||||
for _, f := range ev.RemovedLocalPorts {
|
||||
if f.Protocol != "tcp" {
|
||||
continue
|
||||
}
|
||||
@@ -99,7 +99,7 @@ func (pf *portForwarder) OnEvent(ctx context.Context, ev *api.Event) {
|
||||
logrus.WithError(err).Warnf("failed to stop forwarding tcp port %d", f.Port)
|
||||
}
|
||||
}
|
||||
for _, f := range ev.LocalPortsAdded {
|
||||
for _, f := range ev.AddedLocalPorts {
|
||||
if f.Protocol != "tcp" {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func NewPortForwarder(rules []limayaml.PortForward, ignoreTCP, ignoreUDP bool) *
|
||||
}
|
||||
|
||||
func (fw *Forwarder) OnEvent(ctx context.Context, client *guestagentclient.GuestAgentClient, ev *api.Event) {
|
||||
for _, f := range ev.LocalPortsAdded {
|
||||
for _, f := range ev.AddedLocalPorts {
|
||||
local, remote := fw.forwardingAddresses(f)
|
||||
if local == "" {
|
||||
if !fw.ignoreTCP && f.Protocol == "tcp" {
|
||||
@@ -48,7 +48,7 @@ func (fw *Forwarder) OnEvent(ctx context.Context, client *guestagentclient.Guest
|
||||
logrus.Infof("Forwarding %s from %s to %s", strings.ToUpper(f.Protocol), remote, local)
|
||||
fw.closableListeners.Forward(ctx, client, f.Protocol, local, remote)
|
||||
}
|
||||
for _, f := range ev.LocalPortsRemoved {
|
||||
for _, f := range ev.RemovedLocalPorts {
|
||||
local, remote := fw.forwardingAddresses(f)
|
||||
if local == "" {
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user