Skip to content

Configuration

chop1k edited this page Feb 17, 2022 · 33 revisions

Location

All configuration for kneesocks located in /etc/kneesocks directory. It can contain 3 files:

  • config.json - config of socks server.
  • test-server-config.json - config for test server, which used in testing.
  • e2e.json - configuration for e2e tests.

NOTE: You can override default config location by setting config_path environment variable.

Socks server configuration reference

Config file root consist of:

  • Tcp - Tcp configuration, here you specify bind address of tcp server, port, deadlines, etc.
  • Udp - Udp configuration, here you specify bind address of udp server, port, deadlines, etc.
  • SocksV4 - Socks version 4 configuration, here you specify configuration specific for socks v4.
  • SocksV4a - Socks version 4a configuration, here you specify configuration specific for socks v4a.
  • SocksV5 - Socks version 5 configuration, here you specify configuration specific for socks v5.
  • Log - Logging configuration, here you specify what to log, where to log, how to log, etc.

Examples of prepared configuration located in examples/kneesocks directory. It also contains docker-compose files and other data.

Also, we recommend to specify every value, because if you not specify it it will set default golang value for appropriate type of the parameter. For example, to uint type default value will be 0, for string default value will be "", for pointer types default value will be nil.

NOTE: Default value may not satisfy validation rules, and then server may not start or (in rare cases) even panic at runtime.

Tcp.Bind.Address: string

Specify tcp address to which tcp server will bind. Must be ipv4, ipv6 or hostname like localhost.

To listen only for ipv4 tcp connections specify "127.0.0.1" like below.

{
    "Tcp": {
        "Bind": {
            "Address": "127.0.0.1"
        }
    }
}

To listen only for ipv6 tcp connections specify local ipv6 address line below.

{
    "Tcp": {
        "Bind": {
            "Address": "[::1]"
        }
    }
}

To listen for both ipv4 and ipv6 tcp connections specify empty string like below.

{
    "Tcp": {
        "Bind": {
            "Address": ""
        }
    }
}

Tcp.Bind.Port: uint16

Specify port to which server will bind. According to wiki default port for socks servers is 1080, so we recommend using this number.

{
    "Tcp": {
        "Bind": {
            "Address": "",
            "Port": 1080
        }
    }
}

Tcp.Buffer.ClientSize: uint

Specify length of buffer, which will be used in reading data from client. Default value is 512, we don't recommend use value less than 256, because low values will decrease server performance. Just like a too big values.

{
    "Tcp": {
        "Buffer": {
            "ClientSize": 512
        }
    }
}

Tcp.Buffer.HostSize: uint

Specify length of buffer, which will be used in reading data from host. Default value is 512, we don't recommend use value less than 256, because low values will decrease server performance. Just like a too big values.

{
    "Tcp": {
        "Buffer": {
            "ClientSize": 512,
            "HostSize": 512
        }
    }
}

Tcp.Deadline.Welcome: int

Specify time in seconds which server will wait for first chunk of socks protocol.

This option critical for slow connections, the lower the value, the harder it will be to use socks server for slow connections. When timeout exceeded it will close connection to client without notifying him about it. We recommend use value between 10 and 60.

