1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-27 04:18: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: To use fget, run:
``` ```
fget <host[:port]> <path> fget <host[:port]>/<path>
```
So, for example:
```
fget sks-srv:70/OpenOS
``` ```
## fserv daemon ## fserv daemon

View File

@ -1,13 +1,16 @@
local net = require "net" local net = require "net"
local event = require "event" local event = require "event"
local tArgs = {...} local function parseURL(url)
local address, path = tArgs[1], tArgs[2] local hp, path = url:match("(.-)(/.+)")
local port = 70 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+)") local tArgs = {...}
port = nport or port local host, port, path = parseURL(tArgs[1])
host = host or address
local socket = net.open(host,port) local socket = net.open(host,port)
socket:write("t"..path.."\n") socket:write("t"..path.."\n")