ad88888ba                     88    ad88          
 d8"     "8b                    ""   d8"     ,d     
 Y8,                                 88      88     
 `Y8aaaaa,   8b      db      d8 88 MM88MMM MM88MMM  
   `"""""8b, `8b    d88b    d8' 88   88      88     
         `8b  `8b  d8'`8b  d8'  88   88      88     
 Y8a     a8P   `8bd8'  `8bd8'   88   88      88,    
  "Y88888P"      YP      YP     88   88      "Y888  
                                                    
                                                    
                                                                          
   ,ad8888ba,                          88                                 
  d8"'    `"8b                         88                                 
 d8'                                   88                                 
 88             ,adPPYba,  8b,dPPYba,  88,dPPYba,   ,adPPYba, 8b,dPPYba,  
 88      88888 a8"     "8a 88P'    "8a 88P'    "8a a8P_____88 88P'   "Y8  
 Y8,        88 8b       d8 88       d8 88       88 8PP""""""" 88          
  Y8a.    .a88 "8a,   ,a8" 88b,   ,a8" 88       88 "8b,   ,aa 88          
   `"Y88888P"   `"YbbdP"'  88`YbbdP"'  88       88  `"Ybbd8"' 88          
                           88                                             
                           88 

Swift-Gopher

此软件包还提供了 GopherHelpers,在构建客户端时可能会很有用。一个名为 iGopherBrowser 的 iOS/macOS/iPadOS PoC 客户端同时使用了 GopherHelpersswiftGopherClient

您可以通过 gopher://gopher.navan.dev 或 https://gopher.navan.dev 与我托管的 gopher 服务器进行交互

USAGE: swift-gopher [--gopher-host-name <gopher-host-name>] [--host <host>] [--port <port>] [--gopher-data-dir <gopher-data-dir>] [--disable-search] [--disable-gophermap]

OPTIONS:
  -g, --gopher-host-name <gopher-host-name>
                          Hostname used for generating selectors (default: localhost)
  -h, --host <host>       (default: 0.0.0.0)
  -p, --port <port>       (default: 8080)
  -d, --gopher-data-dir <gopher-data-dir>
                          Data directory to map (default: ./example-gopherdata)
  --disable-search        Disable full-text search feature
  --disable-gophermap     Disable reading gophermap files to override automatic generation
  -h, --help

开始使用

git clone https://github.com/navanchauhan
cd swift-gopher
swift build -c release && swift run swift-gopher

然后,您可以使用 lynx 或 curl(或其他 Gopher 客户端)连接到服务器。

lynx gopher://:8080
# Or,
curl gopher://:8080

注意:根据用户权限,您可能无法绑定到端口 70。

要在 Linux 上为二进制文件赋予权限,您可以使用以下命令

sudo setcap CAP_NET_BIND_SERVICE=+eip ./.build/release/swift-gopher

您还可以参考下面的 systemd 文件,以授予二进制文件相同的权限

部署

Systemd

systemd 示例文件

[Unit]
Description=Swift-Gopher

[Service]
ExecStart=/home/swift-gopher/swift-gopher/.build/release/swift-gopher --port 70 --gopher-host-name gopher.navan.dev --gopher-data-dir /home/swift-gopher/gopher_data
User=swift-gopher
Group=swift-gopher
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

HTTP 代理

尽管 swift-gopher 目前没有原生的 HTTP 处理程序,但您可以使用以下一些软件包自行托管,以将 Gopher 服务器代理到 HTTP

待办事项

生成文档

./generate_docs.sh swiftGopherClient swift-gopher GopherHelpers

参考文档

参考文档托管在 https://web.navan.dev/swift-gopher