{
    "Tcp": {
        "Deadline": {
            "Welcome": 20
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for first chunk.

{
    "Tcp": {
        "Deadline": {
            "Welcome": -1
        }
    }
}

Tcp.Deadline.Exchange: int

Specify time in seconds which server will wait for server to exchange host and client connections. Used in bind command.

{
    "Tcp": {
        "Deadline": {
            "Welcome": 20,
            "Exchange": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for first chunk.

{
    "Tcp": {
        "Deadline": {
            "Welcome": -1,
            "Exchange": -1
        }
    }
}

Udp.Bind.Address: string

Specify udp address to which server will bind. Must be ipv4, ipv6 or hostname like localhost.

To listen only for ipv4 specify "127.0.0.1" like below.

{
    "Tcp": {
        "Bind": {
            "Address": "127.0.0.1"
        }
    }
}

To listen only for ipv6 specify ipv6 address line below.

{
    "Udp": {
        "Bind": {
            "Address": "[::1]"
        }
    }
}

To listen for both ipv4 and ipv6 specify empty string like below.

{
    "Udp": {
        "Bind": {
            "Address": ""
        }
    }
}

Udp.Bind.Port: uint16

Specify port to which server will bind. According to wiki default port for socks servers is 1080, so we recommend using this number.

{
    "Udp": {
        "Bind": {
            "Address": "",
            "Port": 1080
        }
    }
}

Udp.Buffer.PacketSize: uint

Specify maximum length of udp packet. We recommend using 65535 like below.

{
    "Udp": {
        "Buffer": {
            "PacketSize": 65535
        }
    }
}

Udp.Deadline.Read: int

Specify time in seconds which server will wait for response by the host. When timeout exceeded server closes udp socket and ignores all packets from the host, until client send packet to the host again.

{
    "Udp": {
        "Deadline": {
            "Read": 30
        }
    }
}

SocksV4

If you want to turn off socks version 4 just specify null and server will not handle socks v4 connections.

{
    "SocksV4": null
}

SocksV4.AllowConnect: bool

Allow connect command of the socks protocol. In connect command server should relay tcp connection from client to host.

false will prohibit the command and server will respond with failure status and close connection.

{
    "SocksV4": {
        "AllowConnect": false
    }
}

true for allow the command.

{
    "SocksV4": {
        "AllowConnect": true
    }
}

SocksV4.AllowBind: bool

Same as AllowConnect but for bind command of socks v4 protocol.

We strongly recommend set this option to false because implementation have absolutely random behavior, and not ready to production yet.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false
    }
}

SocksV4.Deadline.Response: int

Specify time in second which server will wait for response to be delivered to client. When timeout exceeds server will close connection without notifying the client. This deadline sets for any response regardless of status.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Deadline": {
            "Response": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for response.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Deadline": {
            "Response": -1
        }
    }
}

SocksV4.Deadline.Connect: int

Specify time in seconds which server will wait for host to accept the connection. When timeout exceeds server will respond with failure status and close connection.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Deadline": {
            "Response": 30,
            "Connect": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for connect.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Deadline": {
            "Response": 30,
            "Connect": -1
        }
    }
}

SocksV4.Deadline.Bind: int

Specify time in seconds which server will wait for host to make connection to the server. When timeout exceeds server closes association and respond with failure status.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Deadline": {
            "Response": 30,
            "Connect": 30,
            "Bind": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for bind.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Deadline": {
            "Response": 30,
            "Connect": 30,
            "Bind": -1
        }
    }
}

SocksV4.Restrictions.Whitelist: []string

Specify list of regex patterns for addresses which will not be blocked. Any address that not matches the pattern will be blocked. Empty array will turn off the whitelist and it will not be checked.

NOTE: Whitelist check goes before blacklist.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Restrictions": {
            "Whitelist": [
                ".*.github.com:*"
            ],
            "Blacklist": []
        }
    }
}

SocksV4.Restrictions.Blacklist: []string

Specify list of regex patterns for addresses which will be blocked. Each request with address that matches the pattern will be blocked.

You can block any request to any address and any port using power of regexes.

NOTE: You should use golang regexes because golang regex std library use specific dialect, so other dialect may not be suitable.

NOTE: If you specify invalid regex pattern, it will be skipped without any notification in logs or console, so be careful.

NOTE: Blacklist check goes after whitelist.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Restrictions": {
            "Whitelist": [],
            "Blacklist": [
                "127.0.0.1:*"
            ]
        }
    }
}

SocksV4.Restrictions.Rate.MaxSimultaneousConnections: int

Specify maximum number of simultaneous connections. If number of simultaneous connections exceeds maximum, other connections will failure until other connection closed.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Restrictions": {
            "Whitelist": [],
            "Blacklist": [],
            "Rate": {
                "MaxSimultaneousConnections": 100
            }
        }
    }
}

Specify -1 for no limit. If value < 0 server will not count and will not check number of connections.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Restrictions": {
            "Whitelist": [],
            "Blacklist": [],
            "Rate": {
                "MaxSimultaneousConnections": -1
            }
        }
    }
}

SocksV4.Restrictions.Rate.HostReadBuffersPerSecond: int

If you want to limit download speed, use this option.

Specify maximum number of reads from host per second. Every time server reads data from the host it will increment counter, and when counter exceeds the HostReadBuffersPerSecond number it will set counter to 0 and wait for next second.

So, to compute maximum speed use next formula Tcp.Buffer.HostSize * SocksV4.Restrictions.Rate.HostReadBuffersPerSecond. For "Tcp.Buffer.HostSize": 512 and "Socks.Restrictions.Rate.HostReadBuffersPerSecond": 2048 maximum reads from host will be 1048576 bytes per second, or 1024 kilobytes per second, or 1 megabyte per second.

NOTE: Other rate limits will also affect final limit.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Restrictions": {
            "Whitelist": [],
            "Blacklist": [],
            "Rate": {
                "MaxSimultaneousConnections": -1,
                "HostReadBuffersPerSecond": 2048
            }
        }
    }
}

Specify -1 for no limit. If value < 0 server will not count reads from host and thus will not limit.

