fix listers

This commit is contained in:
Jun Kurihara 2022-07-07 17:42:20 +09:00
commit 5731ba908b
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
3 changed files with 14 additions and 18 deletions

View file

@ -45,12 +45,17 @@ pub fn parse_opts(globals: &mut Globals, backends: &mut Backends) -> Result<()>
}, },
anyhow!("Wrong port spec.") anyhow!("Wrong port spec.")
); );
let mut listen_addresses: Vec<&str> = LISTEN_ADDRESSES_V4.to_vec(); // NOTE: when [::]:xx is bound, both v4 and v6 listeners are enabled.
if let Some(v) = config.listen_ipv6 { let listen_addresses: Vec<&str> = match config.listen_ipv6 {
if v { Some(true) => {
listen_addresses.extend(LISTEN_ADDRESSES_V6.iter()); info!("Listen both IPv4 and IPv6");
LISTEN_ADDRESSES_V6.to_vec()
} }
} Some(false) | None => {
info!("Listen IPv4");
LISTEN_ADDRESSES_V4.to_vec()
}
};
globals.listen_sockets = listen_addresses globals.listen_sockets = listen_addresses
.iter() .iter()
.flat_map(|x| { .flat_map(|x| {

View file

@ -99,10 +99,7 @@ where
let listener_service = async { let listener_service = async {
// let tcp_listener = TcpListener::bind(&self.listening_on).await?; // let tcp_listener = TcpListener::bind(&self.listening_on).await?;
let tcp_listener = self.try_bind_tcp_listener().await?; let tcp_listener = self.try_bind_tcp_listener().await?;
info!( info!("Start TCP proxy serving with HTTP request for configured host names");
"Start TCP proxy serving with HTTP request for configured host names: {:?}",
tcp_listener.local_addr()?
);
while let Ok((stream, _client_addr)) = tcp_listener.accept().await { while let Ok((stream, _client_addr)) = tcp_listener.accept().await {
self self
.clone() .clone()

View file

@ -12,7 +12,7 @@ where
T: Connect + Clone + Sync + Send + 'static, T: Connect + Clone + Sync + Send + 'static,
{ {
pub async fn cert_service(&self) { pub async fn cert_service(&self) {
info!("Start cert watch service for {}", self.listening_on); info!("Start cert watch service");
loop { loop {
for (server_name, backend) in self.backends.apps.iter() { for (server_name, backend) in self.backends.apps.iter() {
if backend.tls_cert_key_path.is_some() && backend.tls_cert_path.is_some() { if backend.tls_cert_key_path.is_some() && backend.tls_cert_path.is_some() {
@ -29,10 +29,7 @@ where
pub async fn listener_service(&self, server: Http<LocalExecutor>) -> Result<()> { pub async fn listener_service(&self, server: Http<LocalExecutor>) -> Result<()> {
// let tcp_listener = TcpListener::bind(&self.listening_on).await?; // let tcp_listener = TcpListener::bind(&self.listening_on).await?;
let tcp_listener = self.try_bind_tcp_listener().await?; let tcp_listener = self.try_bind_tcp_listener().await?;
info!( info!("Start TCP proxy serving with HTTPS request for configured host names");
"Start TCP proxy serving with HTTPS request for configured host names: {:?}",
tcp_listener.local_addr()?
);
loop { loop {
select! { select! {
@ -102,10 +99,7 @@ where
let (endpoint, incoming) = self.try_bind_quic_listener(server_config_h3).await?; let (endpoint, incoming) = self.try_bind_quic_listener(server_config_h3).await?;
// quinn::Endpoint::server(server_config_h3, self.listening_on).unwrap(); // quinn::Endpoint::server(server_config_h3, self.listening_on).unwrap();
info!( info!("Start UDP proxy serving with HTTP/3 request for configured host names");
"Start UDP proxy serving with HTTP/3 request for configured host names: {:?}",
endpoint.local_addr()?
);
let mut p = incoming.peekable(); let mut p = incoming.peekable();
loop { loop {