Files
EasyTier/easytier-proto/proto/common.proto
T
Luna YaoandClaude Code 250c2ad8d6 refactor(config): preserve explicit flags with FlagsPatch and derive CLI arguments from schema (#2585)
This PR refactors EasyTier's configuration flags system across protobuf definitions, TOML/API persistence, runtime reconciliation, and the CLI.

It introduces a synthesized FlagsPatch protobuf message with optionize and pbjson support to track field presence reliably, replaces manual CLI flag boilerplate with dynamic schema-driven clap argument generation, and
establishes Flags::resolve(patch) as the single source of truth for runtime defaults.

Co-authored-by: Claude Code <noreply@anthropic.com>
2026-10-10 22:11:08 +08:00

286 lines
8.3 KiB
Protocol Buffer

syntax = "proto3";
import "annotations.proto";
import "error.proto";
package common;
message Flags {
string default_protocol = 1 [(easytier.flag) = { default: "tcp" }];
string dev_name = 2 [(easytier.flag) = { default: "", form: true }];
bool enable_encryption = 3 [(easytier.flag) = { default: "true", api: { field: "disable_encryption", negate: true } }];
bool enable_ipv6 = 4 [(easytier.flag) = { default: "true", api: { field: "disable_ipv6", negate: true } }];
uint32 mtu = 5 [(easytier.flag) = { default: "1380", form: true }];
bool latency_first = 6 [(easytier.flag) = { default: "false" }];
bool enable_exit_node = 7 [(easytier.flag) = { default: "false" }];
bool no_tun = 8 [(easytier.flag) = { default: "false" }];
bool use_smoltcp = 9 [(easytier.flag) = { default: "false" }];
string relay_network_whitelist = 10 [(easytier.flag) = { default: "*", form: true }];
bool disable_p2p = 11 [(easytier.flag) = { default: "false" }];
bool relay_all_peer_rpc = 12 [(easytier.flag) = { default: "false" }];
bool disable_udp_hole_punching = 13 [(easytier.flag) = { default: "false" }];
// string ipv6_listener = 14; [deprecated = true]; use -l udp://[::]:12345
// instead
bool multi_thread = 15 [(easytier.flag) = { default: "true" }];
CompressionAlgoPb data_compress_algo = 16 [(easytier.flag) = { default: "None", form: true }];
bool bind_device = 17 [(easytier.flag) = { default: "true" }];
// should we convert all tcp streams into kcp streams
bool enable_kcp_proxy = 18 [(easytier.flag) = { default: "false" }];
// does this peer allow kcp input
bool disable_kcp_input = 19 [(easytier.flag) = { default: "false" }];
// disable relay local network kcp packets
bool disable_relay_kcp = 20 [(easytier.flag) = { default: "false" }];
bool proxy_forward_by_system = 21 [(easytier.flag) = { default: "false" }];
// enable magic dns or not
bool accept_dns = 22 [(easytier.flag) = { default: "false", api: { field: "enable_magic_dns" } }];
// enable private mode
bool private_mode = 23 [(easytier.flag) = { default: "false", api: { field: "enable_private_mode" } }];
// should we convert all tcp streams into quic streams
bool enable_quic_proxy = 24 [(easytier.flag) = { default: "false" }];
// does this peer allow quic input
bool disable_quic_input = 25 [(easytier.flag) = { default: "false" }];
// disable relay local network quic packets
bool disable_relay_quic = 35 [(easytier.flag) = { default: "false" }];
// quic listen port
uint32 quic_listen_port = 33 [deprecated = true, (easytier.flag) = { default: "4294967295", deprecated: true }];
// a global relay limit, only work for foreign network
uint64 foreign_relay_bps_limit = 26 [(easytier.flag) = { default: "18446744073709551615" }];
uint32 multi_thread_count = 27 [(easytier.flag) = { default: "2" }];
// enable relay foreign network kcp packets
bool enable_relay_foreign_network_kcp = 28 [(easytier.flag) = { default: "false" }];
// enable relay foreign network quic packets
bool enable_relay_foreign_network_quic = 36 [(easytier.flag) = { default: "false" }];
// encryption algorithm to use, empty string means default (aes-gcm)
string encryption_algorithm = 29 [(easytier.flag) = { default: "aes-gcm", form: true }];
// disable symmetric nat hole punching, treat symmetric as cone when enabled
bool disable_sym_hole_punching = 30 [(easytier.flag) = { default: "false" }];
// tld dns zone for magic dns
string tld_dns_zone = 31 [(easytier.flag) = { default: "et.net." }];
bool p2p_only = 32 [(easytier.flag) = { default: "false" }];
bool disable_tcp_hole_punching = 34 [(easytier.flag) = { default: "false" }];
bool lazy_p2p = 37 [(easytier.flag) = { default: "false" }];
bool need_p2p = 38 [(easytier.flag) = { default: "false" }];
uint64 instance_recv_bps_limit = 39 [(easytier.flag) = { default: "18446744073709551615", form: true }];
bool disable_upnp = 40 [(easytier.flag) = { default: "false" }];
bool disable_relay_data = 41 [(easytier.flag) = { default: "false" }];
bool enable_udp_broadcast_relay = 42 [(easytier.flag) = { default: "false" }];
// Linux-only: SO_MARK (fwmark) value applied to every outbound underlay
// socket (TCP/UDP/QUIC/WS/WG connectors and listeners). Unset = leave
// SO_MARK untouched (kernel default 0). Any set value (including 0) is
// applied via setsockopt. Requires CAP_NET_ADMIN; silently ignored on
// non-Linux platforms.
optional uint32 socket_mark = 43 [(easytier.flag) = { form: true }];
// Prefer direct credential peers that already relay to a destination over
// advertising another direct edge to the same destination.
bool prefer_peer_relay = 44 [(easytier.flag) = { default: "false" }];
}
message RpcDescriptor {
// allow same service registered multiple times in different domain
string domain_name = 1;
string proto_name = 2;
string service_name = 3;
uint32 method_index = 4;
}
message RpcRequest {
RpcDescriptor descriptor = 1 [ deprecated = true ];
bytes request = 2;
int32 timeout_ms = 3;
}
// One transport-neutral RPC invocation submitted through a direct ABI.
//
// full_method_name uses the protobuf reflection form:
// "<package>.<service>.<method>" or "<service>.<method>" for an empty package.
message DirectRpcRequest {
string full_method_name = 1;
bytes request = 2;
optional uint64 timeout_ms = 3;
}
// One process-level management call delegated by the WASI WebClient to its host.
message HostManagementRequest {
DirectRpcRequest rpc = 1;
optional string prepared_config = 2;
// Runtime identity paired with prepared_config without rewriting rpc.request.
UUID prepared_instance_id = 3;
}
message RpcResponse {
bytes response = 1;
error.Error error = 2;
uint64 runtime_us = 3;
}
enum CompressionAlgoPb {
Invalid = 0;
None = 1;
Zstd = 2;
}
message RpcCompressionInfo {
// use this to compress the content
CompressionAlgoPb algo = 1;
// tell the peer which compression algo is used to compress the next
// response/request
CompressionAlgoPb accepted_algo = 2;
}
message RpcPacket {
uint32 from_peer = 1;
uint32 to_peer = 2;
int64 transaction_id = 3;
RpcDescriptor descriptor = 4;
bytes body = 5;
bool is_request = 6;
uint32 total_pieces = 7;
uint32 piece_idx = 8;
int32 trace_id = 9;
RpcCompressionInfo compression_info = 10;
}
message Void {}
message UUID {
uint32 part1 = 1;
uint32 part2 = 2;
uint32 part3 = 3;
uint32 part4 = 4;
}
enum NatType {
// has NAT; but own a single public IP, port is not changed
Unknown = 0;
OpenInternet = 1;
NoPAT = 2;
FullCone = 3;
Restricted = 4;
PortRestricted = 5;
Symmetric = 6;
SymUdpFirewall = 7;
SymmetricEasyInc = 8;
SymmetricEasyDec = 9;
}
message Ipv4Addr { uint32 addr = 1; }
message Ipv6Addr {
uint32 part1 = 1;
uint32 part2 = 2;
uint32 part3 = 3;
uint32 part4 = 4;
}
message IpAddr {
oneof ip {
Ipv4Addr ipv4 = 1;
Ipv6Addr ipv6 = 2;
};
}
message Ipv4Inet {
Ipv4Addr address = 1;
uint32 network_length = 2;
}
message Ipv6Inet {
Ipv6Addr address = 1;
uint32 network_length = 2;
}
message IpInet {
oneof ip {
Ipv4Inet ipv4 = 1;
Ipv6Inet ipv6 = 2;
};
}
message Url { string url = 1; }
message SocketAddr {
oneof ip {
Ipv4Addr ipv4 = 1;
Ipv6Addr ipv6 = 2;
};
uint32 port = 3;
}
message TunnelInfo {
string tunnel_type = 1;
common.Url local_addr = 2;
common.Url remote_addr = 3;
common.Url resolved_remote_addr = 4;
}
message StunInfo {
NatType udp_nat_type = 1;
NatType tcp_nat_type = 2;
int64 last_update_time = 3;
repeated string public_ip = 4;
uint32 min_port = 5;
uint32 max_port = 6;
}
message PeerFeatureFlag {
bool is_public_server = 1;
bool avoid_relay_data = 2;
bool kcp_input = 3;
bool no_relay_kcp = 4;
bool support_conn_list_sync = 5;
bool quic_input = 6;
bool no_relay_quic = 7;
bool is_credential_peer = 8;
bool need_p2p = 9;
bool disable_p2p = 10;
bool ipv6_public_addr_provider = 11;
}
enum SocketType {
TCP = 0;
UDP = 1;
}
message PortForwardConfigPb {
SocketAddr bind_addr = 1;
SocketAddr dst_addr = 2;
SocketType socket_type = 3;
}
message ProxyDstInfo { SocketAddr dst_addr = 1; }
message SecureModeConfig {
bool enabled = 1;
// base64(X25519 private key), used by shared node to present a stable identity
optional string local_private_key = 2;
// base64(X25519 public key), required if local_private_key is set
optional string local_public_key = 3;
}