Ticket #800 (closed defect: fixed)

Opened 10 years ago

Last modified 10 years ago

Change in IP address selection algorithm (the pj_gethostip() function)

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-1.2
Component: pjlib Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported:


Currently the pj_gethostip() function gets the IP address from the following algorithm:

  1. get the IP of the hostname
  2. if IP is not usable, get the default interface
  3. if failed, get the first interface
  4. if failed, return loopback address

Note: failed or not-usable means the query failed or the returned IP address is loopback IP or other non-usable IP.

One of the problem with above approach is sometimes a "good" IP address is returned from the step 1, but the IP is not usable (for example, the interface is down).

A better solution perhaps is to list all the addresses above, give them some weight, and return the one with the "best" value.

Change History

comment:1 Changed 10 years ago by bennylp

  • Status changed from new to closed
  • Resolution set to fixed

Done in r2656:

  • use the weighting mechanism to select the "best" IP to return
Note: See TracTickets for help on using tickets.