Opened 15 years ago

Closed 15 years ago

#800 closed defect (fixed)

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 (1)

comment:1 Changed 15 years ago by bennylp

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

Done in r2656:

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