From b3848e688692f19cf3ab95cb15e0ccaa3b8accc9 Mon Sep 17 00:00:00 2001 From: Izaya Date: Wed, 18 Apr 2018 10:22:59 +1000 Subject: [PATCH] updated fget to use a better URL parser from the KittenOS version --- FRequest/OpenOS/README.md | 8 +++++++- FRequest/OpenOS/usr/bin/fget.lua | 15 +++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/FRequest/OpenOS/README.md b/FRequest/OpenOS/README.md index 9b1f9aa..f299d43 100644 --- a/FRequest/OpenOS/README.md +++ b/FRequest/OpenOS/README.md @@ -21,7 +21,13 @@ fget can be used to get both directory listings and files, provided the server a To use fget, run: ``` -fget +fget / +``` + +So, for example: + +``` +fget sks-srv:70/OpenOS ``` ## fserv daemon diff --git a/FRequest/OpenOS/usr/bin/fget.lua b/FRequest/OpenOS/usr/bin/fget.lua index fbad176..12d5aa7 100644 --- a/FRequest/OpenOS/usr/bin/fget.lua +++ b/FRequest/OpenOS/usr/bin/fget.lua @@ -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")