Skip to content

Commit

Permalink
makefile, many others
Browse files Browse the repository at this point in the history
  • Loading branch information
aryzach committed Dec 4, 2022
1 parent 51dcd9b commit f8bbf35
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ssh:
ssh -i ~/.ssh/awskey.pem -p 2022 [email protected]

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

If I ever get around to using this, I should harden the server w these tips:
https://news.ycombinator.com/item?id=30618577


1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ library:
- socket
- hssh
- parsec
- directory == 1.3.6.0


executables:
Expand Down
11 changes: 11 additions & 0 deletions src/Files.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Files (getFiles) where

import System.Directory

getFilesInDirectory :: FilePath -> IO [FilePath]
getFilesInDirectory dirPath = do
entries <- getDirectoryContents dirPath
let filenames = filter (`notElem` [".", ".."]) entries
return filenames

getFiles = getFilesInDirectory "./files/"
12 changes: 10 additions & 2 deletions src/Parser.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
module Parser where

import Text.Parsec hiding (try)
import Text.Parsec.String
import Text.ParserCombinators.Parsec
import qualified Text.ParserCombinators.Parsec as PC
import Control.Monad (void)

import Files (getFiles)

data Command = Cat String
| Esc
| Ls
Expand Down Expand Up @@ -33,7 +36,7 @@ cat = do
string "cat"
char ' '
whitespace
x <- fileName
x <- matchAnyString getFiles
return $ Cat x

fileName :: Parser String
Expand All @@ -59,3 +62,8 @@ pt p input = parse p "(unknown)" input

whitespace :: Parser ()
whitespace = void $ many $ oneOf " \n\t"

matchAnyString :: [String] -> Parser String
matchAnyString strs = choice $ map (try . string) strs


11 changes: 0 additions & 11 deletions src/TestLib.hs

This file was deleted.

3 changes: 2 additions & 1 deletion sshServer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ source-repository head

library
exposed-modules:
Files
Lib
Parser
TestLib
other-modules:
Paths_sshServer
hs-source-dirs:
Expand All @@ -36,6 +36,7 @@ library
base >=4.7 && <5
, bytestring
, data-default
, directory ==1.3.6.0
, hssh
, memory
, network
Expand Down

0 comments on commit f8bbf35

Please sign in to comment.