From 1e69822bac15f0a3eb4084fb56beb1bb6d7decd8 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 30 May 2011 15:29:43 +0200 Subject: Peer/sockname resolv doesn't work with IPv6 addrs in HTTP. OTP-9343 --- lib/inets/doc/src/notes.xml | 41 ++++++++++++++++++++ lib/inets/src/http_lib/http_transport.erl | 64 ++++++++++++++++--------------- lib/inets/src/inets_app/inets.appup.src | 10 +++++ lib/inets/vsn.mk | 2 +- 4 files changed, 86 insertions(+), 31 deletions(-) diff --git a/lib/inets/doc/src/notes.xml b/lib/inets/doc/src/notes.xml index 0926df8581..0d531affa0 100644 --- a/lib/inets/doc/src/notes.xml +++ b/lib/inets/doc/src/notes.xml @@ -32,6 +32,47 @@ notes.xml +
Inets 5.6.1 + +
Improvements and New Features +

-

+ + + +
+ +
Fixed Bugs and Malfunctions + + + + +

[httpd] Peer/sockname resolv doesn't work with IPv6 addrs + in HTTP.

+

Attila Rajmund Nohl.

+

Own Id: OTP-9343

+
+ +
+
+ +
+ +
Inets 5.6
Improvements and New Features diff --git a/lib/inets/src/http_lib/http_transport.erl b/lib/inets/src/http_lib/http_transport.erl index 01b51d531a..6c2ffc143d 100644 --- a/lib/inets/src/http_lib/http_transport.erl +++ b/lib/inets/src/http_lib/http_transport.erl @@ -500,19 +500,11 @@ close({essl, _}, Socket) -> %%------------------------------------------------------------------------- peername(ip_comm, Socket) -> case inet:peername(Socket) of - {ok,{{A, B, C, D}, Port}} -> - PeerName = integer_to_list(A)++"."++integer_to_list(B)++"."++ - integer_to_list(C)++"."++integer_to_list(D), + {ok, {Addr, Port}} when is_tuple(Addr) andalso (size(Addr) =:= 4) -> + PeerName = ipv4_name(Addr), {Port, PeerName}; - {ok,{{A, B, C, D, E, F, G, H}, Port}} -> - PeerName = http_util:integer_to_hexlist(A) ++ ":"++ - http_util:integer_to_hexlist(B) ++ ":" ++ - http_util:integer_to_hexlist(C) ++ ":" ++ - http_util:integer_to_hexlist(D) ++ ":" ++ - http_util:integer_to_hexlist(E) ++ ":" ++ - http_util:integer_to_hexlist(F) ++ ":" ++ - http_util:integer_to_hexlist(G) ++":"++ - http_util:integer_to_hexlist(H), + {ok, {Addr, Port}} when is_tuple(Addr) andalso (size(Addr) =:= 8) -> + PeerName = ipv6_name(Addr), {Port, PeerName}; {error, _} -> {-1, "unknown"} @@ -530,9 +522,11 @@ peername({essl, _}, Socket) -> peername_ssl(Socket) -> case ssl:peername(Socket) of - {ok,{{A, B, C, D}, Port}} -> - PeerName = integer_to_list(A)++"."++integer_to_list(B)++"."++ - integer_to_list(C)++"."++integer_to_list(D), + {ok, {Addr, Port}} when is_tuple(Addr) andalso (size(Addr) =:= 4) -> + PeerName = ipv4_name(Addr), + {Port, PeerName}; + {ok, {Addr, Port}} when is_tuple(Addr) andalso (size(Addr) =:= 8) -> + PeerName = ipv6_name(Addr), {Port, PeerName}; {error, _} -> {-1, "unknown"} @@ -551,19 +545,11 @@ peername_ssl(Socket) -> %%------------------------------------------------------------------------- sockname(ip_comm, Socket) -> case inet:sockname(Socket) of - {ok,{{A, B, C, D}, Port}} -> - SockName = integer_to_list(A)++"."++integer_to_list(B)++"."++ - integer_to_list(C)++"."++integer_to_list(D), + {ok, {Addr, Port}} -> + SockName = ipv4_name(Addr), {Port, SockName}; - {ok,{{A, B, C, D, E, F, G, H}, Port}} -> - SockName = http_util:integer_to_hexlist(A) ++ ":"++ - http_util:integer_to_hexlist(B) ++ ":" ++ - http_util:integer_to_hexlist(C) ++ ":" ++ - http_util:integer_to_hexlist(D) ++ ":" ++ - http_util:integer_to_hexlist(E) ++ ":" ++ - http_util:integer_to_hexlist(F) ++ ":" ++ - http_util:integer_to_hexlist(G) ++":"++ - http_util:integer_to_hexlist(H), + {ok, {Addr, Port}} -> + SockName = ipv6_name(Addr), {Port, SockName}; {error, _} -> {-1, "unknown"} @@ -581,9 +567,11 @@ sockname({essl, _}, Socket) -> sockname_ssl(Socket) -> case ssl:sockname(Socket) of - {ok,{{A, B, C, D}, Port}} -> - SockName = integer_to_list(A)++"."++integer_to_list(B)++"."++ - integer_to_list(C)++"."++integer_to_list(D), + {ok, {Addr, Port}} -> + SockName = ipv4_name(Addr), + {Port, SockName}; + {ok, {Addr, Port}} -> + SockName = ipv6_name(Addr), {Port, SockName}; {error, _} -> {-1, "unknown"} @@ -605,6 +593,22 @@ resolve() -> %%% Internal functions %%%======================================================================== +ipv4_name({A, B, C, D}) -> + integer_to_list(A) ++ "." ++ + integer_to_list(B) ++ "." ++ + integer_to_list(C) ++ "." ++ + integer_to_list(D). + +ipv6_name({A, B, C, D, E, F, G, H}) -> + http_util:integer_to_hexlist(B) ++ ":" ++ + http_util:integer_to_hexlist(C) ++ ":" ++ + http_util:integer_to_hexlist(D) ++ ":" ++ + http_util:integer_to_hexlist(E) ++ ":" ++ + http_util:integer_to_hexlist(F) ++ ":" ++ + http_util:integer_to_hexlist(G) ++ ":" ++ + http_util:integer_to_hexlist(H). + + %% Address any comes from directive: BindAddress "*" sock_opt(ip_comm, any = Addr, Opts) -> sock_opt2([{ip, Addr} | Opts]); diff --git a/lib/inets/src/inets_app/inets.appup.src b/lib/inets/src/inets_app/inets.appup.src index 47f3fbba58..c432ac82eb 100644 --- a/lib/inets/src/inets_app/inets.appup.src +++ b/lib/inets/src/inets_app/inets.appup.src @@ -18,6 +18,11 @@ {"%VSN%", [ + {"5.6", + [ + {load_module, http_transport, soft_purge, soft_purge, []} + ] + }, {"5.5.2", [ {restart_application, inets} @@ -40,6 +45,11 @@ } ], [ + {"5.6", + [ + {load_module, http_transport, soft_purge, soft_purge, []} + ] + }, {"5.5.2", [ {restart_application, inets} diff --git a/lib/inets/vsn.mk b/lib/inets/vsn.mk index c0e25a30e3..2bb4d83c49 100644 --- a/lib/inets/vsn.mk +++ b/lib/inets/vsn.mk @@ -18,7 +18,7 @@ # %CopyrightEnd% APPLICATION = inets -INETS_VSN = 5.6 +INETS_VSN = 5.6.1 PRE_VSN = APP_VSN = "$(APPLICATION)-$(INETS_VSN)$(PRE_VSN)" -- cgit v1.2.3 From 4384c7137cb016b8b3cb9dd4d8ee82870c08f98c Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 15 Jun 2011 11:41:18 +0200 Subject: Set proper version (5.7). --- lib/inets/doc/src/notes.xml | 4 ++-- lib/inets/vsn.mk | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/inets/doc/src/notes.xml b/lib/inets/doc/src/notes.xml index 0d531affa0..9071a72266 100644 --- a/lib/inets/doc/src/notes.xml +++ b/lib/inets/doc/src/notes.xml @@ -32,7 +32,7 @@ notes.xml -
Inets 5.6.1 +
Inets 5.7
Improvements and New Features

-

@@ -70,7 +70,7 @@
-
+
Inets 5.6 diff --git a/lib/inets/vsn.mk b/lib/inets/vsn.mk index 2bb4d83c49..4abc1733d3 100644 --- a/lib/inets/vsn.mk +++ b/lib/inets/vsn.mk @@ -18,7 +18,7 @@ # %CopyrightEnd% APPLICATION = inets -INETS_VSN = 5.6.1 +INETS_VSN = 5.7 PRE_VSN = APP_VSN = "$(APPLICATION)-$(INETS_VSN)$(PRE_VSN)" -- cgit v1.2.3