1- use std:: sync:: Arc ;
2-
31use super :: { server:: SipServerRef , user:: SipUser , ProxyAction , ProxyModule } ;
42use crate :: config:: ProxyConfig ;
53use crate :: proxy:: server:: TransactionCookie ;
@@ -15,6 +13,7 @@ use rsip::typed::Authorization;
1513use rsip:: Header ;
1614use rsip:: Uri ;
1715use rsipstack:: transaction:: transaction:: Transaction ;
16+ use std:: sync:: Arc ;
1817use tokio_util:: sync:: CancellationToken ;
1918use tracing:: { debug, info} ;
2019
@@ -189,18 +188,8 @@ impl ProxyModule for AuthModule {
189188 _cookie. set_user ( user) ;
190189 Ok ( ProxyAction :: Continue )
191190 } else {
192- // Extract realm from request
193- let from = if tx. original . method == rsip:: Method :: Register {
194- tx. original . to_header ( ) ?. uri ( ) ?. to_string ( )
195- } else {
196- tx. original . uri . to_string ( )
197- } ;
198-
199- let realm = if tx. original . method == rsip:: Method :: Register {
200- tx. original . to_header ( ) ?. uri ( ) ?. host ( ) . to_string ( )
201- } else {
202- tx. original . uri . host ( ) . to_string ( )
203- } ;
191+ let from_uri = tx. original . from_header ( ) ?. uri ( ) ?;
192+ let realm = from_uri. host ( ) . to_string ( ) ;
204193 let realm = ProxyConfig :: normalize_realm ( & realm) ;
205194 // Check which type of authentication was attempted or send both challenges
206195 let has_proxy_auth_header =
@@ -210,7 +199,8 @@ impl ProxyModule for AuthModule {
210199 // Send proxy challenge if proxy auth was attempted
211200 let proxy_auth = self . create_proxy_auth_challenge ( & realm) ?;
212201 info ! (
213- from,
202+ from = from_uri. to_string( ) ,
203+ realm = realm,
214204 ?proxy_auth,
215205 "Proxy authentication failed, sending proxy challenge"
216206 ) ;
@@ -222,7 +212,8 @@ impl ProxyModule for AuthModule {
222212 // Send WWW challenge if WWW auth was attempted
223213 let www_auth = self . create_www_auth_challenge ( & realm) ?;
224214 info ! (
225- from,
215+ from = from_uri. to_string( ) ,
216+ realm = realm,
226217 ?www_auth,
227218 "WWW authentication failed, sending WWW challenge"
228219 ) ;
0 commit comments