Add basic PROXY (version 1) debug support

This commit is contained in:
Les De Ridder 2020-11-16 01:11:23 +01:00
parent 5eea8a71f1
commit 8e461051cd
2 changed files with 24 additions and 7 deletions

View File

@ -5,7 +5,7 @@ salty-ircd is an [Internet Relay Chat](https://en.wikipedia.org/wiki/Internet_Re
The main goals of salty-ircd are strict RFC compliance and security.
### RFC compliance
salty-ircd aims to be fully compliant with the IRC RFCs (in 'RFC mode'), specifically [RFC 1459](https://tools.ietf.org/html/rfc1459), [RFC 2811](https://tools.ietf.org/html/rfc2811), [RFC 2812](https://tools.ietf.org/html/rfc2812), and [RFC 2813](https://tools.ietf.org/html/rfc2813) (planned), including all errata.
salty-ircd aims to be fully compliant with the IRC RFCs (by default), specifically [RFC 1459](https://tools.ietf.org/html/rfc1459), [RFC 2811](https://tools.ietf.org/html/rfc2811), [RFC 2812](https://tools.ietf.org/html/rfc2812), and [RFC 2813](https://tools.ietf.org/html/rfc2813) (planned), including all errata.
Newer RFCs take precedence over older RFCs.
Any additional features breaking RFC compliance are available through compile-time options.
@ -25,9 +25,13 @@ Build dependencies:
Build command:
* RFC compliant: `dub build`
* With all additional features: `dub build -c=modern`
* Modern (all additional features): `dub build -c=modern`
TODO: Add a way to supply a custom list of compile-time options.
The 'modern' configuration aims to be mostly compatible with UnrealIRCd user modes/chars.
When `-d=ProxyV1` is added to the build command, salty-ircd can accept traffic through the PROXY protocol (version 1), e.g. from an UnrealIRCd server running with [a custom module](https://github.com/lesderid/unrealircd5_proxyv1_copy). Please see this module's readme for more information. Note that this is simply a development/debugging option and should not be used for a production server.
TODO: Add a method to supply a custom list of compile-time options.
## Running
First, create the configuration file, `config.sdl`. You can find a template in `config.template.sdl`.
@ -35,4 +39,4 @@ First, create the configuration file, `config.sdl`. You can find a template in `
Then, simply run `./out/salty-ircd`.
## License
The source code for salty-ircd is licensed under the [University of Illinois/NCSA Open Source License](LICENSE).
[University of Illinois/NCSA Open Source License](LICENSE).

View File

@ -42,6 +42,9 @@ class Connection
string pass = null;
debug (ProxyV1)
bool proxy;
@property auto channels()
{
return _server.channels.filter!(c => c.members.canFind(this));
@ -183,6 +186,13 @@ class Connection
continue;
}
debug (ProxyV1)
if (message.command == "PROXY")
{
proxy = true;
hostname = getHost(message.parameters[1]);
}
//NOTE: The RFCs don't specify whether commands are case-sensitive
version (BasicFixes)
{
@ -367,7 +377,8 @@ class Connection
user = message.parameters[0];
modes = modeMaskToModes(message.parameters[1]);
realname = message.parameters[3];
hostname = getHost();
debug (ProxyV1) {}
else hostname = getHost();
if (!wasRegistered && registered)
{
@ -1381,9 +1392,11 @@ class Connection
closeConnection();
}
string getHost()
string getHost(string addressString = null)
{
auto address = parseAddress(_connection.remoteAddress.toAddressString);
auto address = parseAddress(addressString != null ?
addressString :
_connection.remoteAddress.toAddressString);
auto hostname = address.toHostNameString;
if (hostname is null)
{