ssh-tunnel-1.0.0.0: Proxy http-client via ssh tunnel.

Safe HaskellNone
LanguageHaskell2010

Control.SSH.Tunnel

Synopsis

Documentation

data SshTunnelConfig Source #

Configuration of SSH tunnel

Constructors

SshTunnelConfig 

Fields

openSshTunnel Source #

Arguments

:: MonadManaged m 
=> SshTunnelConfig

Configuration of connection

-> ManagerSettings

Your manager settings that would be extended with proxy information

-> m ManagerSettings

Extended client manager settings, tunnel termination action is handled by MonadManaged

Open SSH tunnel and return settings for connection manager

Tunnel is created with: ssh -f -N -M -S master-socket -i pemfile -L localport:127.0.0.1:remoteport userhost @

Note: that the tunnel is created in background (-f) without a shell on remote host (-N) and (-M -S master-socket) defines special socket that is used to terminate the tunnel.

How to use in your code: @ import Control.Monad.Managed import Control.SSH.Tunnel import Network.HTTP.Client import Network.HTTP.Client.TLS

with (openSshTunnel config tlsManagerSettings) $ settings -> do manager <- newManager settings -- do things with manager -- as soon you live the scope, tunnel will be down @

addFingerprints :: MonadIO m => SshTunnelConfig -> FilePath -> m () Source #

Add server fingerprints to given path

data SshTunnel Source #

SSH tunnel ID that can be used to send commands to it

makeSshTunnel Source #

Arguments

:: MonadIO m 
=> SshTunnelConfig

Configuration of connection

-> ManagerSettings

Your manager settings that would be extended with proxy information

-> m (ManagerSettings, SshTunnel)

Extended client manager settings and id that can be used to shut down the tunnel

Make a SSH tunnel, same as openSshTunnel, but handles all Managed monad stuff internally. As soon as SshTunnel value is garbage collected, internal ssh tunnel will be closed. Also you can use closeSshTunnel to manually free resources.

makeSshTunnelSimple :: MonadIO m => SshTunnelConfig -> m SshTunnel Source #

Helper, when you don't need manager in makeSshTunnelSimple

closeSshTunnel :: MonadIO m => SshTunnel -> m () Source #

Closes given ssh tunnel, see makeSshTunnel

saveSshTunnel :: MonadIO m => FilePath -> SshTunnel -> m () Source #

Write down info about tunnel into file to be able to close it from other haskell program.

loadSshTunnel :: MonadIO m => FilePath -> m SshTunnel Source #

Read saved tunnel from file that was written by saveSshTunnel