-
-
Notifications
You must be signed in to change notification settings - Fork 201
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
Add dual-stack socket support for FTL #180
Conversation
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Before this pull request:
With the proposed changes:
|
Signed-off-by: DL6ER <[email protected]> Conflicts: socket.c
socket.c
Outdated
@@ -117,7 +151,7 @@ void bind_to_telnet_port(char type, int *socketdescriptor) | |||
exit(EXIT_FAILURE); | |||
} | |||
|
|||
logg("Listening on port %i for incoming connections", port); | |||
logg("Listening on port %i for incoming %s connections", port, dualstack == true ? "IPv4 + IPv6" : "IPv4"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The == true
can be removed since dualstack
is a boolean already.
socket.c
Outdated
if(bind(*socketdescriptor, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) | ||
{ | ||
logg("Error on binding on port %i", port); | ||
} | ||
else | ||
{ | ||
bound = true; | ||
dualstack = true; | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a non-IPv6 system this would produce 20 lines of errors saying it can't bind to a port. Is there a quicker way to figure out if we have IPv6 access?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to detect if the system has a working ipv6
interface. If we cannot find out how to do it, we could also change the error reporting (don't report on the Individual failures, but only once at the end when we couldn't find at least one port).
Signed-off-by: DL6ER <[email protected]>
…accordingly (don't try to bind to a dual-stack port if the machine isn't capable to handling IPv6, e.g. in docker) Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
Marking as While |
… IPv4-only and one for IPv6-only) to be able to bind to the corresponding loopback interfaces. We listen independently, but handle incoming requests using the same code. Signed-off-by: DL6ER <[email protected]>
Completely re-wrote this feature. In case you are interested , here is the result of my research: However, an essential security feature of |
socket.c
Outdated
{ | ||
// Try IPv4 only socket | ||
// see the comments further up for details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is no longer valid
socket.c
Outdated
logg("Reason: %s (%i)", strerror(errno), errno); | ||
if(bind(*socketdescriptor, (struct sockaddr *) &address, sizeof (address)) != 0) | ||
{ | ||
logg("Error on binding on unix socket %s: %s (%i)", FTLfiles.socketfile, strerror(errno), errno); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unix is capitalized elsewhere.
socket.c
Outdated
@@ -335,16 +383,69 @@ void *telnet_listening_thread(void *args) | |||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); | |||
|
|||
// Set thread name | |||
prctl(PR_SET_NAME,"telnet listener",0,0,0); | |||
prctl(PR_SET_NAME,"telnet-v4",0,0,0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use IPv4
to distinguish this from appearing to be telnet version 4 API
.
socket.c
Outdated
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); | ||
|
||
// Set thread name | ||
prctl(PR_SET_NAME,"telnet-v6",0,0,0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
By submitting this pull request, I confirm the following (please check boxes, eg [X]) Failure to fill the template will close your PR:
Please submit all pull requests against the
development
branch. Failure to do so will delay or deny your requestHow familiar are you with the codebase?:
10
This pull request adds full dual-stack support for
FTL
'stelnet
-like socket. Previously, we bound only to an IPv4 port, now we bind to both the IPv4 and IPv6 port spaces.In case no IPv6 interface is available (e.g. in
docker
),FTL
will bind only to the IPv4 port - just as it did before.This template was created based on the work of
udemy-dl
.