Files
i2pd/tests
Elcoid d1428cd2ae sam: fix inconsistencies in version negotiation of sam handshake
This commit fixes [issue #2570](https://github.com/PurpleI2P/i2pd/issues/2570).

The [specification of the SAM protocol](https://i2p.net/en/docs/api/samv3/)
says the following:
- "As of version 3.1 (I2P 0.9.14), the MIN and MAX parameters are optional."
- "SAM will always return the highest version possible given the MIN and MAX
  constraints"

Given this, the following handshakes do not change:
```
printf "HELLO VERSION MIN=3.1 MAX=3.3\n" | nc -q 0 127.0.0.1 7656
HELLO REPLY RESULT=OK VERSION=3.3

printf "HELLO VERSION MAX=3.3\n" | nc -q 0 127.0.0.1 7656
HELLO REPLY RESULT=OK VERSION=3.3

printf "HELLO VERSION MIN=31 MAX=31\n" | nc -q 0 127.0.0.1 7656
HELLO REPLY RESULT=OK VERSION=3.1
(periods are still optional)
```

But the following ones do (the responses before and after this commit
are included):
```
printf "HELLO VERSION MAX=3.4\n" | nc -q 0 127.0.0.1 7656
before: HELLO REPLY RESULT=NOVERSION
after:  HELLO REPLY RESULT=OK VERSION=3.3

printf "HELLO VERSION MIN=3.0\n" | nc -q 0 127.0.0.1 7656
before: HELLO REPLY RESULT=OK VERSION=3.0
after:  HELLO REPLY RESULT=OK VERSION=3.3

printf "HELLO VERSION MIN=3.1\n" | nc -q 0 127.0.0.1 7656
before: HELLO REPLY RESULT=OK VERSION=3.1
after:  HELLO REPLY RESULT=OK VERSION=3.3

printf "HELLO VERSION MIN=2.9\n" | nc -q 0 127.0.0.1 7656
before: HELLO REPLY RESULT=NOVERSION
after:  HELLO REPLY RESULT=OK VERSION=3.3

printf "HELLO VERSION\n" | nc -q 0 127.0.0.1 7656
before: HELLO REPLY RESULT=NOVERSION
after:  HELLO REPLY RESULT=OK VERSION=3.3

printf "HELLO VERSION MIN=3.3 MAX=3.1\n" | nc -q 0 127.0.0.1 7656
before: HELLO REPLY RESULT=OK VERSION=3.1
after:  HELLO REPLY RESULT=NOVERSION

printf "HELLO VERSION MIN=3.5 MAX=2.7\n" | nc -q 0 127.0.0.1 7656
before: HELLO REPLY RESULT=OK VERSION=2.7
after:  HELLO REPLY RESULT=NOVERSION

printf "HELLO VERSION MIN=2.7 MAX=3.5\n" | nc -q 0 127.0.0.1 7656
before: HELLO REPLY RESULT=NOVERSION
after:  HELLO REPLY RESULT=OK VERSION=3.3

printf "HELLO VERSION MIN=aab3vsg1df MAX=fd3gfbgf1bf\n" | nc -q 0 127.0.0.1 7656
before: HELLO REPLY RESULT=OK VERSION=3.1
after:  HELLO REPLY RESULT=NOVERSION
```

I included a script to automatically test these handshakes.
2026-09-25 10:52:05 -04:00
..
2026-09-23 22:18:12 -04:00
2025-06-02 23:28:51 -03:00
2019-05-31 11:57:16 -04:00