{
    "SocksV4": {
        "AllowConnect": true,
        "AllowBind": false,
        "Restrictions": {
            "Whitelist": [],
            "Blacklist": [],
            "Rate": {
                "MaxSimultaneousConnections": -1,
                "HostReadBuffersPerSecond": -1
            }
        }
    }
}

SocksV4.Restrictions.Rate.HostWriteBuffersPerSecond: int

The same as SocksV4.Restrictions.Rate.HostReadBuffersPerSecond but for write from host.

SocksV4.Restrictions.Rate.ClientReadBuffersPerSecond: int

If you want to limit upload speed, use this option.

The same as SocksV4.Restrictions.Rate.HostReadBuffersPerSecond but for client.

SocksV4a

If you want to turn off socks version 4a just specify null and server will not handle socks v4a connections.

{
    "SocksV4a": null
}

SocksV4a.AllowConnect: bool

The same as SocksV4.AllowConnect but for socks v4a.

SocksV4a.AllowBind: bool

The same as SocksV4.AllowBind but for socks v4a.

SocksV4a.Deadline.Response: int

The same as SocksV4.Deadline.Response but for socks v4a.

SocksV4a.Deadline.Connect: int

The same as SocksV4.Deadline.Connect but for socks v4a.

SocksV4a.Deadline.Bind: int

The same as SocksV4.Deadline.Bind but for socks v4a.

SocksV4a.Restrictions.Whitelist: []string

The same as SocksV4.Restrictions.Whitelist but for socks v4a.

SocksV4a.Restrictions.Blacklist: []string

The same as SocksV4.Restrictions.Blacklist but for socks v4a.

SocksV4a.Restrictions.Rate.MaxSimultaneousConnections: int

The same as SocksV4.Restrictions.Rate.MaxSimultaneousConnections but for socks v4a.

SocksV4a.Restrictions.Rate.HostReadBuffersPerSecond: int

The same as SocksV4.Restrictions.Rate.HostReadBuffersPerSecond but for socks v4a.

SocksV4a.Restrictions.Rate.HostWriteBuffersPerSecond: int

The same as SocksV4.Restrictions.Rate.HostWriteBuffersPerSecond but for socks v4a.

SocksV4a.Restrictions.Rate.ClientReadBuffersPerSecond: int

The same as SocksV4.Restrictions.Rate.ClientReadBuffersPerSecond but for socks v4a.

SocksV4a.Restrictions.Rate.ClientWriteBuffersPerSecond: int

The same as SocksV4.Restrictions.Rate.ClientWriteBuffersPerSecond but for socks v4a.

SocksV5

If you want to turn off socks version 5 just specify null and server will not handle socks v5 connections.

{
    "SocksV5": null
}

SocksV5.AllowConnect: bool

The same as SocksV4.AllowConnect but for socks v5.

SocksV5.AllowBind: bool

The same as SocksV4.AllowBind but for socks v5.

SocksV5.AllowUdpAssociation: bool

Allow udp associate command of socks v5 protocol.

If you sure that you will not use udp we recommend to turn off this command.

{
    "SocksV5": {
        "AllowConnect": true,
        "AllowBind": false,
        "AllowUdpAssociation": false
    }
}

SocksV5.AllowIPv4: bool

Allow ipv4 address type. If false any request to any ipv4 address will be blocked.

{
    "SocksV5": {
        "AllowConnect": true,
        "AllowBind": false,
        "AllowUdpAssociation": false,
        "AllowIPv4": true
    }
}

SocksV5.AllowDomain: bool

Allow domain address type. If false any request to any domain address will be blocked.

NOTE: Many browsers like chromium uses domain address type, so if you want to use socks v5 via browser we recommend to allow this address type.

{
    "SocksV5": {
        "AllowConnect": true,
        "AllowBind": false,
        "AllowUdpAssociation": false,
        "AllowIPv4": true,
        "AllowDomain": true
    }
}

SocksV5.AllowIPv6: bool

Allow ipv6 address type. If false any request to any ipv6 address type will be blocked.

{
    "SocksV5": {
        "AllowConnect": true,
        "AllowBind": false,
        "AllowUdpAssociation": false,
        "AllowIPv4": true,
        "AllowDomain": true,
        "AllowIPv6": true
    }
}

SocksV5.AuthenticationMethodsAllowed: []string

List of authentication methods allowed.

Supported methods:

  • no-authentication - any user that authenticates using this method will be considered as anonymous user.
  • name/password - name and password authentication.

NOTE: Order in which authentication methods specified reflects priority of authentication method.

So, if you specify no-authentication method first, server will check for no-authentication method first, and then it will check other methods if specified.

