syntax = "proto3";

package mitmproxy_ipc;

// Note: The protobuf definition is shared between the Rust and Swift parts.
// We are not using prost-build because providing protoc is a hassle on many platforms.
// See .github/workflows/autofix.yml for how to update the respective files,
// or file a PR and let CI handle it.

// Packet with associated tunnel info (Windows pipe to mitmproxy)
message PacketWithMeta {
  bytes data = 1;
  TunnelInfo tunnel_info = 2;
}
message TunnelInfo {
  uint32 pid = 1;
  optional string process_name = 2;
}

// Packet or intercept spec (Windows pipe to redirector)
message FromProxy {
  oneof message {
    Packet packet = 1;
    InterceptConf intercept_conf = 2;
  }
}
// Packet (macOS UDP Stream)
message Packet {
  bytes data = 1;
}
// Intercept conf (macOS Control Stream)
message InterceptConf {
  bool default = 1;
  repeated string actions = 2;
}
// New flow (macOS TCP/UDP Stream)
message NewFlow {
  oneof message {
    TcpFlow tcp = 1;
    UdpFlow udp = 2;
  }
}
message TcpFlow {
  Address remote_address = 1;
  TunnelInfo tunnel_info = 2;
}
message UdpFlow {
  optional Address local_address = 1;
  TunnelInfo tunnel_info = 3;
}
message UdpPacket {
  bytes data = 1;
  Address remote_address = 2;
}
message Address {
  string host = 1;
  uint32 port = 2;
}