Parcourir la source

Add concurrency parameter

tags/v2.0.0-rc1
9seconds il y a 5 ans
Parent
révision
02643fb6bb
2 fichiers modifiés avec 20 ajouts et 14 suppressions
  1. 16
    14
      config/config.go
  2. 4
    0
      example.config.toml

+ 16
- 14
config/config.go Voir le fichier

@@ -10,13 +10,14 @@ import (
10 10
 )
11 11
 
12 12
 type Config struct {
13
-	Debug     bool          `json:"debug"`
14
-	Secret    mtglib.Secret `json:"secret"`
15
-	BindTo    TypeHostPort  `json:"bind-to"`
16
-	TCPBuffer TypeBytes     `json:"tcp-buffer"`
17
-	PreferIP  TypePreferIP  `json:"prefer-ip"`
18
-	CloakPort TypePort      `json:"cloak-port"`
19
-	Defense   struct {
13
+	Debug       bool          `json:"debug"`
14
+	Secret      mtglib.Secret `json:"secret"`
15
+	BindTo      TypeHostPort  `json:"bind-to"`
16
+	TCPBuffer   TypeBytes     `json:"tcp-buffer"`
17
+	PreferIP    TypePreferIP  `json:"prefer-ip"`
18
+	CloakPort   TypePort      `json:"cloak-port"`
19
+	Concurrency uint          `json:"concurrency"`
20
+	Defense     struct {
20 21
 		Time struct {
21 22
 			Enabled       bool         `json:"enabled"`
22 23
 			AllowSkewness TypeDuration `json:"allow-skewness"`
@@ -80,13 +81,14 @@ func (c *Config) String() string {
80 81
 }
81 82
 
82 83
 type configRaw struct {
83
-	Debug     bool   `toml:"debug" json:"debug,omitempty"`
84
-	Secret    string `toml:"secret" json:"secret"`
85
-	BindTo    string `toml:"bind-to" json:"bind-to"`
86
-	TCPBuffer string `toml:"tcp-buffer" json:"tcp-buffer,omitempty"`
87
-	PreferIP  string `toml:"prefer-ip" json:"prefer-ip,omitempty"`
88
-	CloakPort uint   `toml:"cloak-port" json:"cloak-port,omitempty"`
89
-	Defense   struct {
84
+	Debug       bool   `toml:"debug" json:"debug,omitempty"`
85
+	Secret      string `toml:"secret" json:"secret"`
86
+	BindTo      string `toml:"bind-to" json:"bind-to"`
87
+	TCPBuffer   string `toml:"tcp-buffer" json:"tcp-buffer,omitempty"`
88
+	PreferIP    string `toml:"prefer-ip" json:"prefer-ip,omitempty"`
89
+	CloakPort   uint   `toml:"cloak-port" json:"cloak-port,omitempty"`
90
+	Concurrency uint   `toml:"concurrency" json:"concurrency,omitempty"`
91
+	Defense     struct {
90 92
 		Time struct {
91 93
 			Enabled       bool   `toml:"enabled" json:"enabled,omitempty"`
92 94
 			AllowSkewness string `toml:"allow-skewness" json:"allow-skewness,omitempty"`

+ 4
- 0
example.config.toml Voir le fichier

@@ -23,6 +23,10 @@ secret = "ee367a189aee18fa31c190054efd4a8e9573746f726167652e676f6f676c6561706973
23 23
 # Host:port pair to run proxy on.
24 24
 bind-to = "0.0.0.0:3128"
25 25
 
26
+# Defines how many concurrent connections are allowed to this proxy.
27
+# All other incoming connections are going to be dropped.
28
+concurrency = 8192
29
+
26 30
 # A size of user-space buffer for TCP to use. Since we do 2 connections,
27 31
 # then we have tcp-buffer * (4 + 2) per each connection: read/write for
28 32
 # each connection + 2 copy buffers to pump the data between sockets.

Chargement…
Annuler
Enregistrer