NOTE: There must be at least one method, if no methods specified it will lead to unexpected behavior.

{
    "SocksV5": {
        "AuthenticationMethodsAllowed": [
            "no-authentication",
            "name/password"
        ]
    }
}

SocksV5.Deadline.Selection: int

Specify time in seconds which server will wait for selection chunk to be delivered. When timeout exceeds server will close connection without notifying the client.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for selection chunk.

{
    "SocksV5": {
        "Deadline": {
            "Selection": -1
        }
    }
}

SocksV5.Deadline.Password: int

Specify time in seconds which server will wait for password chunk, if name/password method was chosen. When timeout exceeds server will close connection without notifying the client.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for password chunk.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": -1
        }
    }
}

SocksV5.Deadline.PasswordResponse: int

Specify time in seconds which server will wait for password response chunk to be delivered, if name/password method was chosen. When timeout exceeds server will close connection without notifying the client.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30,
            "PasswordResponse": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for password response chunk.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30,
            "PasswordResponse": -1
        }
    }
}

SocksV5.Deadline.Request: int

Specify time in seconds which server will wait for request chunk. When timeout exceeds server will close connection without notifying the client.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30,
            "PasswordResponse": 30,
            "Request": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for request chunk.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30,
            "PasswordResponse": 30,
            "Request": -1
        }
    }
}

SocksV5.Deadline.Response: int

Specify time in seconds which server will wait for response chunk to be delivered. When timeout exceeds server will close connection without notifying the client. This deadline sets for any response regardless of status.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30,
            "PasswordResponse": 30,
            "Request": 30,
            "Response": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for response chunk.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30,
            "PasswordResponse": 30,
            "Request": 30,
            "Response": -1
        }
    }
}

SocksV5.Deadline.Connect: int

Specify time in seconds which server will wait for host to accept the connection. When timeout exceeds server will respond with TTL Expired status and close connection.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30,
            "PasswordResponse": 30,
            "Request": 30,
            "Response": 30,
            "Connect": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for connect.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30,
            "PasswordResponse": 30,
            "Request": 30,
            "Response": 30,
            "Connect": -1
        }
    }
}

SocksV5.Deadline.Bind: int

Specify time in seconds which server will wait for host to make connection to the server. When timeout exceeds server closes association and respond with failure status.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30,
            "PasswordResponse": 30,
            "Request": 30,
            "Response": 30,
            "Connect": 30,
            "Bind": 30
        }
    }
}

Specify -1 for no deadline. If value < 0 server will not set any deadline for bind.

{
    "SocksV5": {
        "Deadline": {
            "Selection": 30,
            "Password": 30,
            "PasswordResponse": 30,
            "Request": 30,
            "Response": 30,
            "Connect": 30,
            "Bind": -1
        }
    }
}

SocksV5.Users

Specify users in form like below.

{
    "SocksV5": {
        "Users": {
            "username": {
                ...
            }
        }
    }
}

NOTE: Username anonymous is reserved. All users that authenticates via no-authentication method will be considered as anonymous, so all rules and restrictions for anonymous user will be satisfied.

{
    "SocksV5": {
        "Users": {
            "username": {
                ...
            },
            "anonymous": {
                ...
            }
        }
    }
}

SocksV5.Users.*.Password: string

Specify password for user.

{
    "SocksV5": {
        "Users": {
            "username": {
                "Password": "password"
            }
        }
    }
}

SocksV5.Users.*.Restrictions.Whitelist: []string

The same as SocksV4.Restrictions.Whitelist but for specific user.

{
    "SocksV5": {
        "Users": {
            "username": {
                "Restrictions": {
                    "Whitelist": []
                }
            }
        }
    }
}

SocksV5.Users.*.Restrictions.Blacklist: []string

The same as SocksV4.Restrictions.Blacklist but for specific user.

{
    "SocksV5": {
        "Users": {
            "username": {
                "Restrictions": {
                    "Whitelist": [],
                    "Blacklist": [
                        "127.0.0.1:*"
                    ]
                }
            }
        }
    }
}

SocksV5.Users.*.Restrictions.Rate.MaxSimultaneousConnections: int

The same as SocksV4.Restrictions.Rate.MaxSimultaneousConnections but for specific user.

{
    "SocksV5": {
        "Users": {
            "username": {
                "Restrictions": {
                    "Rate": {
                        "MaxSimultaneousConnections": -1
                    }
                }
            }
        }
    }
}

SocksV5.Users.*.Restrictions.Rate.HostReadBuffersPerSecond: int

The same as SocksV4.Restrictions.Rate.HostReadBuffersPerSecond but for specific user.

