syntax = "proto3";

package v2ray.core.app.proxyman;
option csharp_namespace = "V2Ray.Core.App.Proxyman";
option go_package = "proxyman";
option java_package = "com.v2ray.core.app.proxyman";
option java_multiple_files = true;

message InboundConfig {
}

import "v2ray.com/core/common/serial/typed_message.proto";
import "v2ray.com/core/common/net/address.proto";
import "v2ray.com/core/common/net/destination.proto";
import "v2ray.com/core/common/net/port.proto";
import "v2ray.com/core/transport/internet/config.proto";

message AllocationStrategy {
  enum Type {
    // Always allocate all connection handlers.
    Always = 0;

    // Randomly allocate specific range of handlers.
    Random = 1;

    // External. Not supported yet.
    External = 2;
  }

  Type type = 1;

  message AllocationStrategyConcurrency {
    uint32 value = 1;
  }

  // Number of handlers (ports) running in parallel.
  // Default value is 3 if unset.
  AllocationStrategyConcurrency concurrency = 2;


  message AllocationStrategyRefresh {
    uint32 value = 1;
  }

  // Number of minutes before a handler is regenerated.
  // Default value is 5 if unset.
  AllocationStrategyRefresh refresh = 3;
}

message ReceiverConfig {
  v2ray.core.common.net.PortRange port_range = 1;
  v2ray.core.common.net.IPOrDomain listen = 2;
  AllocationStrategy allocation_strategy = 3;
  v2ray.core.transport.internet.StreamConfig stream_settings = 4;
  bool receive_original_destination = 5;
  bool allow_passive_connection = 6 [deprecated=true];
}

message InboundHandlerConfig {
  string tag = 1;
  v2ray.core.common.serial.TypedMessage receiver_settings = 2;
  v2ray.core.common.serial.TypedMessage proxy_settings = 3;
  DispatchConfig dispatch_settings = 4;
}

message OutboundConfig {
  
}

message SenderConfig {
  // Send traffic through the given IP. Only IP is allowed.
  v2ray.core.common.net.IPOrDomain via = 1;
  v2ray.core.transport.internet.StreamConfig stream_settings = 2;
  v2ray.core.transport.internet.ProxyConfig proxy_settings = 3;
}

message OutboundHandlerConfig {
  string tag = 1;
  v2ray.core.common.serial.TypedMessage sender_settings = 2;
  v2ray.core.common.serial.TypedMessage proxy_settings = 3;
  int64 expire = 4;
  string comment = 5;
  DispatchConfig dispatch_settings = 6;
}

message MultiplexingConfig {
  bool enabled = 1;
}

message DispatchConfig {
  MultiplexingConfig mux_settings = 1;
}

message SessionFrame {
  uint32 id = 1;

  enum FrameCommand {
    SessionNew = 0;
    SessionKeep = 1;
    SessionEnd = 2;
  }

  FrameCommand command = 2;

  v2ray.core.common.net.Endpoint target = 3;
  bytes payload = 4;
}
