Skip to content

Commit 43f5f9d

Browse files
committed
Enable SSL from the game-server bot.
Debugging #1382
1 parent ced0ad5 commit 43f5f9d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

codeworld-game-server/codeworld-game-server.cabal

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Executable codeworld-game-bot
4949
bytestring,
5050
text,
5151
websockets >= 0.12.3.0,
52+
wuss,
5253
codeworld-game-api,
5354
codeworld-api,
5455
async,

codeworld-game-server/src/Bot.hs

+20-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,24 @@ import Options.Applicative
3333
import System.Clock
3434
import Text.Read
3535
import Text.Regex
36+
import qualified Wuss as Wuss
3637

3738
connect :: Config -> WS.ClientApp a -> IO a
38-
connect (Config {..}) = WS.runClient hostname port path
39+
connect (Config {..})
40+
| secure =
41+
Wuss.runSecureClientWith
42+
hostname
43+
(fromIntegral port)
44+
path
45+
WS.defaultConnectionOptions
46+
[("Host", BS.pack hostname)]
47+
| otherwise =
48+
WS.runClientWith
49+
hostname
50+
port
51+
path
52+
WS.defaultConnectionOptions
53+
[("Host", BS.pack hostname)]
3954

4055
type Timestamp = Double
4156

@@ -132,6 +147,7 @@ timeSpecToS ts = fromIntegral (sec ts) + fromIntegral (nsec ts) * 1E-9
132147
data Config = Config
133148
{ clients :: Int,
134149
invert :: Bool,
150+
secure :: Bool,
135151
delay :: Maybe Double,
136152
hostname :: String,
137153
port :: Int,
@@ -159,6 +175,8 @@ opts =
159175
)
160176
<*> switch
161177
(long "invert" <> showDefault <> help "Return opposite direction")
178+
<*> switch
179+
(long "secure" <> short 's' <> help "Use a secure connection")
162180
<*> optional
163181
( option
164182
auto
@@ -178,7 +196,7 @@ opts =
178196
<> help "Port"
179197
)
180198
<*> strOption
181-
( long "path" <> showDefault <> metavar "PATH" <> value "gameserver"
199+
( long "path" <> showDefault <> metavar "PATH" <> value "/gameserver"
182200
<> help "Path"
183201
)
184202
<*> optional

0 commit comments

Comments
 (0)