{
    "SocksV5": {
        "Users": {
            "username": {
                "Restrictions": {
                    "Rate": {
                        "MaxSimultaneousConnections": -1,
                        "HostReadBuffersPerSecond": -1
                    }
                }
            }
        }
    }
}

SocksV5.Users.*.Restrictions.Rate.HostWriteBuffersPerSecond: int

The same as SocksV4.Restrictions.Rate.HostWriteBuffersPerSecond but for specific user.

{
    "SocksV5": {
        "Users": {
            "username": {
                "Restrictions": {
                    "Rate": {
                        "MaxSimultaneousConnections": -1,
                        "HostReadBuffersPerSecond": -1,
                        "HostWriteBuffersPerSecond": -1
                    }
                }
            }
        }
    }
}

SocksV5.Users.*.Restrictions.Rate.ClientReadBuffersPerSecond: int

The same as SocksV4.Restrictions.Rate.ClientReadBuffersPerSecond but for specific user.

{
    "SocksV5": {
        "Users": {
            "username": {
                "Restrictions": {
                    "Rate": {
                        "MaxSimultaneousConnections": -1,
                        "HostReadBuffersPerSecond": -1,
                        "HostWriteBuffersPerSecond": -1,
                        "ClientReadBuffersPerSecond": -1
                    }
                }
            }
        }
    }
}

SocksV5.Users.*.Restrictions.Rate.ClientWriteBuffersPerSecond: int

The same as SocksV4.Restrictions.Rate.ClientWriteBuffersPerSecond but for specific user.

{
    "SocksV5": {
        "Users": {
            "username": {
                "Restrictions": {
                    "Rate": {
                        "MaxSimultaneousConnections": -1,
                        "HostReadBuffersPerSecond": -1,
                        "HostWriteBuffersPerSecond": -1,
                        "ClientReadBuffersPerSecond": -1,
                        "ClientWriteBuffersPerSecond": -1
                    }
                }
            }
        }
    }
}

Log.Tcp

If you don't want to log tcp, just specify null.

{
    "Log": {
        "Tcp": null
    }
}

Log.Tcp.Level: int

Level of logs that will be logged.

According to rs/zerolog:

  • panic - 5
  • fatal - 4
  • error - 3
  • warn - 2
  • info - 1
  • debug - 0
  • trace - -1

We recommend set this value to 1.

{
    "Log": {
        "Tcp": {
            "Level": 1
        }
    }
}

Log.Tcp.Console

If you want to turn off console logging, just specify null.

{
    "Log": {
        "Tcp": {
            "Console": null
        }
    }
}

Log.Tcp.Console.TimeFormat: string

Format for formatting time. We recommend to set it to 2006-01-02 15:04:05.

NOTE: This is golang format, not default format, so see golang documentation for more information.

{
    "Log": {
        "Tcp": {
            "Console": {
                "TimeFormat": "2006-01-02 15:04:05"
            }
        }
    }
}

Log.Tcp.File

If you want to turn off logging to file, just specify null.

{
    "Log": {
        "Tcp": {
            "File": null
        }
    }
}

Log.Tcp.File.Path: string

Specify path to file which will be used for logs. If file not exists server will create a new one. If file exists it will append new logs to end of file.

NOTE: Default log directory for unix systems /var/log/kneesocks. We recommend use this directory.

{
    "Log": {
        "Tcp": {
            "File": {
                "Path": "/var/log/kneesocks/tcp.log"
            }
        }
    }
}

Log.Udp

The same as Log.Tcp, but for udp.

Log.Udp.Level: int

The same as Log.Tcp.Level, but for udp.

Log.Udp.Console

The same as Log.Tcp.Console, but for udp.

Log.Udp.Console.TimeFormat: string

The same as Log.Tcp.Console.TimeFormat, but for udp.

Log.Udp.File

The same as Log.Tcp.File, but for udp.

Log.Udp.File.Path: string

The same as Log.Tcp.File.Path, but for udp.

Log.SocksV4

The same as Log.Tcp, but for socks v4.

Log.SocksV4.Level: int

The same as Log.Tcp.Level, but for socks v4.

Log.SocksV4.Console

The same as Log.Tcp.Console, but for socks v4.

Log.SocksV4.Console.TimeFormat: string

The same as Log.Tcp.Console.TimeFormat, but for socks v4.

Log.SocksV4.File

The same as Log.Tcp.File, but for socks v4.

Log.SocksV4.File.Path: string

The same as Log.Tcp.File.Path, but for socks v4.

Log.SocksV4a

The same as Log.Tcp, but for socks v4a.

Log.SocksV4a.Level: int

