Skip to content

Commit

Permalink
Merge branch 'eric' of ssh://localhost:2222/srv/git/ssh-hans into eric
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Dec 2, 2015
2 parents 26cc0e4 + 9f85f23 commit 8b0516b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ mkClient creds (h,_,_) = Client { .. }
cGet = S.hGetSome h
cPut = S.hPutStr h . L.toStrict
cClose = hClose h
cLog = putStrLn

cDirectTcp _host _port _events _writeback = return False

Expand Down Expand Up @@ -132,7 +133,6 @@ mkClient creds (h,_,_) = Client { .. }
_ -> return (AuthFailed ["password","publickey"])

cAuthHandler _session_id user _svc m =
do print (user,m)
return (AuthFailed ["password","publickey"])

loadServerKeys :: FilePath -> IO [ServerCredential]
Expand Down
9 changes: 7 additions & 2 deletions src/Network/SSH/Connection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ connectionSend msg = Connection $
do (client, state) <- ask
liftIO (send client state msg)

connectionLog :: String -> Connection ()
connectionLog msg = Connection $
do (client, _) <- ask
liftIO (cLog client msg)

connectionGetChannels :: Connection (Map Word32 SshChannel)
connectionGetChannels = Connection (lift get)

Expand Down Expand Up @@ -113,11 +118,11 @@ connectionService =
connectionService

SshMsgDisconnect reason _desc _lang ->
liftIO (putStrLn ("Disconnect: " ++ show reason))
connectionLog ("Disconnect: " ++ show reason)
-- TODO: tear down channels

_ ->
do liftIO (putStrLn ("Unhandled message: " ++ show msg))
do connectionLog ("Unhandled message: " ++ show msg)
connectionService


Expand Down
8 changes: 7 additions & 1 deletion src/Network/SSH/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Network.SSH.Packet
import Network.SSH.PubKey (PrivateKey)
import Network.SSH.TerminalModes

import Data.Char (isControl)
import Data.IORef
import Data.Word
import Data.Serialize
Expand Down Expand Up @@ -47,6 +48,9 @@ data Client = Client
-- | Close network socket
, cClose :: IO ()

-- | Log messages for events related to this client
, cLog :: String -> IO ()

-- | TERM, initial window dimensions, termios flags, incoming events, write callback
, cOpenShell :: S.ByteString -> SshWindowSize -> [(TerminalFlag, Word32)] ->
Chan SessionEvent ->
Expand Down Expand Up @@ -123,7 +127,9 @@ receive client SshState { .. } = loop
writeIORef sshRecvState (seqNum1, cipher', mac, comp)
case msg of
SshMsgIgnore _ -> loop
SshMsgDebug display m _ | display -> S8.putStrLn m >> loop -- XXX drop controls
SshMsgDebug display m _ | display -> do cLog client (filter (not . isControl)
(S8.unpack m))
loop -- XXX drop controls
| otherwise -> loop
_ -> return msg

Expand Down

0 comments on commit 8b0516b

Please sign in to comment.