mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-03 14:49:08 +00:00
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.