The same as Log.Tcp.Level, but for socks v4a.

Log.SocksV4a.Console

The same as Log.Tcp.Console, but for socks v4a.

Log.SocksV4a.Console.TimeFormat: string

The same as Log.Tcp.Console.TimeFormat, but for socks v4a.

Log.SocksV4a.File

The same as Log.Tcp.File, but for socks v4a.

Log.SocksV4a.File.Path: string

The same as Log.Tcp.File.Path, but for socks v4a.

Log.SocksV5

The same as Log.Tcp, but for socks v5.

Log.SocksV5.Level: int

The same as Log.Tcp.Level, but for socks v5.

Log.SocksV5.Console

The same as Log.Tcp.Console, but for socks v5.

Log.SocksV5.Console.TimeFormat: string

The same as Log.Tcp.Console.TimeFormat, but for socks v5.

Log.SocksV5.File

The same as Log.Tcp.File, but for socks v5.

Log.SocksV5.File.Path: string

The same as Log.Tcp.File.Path, but for socks v5.

Example of config file

Below example of end config file.

NOTE: This example turn on all functionalities and have no limitations.

{
  "Tcp": {
    "Bind": {
      "Address": "",
      "Port": 1080
    },
    "Buffer": {
      "ClientSize": 512,
      "HostSize": 512
    },
    "Deadline": {
      "Welcome": 2,
      "Exchange": 15
    }
  },
  "Udp": {
    "Bind": {
      "Address": "",
      "Port": 1080
    },
    "Buffer": {
      "PacketSize": 65535
    },
    "Deadline": {
      "Read": 30
    }
  },
  "SocksV4": {
    "AllowConnect": true,
    "AllowBind": true,
    "Deadline": {
      "Response": -1,
      "Connect": -1,
      "Bind": -1
    },
    "Restrictions": {
      "Blacklist": [],
      "Whitelist": [],
      "Rate": {
        "MaxSimultaneousConnections": -1,
        "HostReadBuffersPerSecond": -1,
        "HostWriteBuffersPerSecond": -1,
        "ClientReadBuffersPerSecond": -1,
        "ClientWriteBuffersPerSecond": -1
      }
    }
  },
  "SocksV4a": {
    "AllowConnect": true,
    "AllowBind": true,
    "Deadline": {
      "Response": -1,
      "Connect": -1,
      "Bind": -1
    },
    "Restrictions": {
      "Blacklist": [],
      "Whitelist": [],
      "Rate": {
        "MaxSimultaneousConnections": -1,
        "HostReadBuffersPerSecond": -1,
        "HostWriteBuffersPerSecond": -1,
        "ClientReadBuffersPerSecond": -1,
        "ClientWriteBuffersPerSecond": -1
      }
    }
  },
  "SocksV5": {
    "AllowConnect": true,
    "AllowBind": true,
    "AllowUdpAssociation": true,
    "AllowIPv4": true,
    "AllowIPv6": true,
    "AllowDomain": true,
    "AuthenticationMethodsAllowed": [
      "no-authentication",
      "name/password"
    ],
    "Deadline": {
      "Selection": -1,
      "Password": -1,
      "PasswordResponse": -1,
      "Request": -1,
      "Response": -1,
      "Connect": -1,
      "Bind": -1
    },
    "Users": {
      "admin": {
        "Password": "admin",
        "Restrictions": {
          "Blacklist": [],
          "Whitelist": [],
          "Rate": {
            "MaxSimultaneousConnections": -1,
            "HostReadBuffersPerSecond": -1,
            "HostWriteBuffersPerSecond": -1,
            "ClientReadBuffersPerSecond": -1,
            "ClientWriteBuffersPerSecond": -1
          }
        }
      },
      "anonymous": {
        "Password": "",
        "Restrictions": {
          "Blacklist": [],
          "Whitelist": [],
          "Rate": {
            "MaxSimultaneousConnections": -1,
            "HostReadBuffersPerSecond": -1,
            "HostWriteBuffersPerSecond": -1,
            "ClientReadBuffersPerSecond": -1,
            "ClientWriteBuffersPerSecond": -1
          }
        }
      }
    }
  },
  "Log": {
    "Tcp": {
      "Level": 1,
      "Console": {
        "TimeFormat": "2006-01-02 15:04:05"
      },
      "File": {
        "Path": "/var/log/kneesocks/tcp.log"
      }
    },
    "Udp": {
      "Level": 1,
      "Console": {
        "TimeFormat": "2006-01-02 15:04:05"
      },
      "File": {
        "Path": "/var/log/kneesocks/udp.log"
      }
    },
    "SocksV4": {
      "Level": 1,
      "Console": {
        "TimeFormat": "2006-01-02 15:04:05"
      },
      "File": {
        "Path": "/var/log/kneesocks/v4.log"
      }
    },
    "SocksV4a": {
      "Level": 1,
      "Console": {
        "TimeFormat": "2006-01-02 15:04:05"
      },
      "File": {
        "Path": "/var/log/kneesocks/v4a.log"
      }
    },
    "SocksV5": {
      "Level": 1,
      "Console": {
        "TimeFormat": "2006-01-02 15:04:05"
      },
      "File": {
        "Path": "/var/log/kneesocks/v5.log"
      }
    }
  }
}

