diff --git a/src/http.h b/src/http.h index 7f26148..b045205 100644 --- a/src/http.h +++ b/src/http.h @@ -136,6 +136,7 @@ typedef struct http_connection { char *hc_peer_ipstr; struct sockaddr_storage *hc_self; char *hc_representative; + int is_local_address_cache; pthread_mutex_t *hc_paths_mutex; http_path_list_t *hc_paths; diff --git a/src/satip/rtsp.c b/src/satip/rtsp.c index bd8c978..f8cb68c 100644 --- a/src/satip/rtsp.c +++ b/src/satip/rtsp.c @@ -322,14 +322,18 @@ static inline const char * rtsp_conn_ip(http_connection_t *hc, char *buf, size_t buflen, int *port) { const char *used_ip = rtsp_ip; - int used_port = rtsp_port, local; + int used_port = rtsp_port; + int local = hc->is_local_address_cache; struct sockaddr_storage self; if (rtsp_nat_ip[0] == '\0') goto end; self = *hc->hc_self; /* note: call ip_check at first to initialize self (ip any) */ - local = ip_check_is_local_address(hc->hc_peer, hc->hc_self, &self); + if (local < 0) { + hc->is_local_address_cache = ip_check_is_local_address(hc->hc_peer, hc->hc_self, &self); + local = hc->is_local_address_cache; + } if (local || satip_server_conf.satip_nat_name_force) { used_ip = rtsp_nat_ip; if (rtsp_nat_port > 0) @@ -1664,6 +1668,7 @@ rtsp_serve(int fd, void **opaque, struct sockaddr_storage *peer, hc.hc_self = self; hc.hc_process = rtsp_process_request; hc.hc_cseq = 1; + hc.is_local_address_cache = -1; http_serve_requests(&hc);