Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong printing of IPv6 addresses #534

Closed
sanderjo opened this issue May 7, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@sanderjo
Copy link
Contributor

commented May 7, 2018

FWIW: nserv prints out a wrong IPv6 address (after a connection timeout): the right two sets ("hextets") are left out, "::" prepended on the left. Example:

Source IPv6 address is
2001:aaaa:ff00:0:11a1:28f5:a775:f979
but nserv prints
::2001:aaaa:ff00:0:11a1:28f5:
So:

  • on the left side, :: prepended
  • on the right side, the two right sets (so: 8 hex digits) are left out.

Listening on IPv6

$ ./nzbget --nserv -d my_content/ -b ::
[INFO] NServ 20.0-testing-r2176 (Test NNTP server)
[INFO] Press Ctrl+C to quit
[INFO] Listening on port 6791
[DETAIL] [1] Received: JJKJLKJKLJLKJL
[WARNING] [1] Unknown command: JJKJLKJKLJLKJL
[ERROR] Could not receive data on socket from ::: ErrNo 11, Resource temporarily unavailable

[DETAIL] [2] Received: BLABLABLA
[WARNING] [2] Unknown command: BLABLABLA
[ERROR] Could not receive data on socket from ::2001:aaaa:ff00:0:11a1:28f5: ErrNo 11, Resource temporarily unavailable

with client connection

$ telnet 2001:aaaa:ff00:0:11a1:28f5:a775:f979 6791
Trying 2001:aaaa:ff00:0:11a1:28f5:a775:f979...
Connected to 2001:aaaa:ff00:0:11a1:28f5:a775:f979.
Escape character is '^]'.
200 Welcome (NServ)
BLABLABLA
500 Unknown command
Connection closed by foreign host.

FWIW: it's daemon/connect/Connection.cpp line 413 that does the printing.

Listening on IPv4 gives the correct IP address

$ ./nzbget --nserv -d my_content/ 
[INFO] NServ 20.0-testing-r2176 (Test NNTP server)
[INFO] Press Ctrl+C to quit
[INFO] Listening on port 6791
[DETAIL] [1] Received: JSJIJIJIJIJIJS
[WARNING] [1] Unknown command: JSJIJIJIJIJIJS
[ERROR] Could not receive data on socket from 127.0.0.1: ErrNo 11, Resource temporarily unavailable
@sanderjo

This comment has been minimized.

Copy link
Contributor Author

commented May 8, 2018

Listening on IPv6 (and iPv4), and connecting to 127.0.0.1, prints ::ffff, which should be ::ffff:127.0.0.1.

Hmmm ... 127.0.0.1 (4 bytes) missing. 8 hex digits are also 4 bytes ... in general / hypothesis: the last 4 bytes are not printed?

$ ./nzbget --nserv -d my_content/ -b ::
[INFO] NServ 20.0-testing-r2176 (Test NNTP server)
[INFO] Press Ctrl+C to quit
[INFO] Listening on port 6791
[DETAIL] [1] Received: AUTHINFO blabla
[ERROR] Could not receive data on socket from ::ffff: ErrNo 11, Resource temporarily unavailable

client:

$ telnet 127.0.0.1 6791
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
200 Welcome (NServ)
AUTHINFO blabla
281 Authentication accepted
Connection closed by foreign host.
@sanderjo

This comment has been minimized.

Copy link
Contributor Author

commented May 8, 2018

Another observation:

Connecting to fe80::d0e6:4f78:4332:44ba gives Could not receive data on socket from 0:0:fe80::d0e6:4f78

So, new hypothesis: 0:0: (or 0000:0000:, so 4 bytes with 0, maybe IPv4's anything 0.0.0.0?) are added on the left side, and the print only prints the first 8 hextets (16 bytes), thus leaving out the 2 hextets (4 bytes) on the right hand side.

And as we know: in an IPv6 address, one sequence of :0000:'s can be replaced with "::", explaining the "::2001:aaaa:ff00:0:11a1:28f5": the 0000:0000: on the left side are replaced with :: .

hugbug added a commit that referenced this issue May 8, 2018

@hugbug hugbug changed the title nserv: wrong printing of IPv6 address: right two sets left out, "::" prepended on the left side Wrong printing of IPv6 addresses May 8, 2018

@hugbug

This comment has been minimized.

Copy link
Member

commented May 8, 2018

I've sent you a fixed version to try.

@sanderjo

This comment has been minimized.

Copy link
Contributor Author

commented May 8, 2018

That works! Thank you!

Tested with git version:

$ ./nzbget --nserv -d my_content/ -b ::
[INFO] NServ 20.0-testing-r2180 (Test NNTP server)
[INFO] Press Ctrl+C to quit
[INFO] Listening on port 6791
[DETAIL] [1] Received: QUIT
[DETAIL] [1] Closing connection
[DETAIL] [2] Received: hello
[WARNING] [2] Unknown command: hello
[ERROR] Could not receive data on socket from ::ffff:127.0.0.1: ErrNo 11, Resource temporarily unavailable
[DETAIL] [3] Received: HELO there
[WARNING] [3] Unknown command: HELO there
[ERROR] Could not receive data on socket from ::1: ErrNo 11, Resource temporarily unavailable
[DETAIL] [4] Received: BLABLABLA
[WARNING] [4] Unknown command: BLABLABLA
[ERROR] Could not receive data on socket from fe80::b642:8c02:3b0:4774: ErrNo 11, Resource temporarily unavailable

and still working for IPv4.

$ ./nzbget --nserv -d my_content/ 
[INFO] NServ 20.0-testing-r2180 (Test NNTP server)
[INFO] Press Ctrl+C to quit
[INFO] Listening on port 6791
[DETAIL] [1] Received: BBBBBBB
[WARNING] [1] Unknown command: BBBBBBB
[ERROR] Could not receive data on socket from 127.0.0.1: ErrNo 11, Resource temporarily unavailable

👍

@hugbug

This comment has been minimized.

Copy link
Member

commented May 8, 2018

Thanks.

@hugbug hugbug closed this May 8, 2018

@hugbug hugbug added the bug label May 8, 2018

@hugbug hugbug added this to the v20 milestone May 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.