1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-23 10:38:05 +11:00

updated fget to use a better URL parser from the KittenOS version

This commit is contained in:
Izaya 2018-04-18 10:22:59 +10:00
parent b25311bfed
commit b3848e6886
2 changed files with 16 additions and 7 deletions

View File

@ -21,7 +21,13 @@ fget can be used to get both directory listings and files, provided the server a
To use fget, run:
```
fget <host[:port]> <path>
fget <host[:port]>/<path>
```
So, for example:
```
fget sks-srv:70/OpenOS
```
## fserv daemon

View File

@ -1,13 +1,16 @@
local net = require "net"
local event = require "event"
local tArgs = {...}
local address, path = tArgs[1], tArgs[2]
local port = 70
local function parseURL(url)
local hp, path = url:match("(.-)(/.+)")
hp, path = hp or url, path or "/"
local host, port = hp:match("(.+):(.+)")
host, port = host or hp, port or 70
return host, port, path
end
local host,nport = address:match("(.+):(%d+)")
port = nport or port
host = host or address
local tArgs = {...}
local host, port, path = parseURL(tArgs[1])
local socket = net.open(host,port)
socket:write("t"..path.."\n")