@@ -59,15 +59,15 @@ pub struct ProxyServer {
5959 attested_tls_server : AttestedTlsServer ,
6060 /// The underlying TCP listener
6161 listener : Arc < TcpListener > ,
62- /// The address of the target service we are proxying to
63- target : SocketAddr ,
62+ /// The address/hostname of the target service we are proxying to
63+ target : String ,
6464}
6565
6666impl ProxyServer {
6767 pub async fn new (
6868 cert_and_key : TlsCertAndKey ,
6969 local : impl ToSocketAddrs ,
70- target : SocketAddr ,
70+ target : String ,
7171 attestation_generator : AttestationGenerator ,
7272 attestation_verifier : AttestationVerifier ,
7373 client_auth : bool ,
@@ -97,7 +97,7 @@ impl ProxyServer {
9797 cert_chain : Vec < CertificateDer < ' static > > ,
9898 server_config : Arc < ServerConfig > ,
9999 local : impl ToSocketAddrs ,
100- target : SocketAddr ,
100+ target : String ,
101101 attestation_generator : AttestationGenerator ,
102102 attestation_verifier : AttestationVerifier ,
103103 ) -> Result < Self , ProxyError > {
@@ -120,7 +120,7 @@ impl ProxyServer {
120120
121121 /// Accept an incoming connection and handle it in a seperate task
122122 pub async fn accept ( & self ) -> Result < ( ) , ProxyError > {
123- let target = self . target ;
123+ let target = self . target . clone ( ) ;
124124 let ( inbound, _client_addr) = self . listener . accept ( ) . await ?;
125125 let attested_tls_server = self . attested_tls_server . clone ( ) ;
126126
@@ -153,7 +153,7 @@ impl ProxyServer {
153153 tls_stream : tokio_rustls:: server:: TlsStream < tokio:: net:: TcpStream > ,
154154 measurements : Option < MultiMeasurements > ,
155155 remote_attestation_type : AttestationType ,
156- target : SocketAddr ,
156+ target : String ,
157157 ) -> Result < ( ) , ProxyError > {
158158 tracing:: debug!( "proxy-server accepted connection" ) ;
159159
@@ -183,6 +183,7 @@ impl ProxyServer {
183183 . expect ( "Attestation type should be able to be encoded as a header value" ) ,
184184 ) ;
185185
186+ let target = target. clone ( ) ;
186187 async move {
187188 match Self :: handle_http_request ( req, target) . await {
188189 Ok ( res) => {
@@ -208,7 +209,7 @@ impl ProxyServer {
208209 // Handle a request from the proxy client to the target server
209210 async fn handle_http_request (
210211 req : hyper:: Request < hyper:: body:: Incoming > ,
211- target : SocketAddr ,
212+ target : String ,
212213 ) -> Result < Response < BoxBody < bytes:: Bytes , hyper:: Error > > , ProxyError > {
213214 // Connect to the target server
214215 let outbound = TcpStream :: connect ( target) . await ?;
@@ -595,7 +596,7 @@ mod tests {
595596 cert_chain,
596597 server_config,
597598 "127.0.0.1:0" ,
598- target_addr,
599+ target_addr. to_string ( ) ,
599600 AttestationGenerator :: new_not_dummy ( AttestationType :: DcapTdx ) . unwrap ( ) ,
600601 AttestationVerifier :: expect_none ( ) ,
601602 )
@@ -672,7 +673,7 @@ mod tests {
672673 server_cert_chain,
673674 server_tls_server_config,
674675 "127.0.0.1:0" ,
675- target_addr,
676+ target_addr. to_string ( ) ,
676677 AttestationGenerator :: with_no_attestation ( ) ,
677678 AttestationVerifier :: mock ( ) ,
678679 )
@@ -743,7 +744,7 @@ mod tests {
743744 server_cert_chain,
744745 server_config,
745746 "127.0.0.1:0" ,
746- target_addr,
747+ target_addr. to_string ( ) ,
747748 AttestationGenerator :: with_no_attestation ( ) ,
748749 AttestationVerifier :: mock ( ) ,
749750 )
@@ -824,7 +825,7 @@ mod tests {
824825 server_cert_chain,
825826 server_tls_server_config,
826827 "127.0.0.1:0" ,
827- target_addr,
828+ target_addr. to_string ( ) ,
828829 AttestationGenerator :: new_not_dummy ( AttestationType :: DcapTdx ) . unwrap ( ) ,
829830 AttestationVerifier :: mock ( ) ,
830831 )
@@ -923,7 +924,7 @@ mod tests {
923924 cert_chain. clone ( ) ,
924925 server_config,
925926 "127.0.0.1:0" ,
926- target_addr,
927+ target_addr. to_string ( ) ,
927928 AttestationGenerator :: new_not_dummy ( AttestationType :: DcapTdx ) . unwrap ( ) ,
928929 AttestationVerifier :: expect_none ( ) ,
929930 )
@@ -960,7 +961,7 @@ mod tests {
960961 cert_chain,
961962 server_config,
962963 "127.0.0.1:0" ,
963- target_addr,
964+ target_addr. to_string ( ) ,
964965 AttestationGenerator :: with_no_attestation ( ) ,
965966 AttestationVerifier :: expect_none ( ) ,
966967 )
@@ -1004,7 +1005,7 @@ mod tests {
10041005 cert_chain,
10051006 server_config,
10061007 "127.0.0.1:0" ,
1007- target_addr,
1008+ target_addr. to_string ( ) ,
10081009 AttestationGenerator :: new_not_dummy ( AttestationType :: DcapTdx ) . unwrap ( ) ,
10091010 AttestationVerifier :: expect_none ( ) ,
10101011 )
0 commit comments