Skip to content

Bugfix/ipv6 handling#216

Closed
metelik wants to merge 6 commits intotravelping:masterfrom
se-apc:bugfix/ipv6_handling
Closed

Bugfix/ipv6 handling#216
metelik wants to merge 6 commits intotravelping:masterfrom
se-apc:bugfix/ipv6_handling

Conversation

@metelik
Copy link
Copy Markdown

@metelik metelik commented Oct 4, 2021

Changes:

  • Fixing IPv6 parse function - IPv6 address is a tuple of 8 hextets (not 6)
  • Adding AAAA class host-name resolution (:inet6)
  • Adding switch between :inet and :inet6 address families for UDP client's socket opening based on the server's address

metelik and others added 2 commits June 3, 2021 12:15
Merging from the upstream
…inet or :inet6 based on peer's socket address to the client's socket
@metelik metelik requested a review from a team as a code owner October 4, 2021 07:36
Copy link
Copy Markdown
Contributor

@vkatsuba vkatsuba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Thanks for your contribution! Please run GitHub Actions manually in your fork and provide here the link to success CI.
How to:

Open https://github.com/se-apc/eradius
Select tab Actions - https://github.com/se-apc/eradius/actions
Select tab CI
Find button Run workflow
Select in Run workflow branch master and click Run workflow

Copy link
Copy Markdown
Contributor

@vkatsuba vkatsuba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep one code style - use 4 spaces instead of 2.

Copy link
Copy Markdown
Contributor

@vkatsuba vkatsuba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can, please provide test cases.

Copy link
Copy Markdown
Member

@RoadRunnr RoadRunnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You PR contains a merge commit. Please make sure that you only include your changes in the PR and that the history is linear.

Comment thread src/eradius_client.erl
-spec send_request(nas_address(), #radius_request{}, options()) ->
{ok, binary(), eradius_lib:authenticator()} | {error, 'timeout' | 'socket_down'}.
send_request({Host, Port, Secret}, Request, Options)
send_request({Host, Port, Secret}, Request, Options)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, don't mix pure formatting and white space changes with functional changes.

If you think the whitespace problems need fixing, create a separate pull request for that.

@metelik
Copy link
Copy Markdown
Author

metelik commented Oct 4, 2021

If you can, please provide test cases.

Sure thing. I shall need to revisit some tests that have already been present due to the APIs changes. The functionality itself I had tested manually. I am not an Erlang major (not main main programming language) so perhaps a joint effort in the expansion of the available test suite would be well appreciated.

I amended the eradius_client_SUITE to match the change to the eradius_client_socket APIs' change

@metelik
Copy link
Copy Markdown
Author

metelik commented Oct 4, 2021

You PR contains a merge commit. Please make sure that you only include your changes in the PR and that the history is linear.

QQ on this one. I shall have been probably merging the current master branch into our fork in any way so another merge commit shall appear. Would the commits' squashing into one do? I am asking because such a synchronisation with the upstream master can be advantageous on many levels. OOC what would be the reasons behind your disliking that?

Tomasz Kazimierz Motyl and others added 3 commits October 4, 2021 03:47
Amending the test suite to fit the change to the eradius_client_socket,start/3 to start/4  API
@metelik metelik requested review from RoadRunnr and vkatsuba October 7, 2021 22:39
Comment thread src/eradius_client.erl
end.

%% @private
inet_family_based_on_peer(_PeerSocket = {{_, _, _, _}, _port}) ->
Copy link
Copy Markdown
Member

@0xAX 0xAX Oct 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only inet_family_based_on_peer/1 is called everywhere. So the:

inet_family_based_on_peer(_PeerSocket) ->
    [].

should be removed at all and inet_family_based_on_peer/2 should be reworked to inet_family_based_on_peer/1 like:

inet_family_based_on_peer({_, _, _, _}) ->
    [inet];
inet_family_based_on_peer({_, _, _, _, _, _, _, _}) ->
    [inet6].

That should be safe to do as inet_family_based_on_peer/1 will be called with proper IP address all the time.

Comment thread src/eradius_client.erl
IP = lists:nth(Index, IPs),
send_request({IP, Port, Secret}, Request, Options);
_ -> error(badarg)
_Err ->
Copy link
Copy Markdown
Member

@0xAX 0xAX Oct 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified a bit. The whole send_request function may look like this:

send_request({Host, Port, Secret}, Request, Options)
  when ?GOOD_CMD(Request) andalso is_list(Host) ->
    case gethostbyname(Host) of
        {ok, #hostent{h_addr_list = [IP]}} ->
            send_request({IP, Port, Secret}, Request, Options);
        {ok, #hostent{h_addr_list = [_ | _] = IPs}} ->
            Index = rand:uniform(length(IPs)),
            IP = lists:nth(Index, IPs),
            send_request({IP, Port, Secret}, Request, Options);
        _Err -> error(badarg)
     end
   end;

gethostbyname(Host) ->
  case inet:gеthostbyname(Host, inet6) do
    {error, _} ->
      inet:gethostbyname(Host, inet);
    Hostent ->
      Hostent
end.

@0xAX
Copy link
Copy Markdown
Member

0xAX commented Oct 14, 2021

Hello @metelik. First of all thanks for PR. I've leaved some comments to simpilfy a couple of places. Could you please adjust the PR.

@metelik
Copy link
Copy Markdown
Author

metelik commented Oct 16, 2021

Hello @metelik. First of all thanks for PR. I've leaved some comments to simpilfy a couple of places. Could you please adjust the PR.

Sure thing @0xAX . I shall have been looking into it. I am occupied with another project (for which I am being paid for), hence resolving all the requested changes may drag tiny bit :/

@vkatsuba
Copy link
Copy Markdown
Contributor

Sure thing @0xAX . I shall have been looking into it. I am occupied with another project (for which I am being paid for), hence resolving all the requested changes may drag tiny bit :/

@metelik if you don't have a lot of time to update it, we can do it in our side with saving git commits history with your changes. What do you think about it?

@metelik
Copy link
Copy Markdown
Author

metelik commented Oct 17, 2021

Sure thing @0xAX . I shall have been looking into it. I am occupied with another project (for which I am being paid for), hence resolving all the requested changes may drag tiny bit :/

@metelik if you don't have a lot of time to update it, we can do it in our side with saving git commits history with your changes. What do you think about it?
@vkatsuba Sounds like a bargain to me as I really have been swamped. Needless to say that I find the fixes extremely beneficial to the open-source family. A bit of the heads up: at some point in the future we plan to extend the RADIUS implementation with EAP-TTLS client.

@vkatsuba
Copy link
Copy Markdown
Contributor

Moved to #234

@vkatsuba vkatsuba closed this Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants