package com.njzscloud.common.sshtunnel;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "ssh-tunnel", name = "enable", havingValue = "true")
@EnableConfigurationProperties({SSHTunnelProperties.class})
public class SSHTunnelAutoConfiguration {

    @Bean(destroyMethod = "close")
    public SSHTunnel sshTunnel(SSHTunnelProperties SSHTunnelProperties) {
        return new SSHTunnel(SSHTunnelProperties);
    }

}
