mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-12-26 10:18:07 +11:00
updated fget to use a better URL parser from the KittenOS version
This commit is contained in:
parent
b25311bfed
commit
b3848e6886
@ -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
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user