From 02643fb6bbac8e0da4cc46ce2fd48acac76eb570 Mon Sep 17 00:00:00 2001 From: 9seconds Date: Fri, 12 Mar 2021 16:21:52 +0300 Subject: [PATCH] Add concurrency parameter --- config/config.go | 30 ++++++++++++++++-------------- example.config.toml | 4 ++++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/config/config.go b/config/config.go index c97075b..702c5f7 100644 --- a/config/config.go +++ b/config/config.go @@ -10,13 +10,14 @@ import ( ) type Config struct { - Debug bool `json:"debug"` - Secret mtglib.Secret `json:"secret"` - BindTo TypeHostPort `json:"bind-to"` - TCPBuffer TypeBytes `json:"tcp-buffer"` - PreferIP TypePreferIP `json:"prefer-ip"` - CloakPort TypePort `json:"cloak-port"` - Defense struct { + Debug bool `json:"debug"` + Secret mtglib.Secret `json:"secret"` + BindTo TypeHostPort `json:"bind-to"` + TCPBuffer TypeBytes `json:"tcp-buffer"` + PreferIP TypePreferIP `json:"prefer-ip"` + CloakPort TypePort `json:"cloak-port"` + Concurrency uint `json:"concurrency"` + Defense struct { Time struct { Enabled bool `json:"enabled"` AllowSkewness TypeDuration `json:"allow-skewness"` @@ -80,13 +81,14 @@ func (c *Config) String() string { } type configRaw struct { - Debug bool `toml:"debug" json:"debug,omitempty"` - Secret string `toml:"secret" json:"secret"` - BindTo string `toml:"bind-to" json:"bind-to"` - TCPBuffer string `toml:"tcp-buffer" json:"tcp-buffer,omitempty"` - PreferIP string `toml:"prefer-ip" json:"prefer-ip,omitempty"` - CloakPort uint `toml:"cloak-port" json:"cloak-port,omitempty"` - Defense struct { + Debug bool `toml:"debug" json:"debug,omitempty"` + Secret string `toml:"secret" json:"secret"` + BindTo string `toml:"bind-to" json:"bind-to"` + TCPBuffer string `toml:"tcp-buffer" json:"tcp-buffer,omitempty"` + PreferIP string `toml:"prefer-ip" json:"prefer-ip,omitempty"` + CloakPort uint `toml:"cloak-port" json:"cloak-port,omitempty"` + Concurrency uint `toml:"concurrency" json:"concurrency,omitempty"` + Defense struct { Time struct { Enabled bool `toml:"enabled" json:"enabled,omitempty"` AllowSkewness string `toml:"allow-skewness" json:"allow-skewness,omitempty"` diff --git a/example.config.toml b/example.config.toml index cf18a31..a9ff45b 100644 --- a/example.config.toml +++ b/example.config.toml @@ -23,6 +23,10 @@ secret = "ee367a189aee18fa31c190054efd4a8e9573746f726167652e676f6f676c6561706973 # Host:port pair to run proxy on. bind-to = "0.0.0.0:3128" +# Defines how many concurrent connections are allowed to this proxy. +# All other incoming connections are going to be dropped. +concurrency = 8192 + # A size of user-space buffer for TCP to use. Since we do 2 connections, # then we have tcp-buffer * (4 + 2) per each connection: read/write for # each connection + 2 copy buffers to pump the data between sockets.