Test server configuration reference

Socks.IPv4: string

Specify ipv4 address of socks server. It will be used during bind command tests.

{
    "Socks": {
        "IPv4": "127.0.0.1"
    }
}

Socks.IPv6: string

Specify ipv6 address of socks server. It will be used during bind command tests.

{
    "Socks": {
        "IPv4": "127.0.0.1",
        "IPv6": "[::1]"
    }
}

Socks.Port: uint16

Specify port of socks server. It will be used during bind command tests.

{
    "Socks": {
        "IPv4": "127.0.0.1",
        "IPv6": "[::1]",
        "Port": 1080
    }
}

Tcp.BindAddress: string

Specify address at which tcp server will listen. To listen for both ipv4 and ipv6 tcp connections specify empty string like below.

{
    "Tcp": {
        "BindAddress": ""
    }
}

Tcp.BindPort: uint16

Specify port at which bind tcp server will listen. Must be different from Tcp.ConnectPort

{
    "Tcp": {
        "BindAddress": "",
        "BindPort": 9000
    }
}

Tcp.ConnectPort: uint16

Specify port at which connect tcp server will listen. Must be different from Tcp.BindPort

{
    "Tcp": {
        "BindAddress": "",
        "BindPort": 9000,
        "ConnectPort": 9999
    }
}

Udp.BindAddress: string

Specify address at which udp server will listen. To listen for both ipv4 and ipv6 udp packets specify empty string like below.

{
    "Udp": {
        "BindAddress": ""
    }
}

Udp.BindPort: uint16

Specify port at which udp server will listen.

{
    "Udp": {
        "BindAddress": "",
        "BindPort": 9999
    }
}

Picture.BigPicturePath: string

Specify path to the big picture. We recommend to use ./configs/test_server/images/1.gif.

{
    "Picture": {
        "BigPicturePath": "./configs/test_server/images/1.gif"
    }
}

Picture.MiddlePicturePath: string

Specify path to the middle picture. We recommend to use ./configs/test_server/images/2.jpg.

{
    "Picture": {
        "BigPicturePath": "./configs/test_server/images/1.gif",
        "MiddlePicturePath": "./configs/test_server/images/2.jpg"
    }
}

Picture.SmallPicturePath: string

Specify path to the small picture. We recommend to use ./configs/test_server/images/3.jpg.

{
    "Picture": {
        "BigPicturePath": "./configs/test_server/images/1.gif",
        "MiddlePicturePath": "./configs/test_server/images/2.jpg",
        "SmallPicturePath": "./configs/test_server/images/3.jpg"
    }
}

Log.Path: string

Specify path to log file.

{
    "Log": {
        "Path": "/tmp/test-server.log"
    }
}

Example

{
  "Socks": {
    "IPv4": "127.0.0.1",
    "IPv6": "::1",
    "Port": 1080,
    "Zone": ""
  },
  "Tcp": {
    "BindAddress": "",
    "BindPort": 9000,
    "ConnectPort": 9999
  },
  "Udp": {
    "BindAddress": "",
    "BindPort": 9999
  },
  "Picture": {
    "BigPicturePath": "./configs/test_server/images/1.gif",
    "MiddlePicturePath": "./configs/test_server/images/2.jpg",
    "SmallPicturePath": "./configs/test_server/images/3.jpg"
  },
  "Log": {
    "Path": "/tmp/test-server.log"
  }
}

E2e tests configuration reference

Example

Below is default configuration, we recommend to use it.

