Haskell袜子客户要求

问题描述

我正在编写一个客户端,该客户端从我的浏览器通过SOCKS5侦听请求。然后连接到目标服务器并通过客户端执行http操作,然后将结果发送回去。

但是我不知道如何执行HTTP(S)请求。

我正在使用Network.Simple.TCP

serverb :: IO ()
serverb =
  serve (Host "127.0.0.1") "8000" $ \(connectionSocket,remoteAddr) -> do
    x <- recv connectionSocket 64
    print (B.unpack <$> x)
    send connectionSocket (B.pack [0x05,0x00])
    t <- recv connectionSocket 1024
    print t
    case t of
      Nothing -> return ()
      Just t' -> do
        let (tAddr,tPort) = getADDR ((B.unpack t') !! 3) t'
        send connectionSocket (B.pack [0x05,0x00,0x01,0x00])
        print tAddr
        h <- recv connectionSocket 1024
        print h
        -- don't know how to do the rest
    putStrLn $ "TCP connection established from " ++ show remoteAddr

getADDR :: Word8 -> ByteString -> (ByteString,ByteString)
getADDR t x = bimap B.pack B.pack $ go ([],f t s)
  where
    s =  B.unpack x
    f x = if t == 0x03 then drop 5 else drop 4
    go (p,[a,b]) = (p,b])
    go (a,(b : bs)) = go (a ++ [b],bs)

getADDR提取DST.ADDRDST.PORT

我认为我正在h中以ByteString的身份获得完整的HTTP(S)请求,但是我不知道如何执行该请求。

h

中的某些内容
GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: keep-alive (I'm not showing all of request)

任何人都可以对我应该做什么以及需要什么软件包提供一些提示吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...