You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

  1. From c00347899e9f0c3420f98c53eab1469644e28e06 Mon Sep 17 00:00:00 2001
  2. From: Nenad Merdanovic <nmerdan@haproxy.com>
  3. Date: Sun, 23 Jul 2017 22:04:58 -0400
  4. Subject: [PATCH 16/18] BUG/MINOR: lua: Fix Server.get_addr() port values
  5. The get_addr() method of the Lua Server class was using the
  6. 'sockaddr_storage addr' member to get the port value. HAProxy does not
  7. store ports in this member as it uses a separate member, called
  8. 'svc_port'.
  9. This fix should be backported to 1.7.
  10. (cherry picked from commit 3849473828f319829aff422d2fbbce0823e65d64)
  11. Signed-off-by: William Lallemand <wlallemand@haproxy.org>
  12. ---
  13. src/hlua_fcn.c | 6 ++----
  14. 1 file changed, 2 insertions(+), 4 deletions(-)
  15. diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c
  16. index fe899a4a..0752220e 100644
  17. --- a/src/hlua_fcn.c
  18. +++ b/src/hlua_fcn.c
  19. @@ -545,8 +545,7 @@ int hlua_server_get_addr(lua_State *L)
  20. addr, INET_ADDRSTRLEN);
  21. luaL_addstring(&b, addr);
  22. luaL_addstring(&b, ":");
  23. - snprintf(addr, INET_ADDRSTRLEN, "%d",
  24. - ntohs(((struct sockaddr_in *)&srv->addr)->sin_port));
  25. + snprintf(addr, INET_ADDRSTRLEN, "%d", srv->svc_port);
  26. luaL_addstring(&b, addr);
  27. break;
  28. case AF_INET6:
  29. @@ -554,8 +553,7 @@ int hlua_server_get_addr(lua_State *L)
  30. addr, INET_ADDRSTRLEN);
  31. luaL_addstring(&b, addr);
  32. luaL_addstring(&b, ":");
  33. - snprintf(addr, INET_ADDRSTRLEN, "%d",
  34. - ntohs(((struct sockaddr_in6 *)&srv->addr)->sin6_port));
  35. + snprintf(addr, INET_ADDRSTRLEN, "%d", srv->svc_port);
  36. luaL_addstring(&b, addr);
  37. break;
  38. case AF_UNIX:
  39. --
  40. 2.13.0