From ff6237a38269281dc7fc55c33f49b67c167ea491 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 11 Nov 2022 01:24:51 +0800 Subject: [PATCH] priv_fix --- pjproject-2.11.1/pjlib/src/pj/sock_common.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pjproject-2.11.1/pjlib/src/pj/sock_common.c b/pjproject-2.11.1/pjlib/src/pj/sock_common.c index 96cd6b5..e1e9606 100644 --- a/pjproject-2.11.1/pjlib/src/pj/sock_common.c +++ b/pjproject-2.11.1/pjlib/src/pj/sock_common.c @@ -733,6 +733,27 @@ PJ_DEF(pj_status_t) pj_sockaddr_parse( int af, unsigned options, /* Resolve the IP address of local machine */ PJ_DEF(pj_status_t) pj_gethostip(int af, pj_sockaddr *addr) +{ + char *bind = NULL; + if (af == PJ_AF_INET) { + bind = getenv("PJSIP_BIND4"); + } + else if (af == PJ_AF_INET6) { + bind = getenv("PJSIP_BIND6"); + } + if (bind) { + pj_str_t pjbind = pj_str(bind); + pj_sockaddr dst_addr; + pj_status_t status = pj_sockaddr_init(af, &dst_addr, &pjbind, 0); + if (status == PJ_SUCCESS) { + pj_sockaddr_cp(addr, &dst_addr); + printf("---------- af:%d, bind:%s, PJ_SUCCESS:%d\n", af, bind, status); + return status; + } + } + return _pj_gethostip(af, addr); +} +pj_status_t _pj_gethostip(int af, pj_sockaddr *addr) { unsigned i, count, cand_cnt; enum {