{
  "V4": {
    "Bind": [
      {
        "Port": 10001,
        "Picture": 1
      },
      {
        "Port": 10002,
        "Picture": 2
      },
      {
        "Port": 10003,
        "Picture": 3
      }
    ],
    "Connect": [
      {
        "Picture": 1
      },
      {
        "Picture": 2
      },
      {
        "Picture": 3
      }
    ]
  },
  "V4a": {
    "Bind": [
      {
        "Port": 10004,
        "Picture": 1
      },
      {
        "Port": 10005,
        "Picture": 2
      },
      {
        "Port": 10006,
        "Picture": 3
      }
    ],
    "Connect": [
      {
        "Picture": 1
      },
      {
        "Picture": 2
      },
      {
        "Picture": 3
      }
    ]
  },
  "V5": {
    "Bind": [
      {
        "Port": 10007,
        "Picture": 1,
        "AddressType": 1
      },
      {
        "Port": 10008,
        "Picture": 1,
        "AddressType": 3
      },
      {
        "Port": 10009,
        "Picture": 1,
        "AddressType": 4
      },
      {
        "Port": 10010,
        "Picture": 2,
        "AddressType": 1
      },
      {
        "Port": 10011,
        "Picture": 2,
        "AddressType": 3
      },
      {
        "Port": 10012,
        "Picture": 2,
        "AddressType": 4
      },
      {
        "Port": 10013,
        "Picture": 3,
        "AddressType": 1
      },
      {
        "Port": 10014,
        "Picture": 3,
        "AddressType": 3
      },
      {
        "Port": 10015,
        "Picture": 3,
        "AddressType": 4
      }
    ],
    "Connect": [
      {
        "Picture": 1,
        "AddressType": 1
      },
      {
        "Picture": 1,
        "AddressType": 3
      },
      {
        "Picture": 1,
        "AddressType": 4
      },
      {
        "Picture": 2,
        "AddressType": 1
      },
      {
        "Picture": 2,
        "AddressType": 3
      },
      {
        "Picture": 2,
        "AddressType": 4
      },
      {
        "Picture": 3,
        "AddressType": 1
      },
      {
        "Picture": 3,
        "AddressType": 3
      },
      {
        "Picture": 3,
        "AddressType": 4
      }
    ],
    "Auth": [
      {
        "Picture": 1,
        "AddressType": 1,
        "Method": 0
      },
      {
        "Picture": 1,
        "AddressType": 3,
        "Method": 0
      },
      {
        "Picture": 1,
        "AddressType": 4,
        "Method": 0
      },
      {
        "Picture": 2,
        "AddressType": 1,
        "Method": 0
      },
      {
        "Picture": 2,
        "AddressType": 3,
        "Method": 0
      },
      {
        "Picture": 2,
        "AddressType": 4,
        "Method": 0
      },
      {
        "Picture": 3,
        "AddressType": 1,
        "Method": 0
      },
      {
        "Picture": 3,
        "AddressType": 3,
        "Method": 0
      },
      {
        "Picture": 3,
        "AddressType": 4,
        "Method": 0
      },
      {
        "Picture": 1,
        "AddressType": 1,
        "Method": 2
      },
      {
        "Picture": 1,
        "AddressType": 3,
        "Method": 2
      },
      {
        "Picture": 1,
        "AddressType": 4,
        "Method": 2
      },
      {
        "Picture": 2,
        "AddressType": 1,
        "Method": 2
      },
      {
        "Picture": 2,
        "AddressType": 3,
        "Method": 2
      },
      {
        "Picture": 2,
        "AddressType": 4,
        "Method": 2
      },
      {
        "Picture": 3,
        "AddressType": 1,
        "Method": 2
      },
      {
        "Picture": 3,
        "AddressType": 3,
        "Method": 2
      },
      {
        "Picture": 3,
        "AddressType": 4,
        "Method": 2
      }
    ],
    "Associate": [
      {
        "Picture": 3,
        "AddressType": 1
      },
      {
        "Picture": 3,
        "AddressType": 3
      },
      {
        "Picture": 3,
        "AddressType": 4
      }
    ]
  },
  "Socks": {
    "Address": "127.0.0.1",
    "TcpPort": 1080,
    "UdpPort": 1080
  },
  "Server": {
    "IPv4": "127.0.0.1",
    "Domain": "localhost",
    "IPv6": "::1",
    "ConnectPort": 9999,
    "BindPort": 9000,
    "UdpPort": 9999
  },
  "Picture": {
    "BigPictureHash": "f170d55c41c713edc2282404d2502cf0921f1ea3e78cdfc6839dde0a79c4bb8c",
    "MiddlePictureHash": "87dee88fa63c5fd541bb5b4998b05c24bc76fb9c95b4789a5ddb309eece2b83a",
    "SmallPictureHash": "0f7850cac7e4e82d8c34e54cfaf406f9eebc66d7c8a1dc20f7a854e606d67b07"
  },
  "Misc": {
    "TempDirPath": "/tmp",
    "TempFileNamePattern": "%s/%s.%s.png",
    "RandomSuffixLength": 16
  },
  "User": {
    "Name": "test",
    "Password": "test"
  }
}

Clone this wiki locally