Jump to content




CraftNet Project

api networking utility

26 replies to this topic

#1 App1eGenius93

  • Members
  • 21 posts
  • LocationRochester, NY

Posted 26 September 2012 - 03:08 PM

CraftNet

(Note: Midterm week for me so I'll get this page updated this weekend)

Description:

CraftNet is a project that aims at recreating actual network interfaces and hopes to provide powerful ComputerCraft networking functionality in the world of Minecraft. We hope to achieve this by creating API's and programs that allow any user to create a file server with just a few keystrokes.

Members:
  • App1eGenius93 (Dustin)
  • MysticT
  • thesbros
  • Heli25 (Joe) (Won't find on these forums)
  • Danny
In Progress:
  • DNS
  • FTP
Completed Tasks:
  • None
Server Address:
  • cvmc.mclegacyhosting.com:25567 (Minecraft) (whitelisted)
  • dustinschreiber.com (Teamspeak) (Non-members won't be able to do anything)
I'll try to keep the to-do list photo up to date.

Attached Image: Screen Shot 2012-09-26 at 1.57.19 PM.png

#2 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 26 September 2012 - 03:29 PM

Sooooooooooo..... Can we have some more specific defined description?
I can't figure if you are making a way of connecting to FTP and DNS in-game or make a virtual FTP and DNS system...

#3 App1eGenius93

  • Members
  • 21 posts
  • LocationRochester, NY

Posted 26 September 2012 - 03:35 PM

View Postjag_e_nummer_ett, on 26 September 2012 - 03:29 PM, said:

Sooooooooooo..... Can we have some more specific defined description?
I can't figure if you are making a way of connecting to FTP and DNS in-game or make a virtual FTP and DNS system...

Yes, I'm just writing it externally and I had to run to class but wanted to get this up. I'll have a good description in a few hours. Sorry for lack of info.

#4 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 26 September 2012 - 05:33 PM

View PostApp1eGenius93, on 26 September 2012 - 03:35 PM, said:

View Postjag_e_nummer_ett, on 26 September 2012 - 03:29 PM, said:

Sooooooooooo..... Can we have some more specific defined description?
I can't figure if you are making a way of connecting to FTP and DNS in-game or make a virtual FTP and DNS system...

Yes, I'm just writing it externally and I had to run to class but wanted to get this up. I'll have a good description in a few hours. Sorry for lack of info.
It's ok :P/>
I'm just curious

#5 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 26 September 2012 - 07:50 PM

It would be so cool if this came along and became something big, so that you can have like a internet connection. So someone can host like a website or something and others can use a web browser (add that to the to-do :P/> ) to see the website.

Just go a step further and someone creates games that uses your internet so that you can play online via rednet :D/>

#6 App1eGenius93

  • Members
  • 21 posts
  • LocationRochester, NY

Posted 26 September 2012 - 08:56 PM

View Postjag_e_nummer_ett, on 26 September 2012 - 07:50 PM, said:

It would be so cool if this came along and became something big, so that you can have like a internet connection. So someone can host like a website or something and others can use a web browser (add that to the to-do :P/> ) to see the website.

Just go a step further and someone creates games that uses your internet so that you can play online via rednet :D/>

Oooo! I like that! R u interested in joining the team at all? And when you say web browser, do u mean like you can use firefox or something to browse the website that's running via computercraft? Or do you mean it all runs within minecraft and people can have websites in the game?

#7 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 26 September 2012 - 09:11 PM

I'm studying IT myself and used to work on networking in CC myself (didn't find the time to continue though). However, I started implementing the ISO OSI model from scratch (layer 3 actually, bottom 2 layers are implemented by rednet allready). Wouldn't that be more 'base safe' than writing two procedures that behave like DNS and FTP but are actual just totally different protocols? Correct me if I understood you wrong and you're not doing that at all. : )

The advantage of simulating the OSI layers is the power of interfacing and flexibilty. You can adapt the bottom layers to the medium (like modem/bundled cables/something new) and all above still works...
Or even better yet, I was having this dream... I planned to port LuaSocket to CC (built on the OSI model), I also made a simple html browser that used the HTTP API. Now, the HTTP API used in CC is the exact same API as the HTTP part of LuaSocket, so my browser could browse on the CC networks as well as on the actual internet... Never got to porting LuaSocket though :P/>.

As I had two courses on Computer Networking last year and I'm following another one at the moment, I guess I could try and help on this project. I live in Europe though, and got little time on my hands.

#8 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 26 September 2012 - 09:33 PM

View PostOrwell, on 26 September 2012 - 09:11 PM, said:

I'm studying IT myself and used to work on networking in CC myself (didn't find the time to continue though). However, I started implementing the ISO OSI model from scratch (layer 3 actually, bottom 2 layers are implemented by rednet allready). Wouldn't that be more 'base safe' than writing two procedures that behave like DNS and FTP but are actual just totally different protocols? Correct me if I understood you wrong and you're not doing that at all. : )

The advantage of simulating the OSI layers is the power of interfacing and flexibilty. You can adapt the bottom layers to the medium (like modem/bundled cables/something new) and all above still works...
Or even better yet, I was having this dream... I planned to port LuaSocket to CC (built on the OSI model), I also made a simple html browser that used the HTTP API. Now, the HTTP API used in CC is the exact same API as the HTTP part of LuaSocket, so my browser could browse on the CC networks as well as on the actual internet... Never got to porting LuaSocket though :P/>.

As I had two courses on Computer Networking last year and I'm following another one at the moment, I guess I could try and help on this project. I live in Europe though, and got little time on my hands.
That's exactly what I was planning to do, except that I don't wanted to use rednet and was planning to add my own peripherals (cables, switches and wireless modems, already working).
I don't know if you (Dustin) had the same idea, but I think we should try to do that. Once we have that, we can use it as a base to higher level stuff.

#9 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 26 September 2012 - 10:00 PM

I'm glad someone else is walking the same path, I'm very interested to watch the progress in that. And actually, if you implement the OSI model correctly, adding rednet support on top of your own peripheral stuff would be of minimal effort, right?

#10 App1eGenius93

  • Members
  • 21 posts
  • LocationRochester, NY

Posted 26 September 2012 - 10:07 PM

I'm in my first year of IT at Rochester Institute of Technology. I've self taught myself a lot but you two are talking about some things (i mean some of the things you are saying) completely go over my head lol. I'm sure I could learn and understand that quickly haha. I haven't really thought much about the actual implementation yet I've just been thinking about programming part so far. I was waiting till I was able to get people on teamspeak and we actually talked about the best way to do some of this stuff. So who knows, we may be on the same path here lol.

#11 MetalMiner

  • Members
  • 45 posts
  • LocationSwitzerland!

Posted 27 September 2012 - 08:05 AM

View Postjag_e_nummer_ett, on 26 September 2012 - 07:50 PM, said:

It would be so cool if this came along and became something big, so that you can have like a internet connection. So someone can host like a website or something and others can use a web browser (add that to the to-do :P/> ) to see the website.

For a few weeks, im working on something like that. I made a 'webbrowser', wich allows you to call a website from another cc computer (with the server software). The browser has something like a html interpreter. Currently i implemented just the </br> tag, but i'll add more (currently i'm working on the <a> tag, wich allows you to mark a text as selectable link to another website).

Perhaps there is a way to combine these things (my browser will use your network)?

#12 nutcase84

  • Members
  • 711 posts
  • LocationIn My Lonely Little Computer Corner

Posted 27 September 2012 - 11:18 AM

This looks awesome! I hope it has a good turnout! :P/>

#13 App1eGenius93

  • Members
  • 21 posts
  • LocationRochester, NY

Posted 09 October 2012 - 03:16 PM

Okay I forgot to update over the weekend. While try and fix up some things today. I'm working on a site that will have the news and eventual download for the project. Also will have our progress posted there so I may or may not update this thread much once I finish the site.

Stay tuned! :P/>

#14 FuzzyPurp

    Part-Time Ninja

  • Members
  • 510 posts
  • LocationHarlem, NY

Posted 17 October 2012 - 06:49 AM

Please post a code or this thread will be removed from the programs section.

#15 App1eGenius93

  • Members
  • 21 posts
  • LocationRochester, NY

Posted 17 October 2012 - 02:19 PM

View PostFuzzyPurp, on 17 October 2012 - 06:49 AM, said:

Please post a code or this thread will be removed from the programs section.

We don't really have any code ready for the public yet... Is there another section that this should be for now then?

#16 DaWooShit

  • Members
  • 21 posts

Posted 20 October 2012 - 04:57 PM

I have made a simple ftp program and a simple ftp client. Again, very simple and basic. But it might be of use to you...

Commands is:
download - download a file from the server
goto - go to a page (if there is a lot of files/folders in a directory)
up - move on directory up.
exit - Exit program and clear ftp server.

FTP Client:

local running = true
local selected = 1
settings={}
--[[Load settings]]--
test = io.open("settings.txt", "r")
if test == nil then
file = io.open("settings.txt", "w")
 
while X~="top" and X~="bottom" and X~="left" and X~="right" and X~="back" and X~="front" do
  term.clear()
  term.setCursorPos(1,1)
  print("Which side is the router on?:")
  X=io.read()
end
 
file:write(X)
file:write("n")
file:write("stop")
file:write("n")
file:close()
print("Settings completed...")
print("Please restart the program...")
sleep(4)
os.reboot()
else
test:close()
file = io.open("settings.txt", "r")
running=true
while running do
  X = file:read()
  if X~="stop" then
   table.insert(settings,X)
  else
   running=false
  end
end
file:close()
end
--[[Download]]--
function Download()
term.clear()
term.setCursorPos(1,1) 
print("Enter number next to the ")
print("file you wish to download:")
Z=io.read()
term.clear()
term.setCursorPos(1,1)
print("Enter name of the final file")
print("EX: Downloadedfile.txt")
Y=io.read()
file = io.open(Y, "w")
rednet.send(FTPSERVER,"download")
rednet.send(FTPSERVER,Z)
msg="none"
while msg~="StopDownloadNow" do
  id, msg=rednet.receive(5)
  if msg~="StopDownloadNow" then
   print("Data stream: ",msg)
   file:write(msg)
   file:write("n")
  end
end
file:close()
print("Download Completed...")
sleep(4)
os.reboot()
end
--[[functions in menu]]--
FTPSERVER=0
Files={}

while FTPSERVER<=0 do
  term.clear()
  term.setCursorPos(1,1)
  print("Enter ID of ftp server")
  FTPSERVER=io.read()
  if tonumber(FTPSERVER)~=nil then
   FTPSERVER=math.ceil(tonumber(FTPSERVER))
  else
   FTPSERVER=0
  end
end
rednet.open(settings[1])
rednet.send(FTPSERVER,"ftp")
X=10
while X>0 do
  id, msg=rednet.receive(5)
  X=X-1
  if msg=="confirmed" and id==FTPSERVER then
   X=0
   print("Ftp server found...")
   sleep(1)
   rednet.send(FTPSERVER,"/ftp")
  else
   print("Ftp server not found")
   print("Attempt to restart server?")
   print("y/n?")
   Z=io.read()
   if Z=="y" then
    rednet.send(FTPSERVER,"exit")
   end
   os.reboot()
  end
 
  while true do
   msg="none"
   Files={}
   while msg~="true" and msg~="false" do
    id, msg=rednet.receive(5)
    if msg~="true" and msg~="false" then
	 table.insert(Files,msg)
    end
   end
   Print=true
   Side=1
   Printlist=1
   Sides=math.ceil(#Files/14)
   while Print do
    term.clear()
    term.setCursorPos(1,1)
    for i=Printlist,Printlist+14 do
  if i<10 then
	  print(i,"  : ",Files[i])
  else
   print(i," : ",Files[i])
  end
    end
print(Side,"/",Sides)
    if msg=="true" then
   print("Folder found")
    else
   print("Folder not found")
    end
Y=io.read()
 
    if Y=="exit" then
  Print=false
	 rednet.send(FTPSERVER,"exit")
   os.reboot()
    elseif Y=="up" then
  Print=false
	 rednet.send(FTPSERVER,"up")
    elseif Y=="download" then
  Print=false
	 Download()
elseif Y=="goto" then
  term.clear()
  term.setCursorPos(1,1)
  print("Goto what page?")
  Y=io.read()
  if tonumber(Y)~=nil and tonumber(Y)<=Sides then
   Side=math.ceil(tonumber(Y))
   Printlist=Side*14
  end
    else
  Print=false
	 if tonumber(Y)~=nil then
   Y=math.ceil(tonumber(Y))
   Directory=Files[Y]
   Directory="/"..Directory
	  rednet.send(FTPSERVER,Directory)
  end 
   end
   end
   end
   end


FTP server:

Dontshow="config"
if fs.isDir("/ftp")==false then
fs.makeDir("/ftp")
end

function Download(X)
print("Uploadning file:")
msg=tonumber(msg)
TempDir=""
for i=1,#Directories do
  TempDir=TempDir..Directories[i]
end
TempDir=TempDir.."/"..Files[msg]
print("Sending: ",TempDir)
if fs.exists(TempDir)==true then
file = io.open(TempDir, "r")
  while X~=nil do
   X = file:read()
   if X~=nil then
    print("Send data:",X)
    rednet.send(idX,X)
   end
   sleep(0.1)
  end
  rednet.send(idX,"StopDownloadNow")
end
end

rednet.open("top")
msg="none"
idX, msg=rednet.receive()
if msg=="exit" then
  os.reboot()
end
if msg=="ftp" then
  Directories={}
  rednet.send(idX,"confirmed")
  TempDir=""
 
  while true do
   print("Waiting for command...")
   msg="nullstate"
   id, msg=rednet.receive(300)
   if msg=="nullstate" then
    os.reboot()
   end
   if id==idX then
   if msg=="up" then
    table.remove(Directories,#Directories)
   elseif msg=="exit" then
    os.reboot()
   elseif msg=="download" then
    id, msg=rednet.receive(5)
    Download(msg)
   else
    print("Searching for files in: ",msg)
    search=false
    TempDir=""
    for i=1,#Directories do
	 TempDir=TempDir..Directories[i]
    end
    TempDir=TempDir..msg
    if fs.isDir(TempDir)==true then
	 search=true
  print("Directory found")
  table.insert(Directories,msg)
    end
   end
 
  TempDir=""
  for i=1,#Directories do
   TempDir=TempDir..Directories[i]
  end
 
  print("Final directory: ",TempDir)
 
  Files=fs.list(TempDir)
  print("Files found: ")
  for i=1,#Files do
   if Files[i]~=Dontshow then
    print(Files[i])
    rednet.send(idX,Files[i])
    sleep(0.1)
   end
  end
  sleep(0.5)
  if search==true then
    rednet.send(idX,"true")
  else
    rednet.send(idX,"false")
  end
  end
end
end


#17 Cruor

  • Members
  • 413 posts
  • LocationNorway

Posted 27 October 2012 - 07:13 PM

Moved to general as this is not a program.

#18 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 28 October 2012 - 04:36 AM

Oh, please, not another "I'm gonna make the Internet!" topics. At least the poster of this one seems to understand networking.

#19 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

Posted 28 October 2012 - 04:45 AM

Are there any openings in your development team? If so, I'd love to help if I can.

#20 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 28 October 2012 - 04:46 AM

View PostDaWooShit, on 20 October 2012 - 04:57 PM, said:

I have made a simple ftp program and a simple ftp client. Again, very simple and basic. But it might be of use to you...

Commands is:
download - download a file from the server
goto - go to a page (if there is a lot of files/folders in a directory)
up - move on directory up.
exit - Exit program and clear ftp server.

FTP Client:

local running = true
local selected = 1
settings={}
--[[Load settings]]--
test = io.open("settings.txt", "r")
if test == nil then
file = io.open("settings.txt", "w")

while X~="top" and X~="bottom" and X~="left" and X~="right" and X~="back" and X~="front" do
  term.clear()
  term.setCursorPos(1,1)
  print("Which side is the router on?:")
  X=io.read()
end

file:write(X)
file:write("n")
file:write("stop")
file:write("n")
file:close()
print("Settings completed...")
print("Please restart the program...")
sleep(4)
os.reboot()
else
test:close()
file = io.open("settings.txt", "r")
running=true
while running do
  X = file:read()
  if X~="stop" then
   table.insert(settings,X)
  else
   running=false
  end
end
file:close()
end
--[[Download]]--
function Download()
term.clear()
term.setCursorPos(1,1) 
print("Enter number next to the ")
print("file you wish to download:")
Z=io.read()
term.clear()
term.setCursorPos(1,1)
print("Enter name of the final file")
print("EX: Downloadedfile.txt")
Y=io.read()
file = io.open(Y, "w")
rednet.send(FTPSERVER,"download")
rednet.send(FTPSERVER,Z)
msg="none"
while msg~="StopDownloadNow" do
  id, msg=rednet.receive(5)
  if msg~="StopDownloadNow" then
   print("Data stream: ",msg)
   file:write(msg)
   file:write("n")
  end
end
file:close()
print("Download Completed...")
sleep(4)
os.reboot()
end
--[[functions in menu]]--
FTPSERVER=0
Files={}

while FTPSERVER<=0 do
  term.clear()
  term.setCursorPos(1,1)
  print("Enter ID of ftp server")
  FTPSERVER=io.read()
  if tonumber(FTPSERVER)~=nil then
   FTPSERVER=math.ceil(tonumber(FTPSERVER))
  else
   FTPSERVER=0
  end
end
rednet.open(settings[1])
rednet.send(FTPSERVER,"ftp")
X=10
while X>0 do
  id, msg=rednet.receive(5)
  X=X-1
  if msg=="confirmed" and id==FTPSERVER then
   X=0
   print("Ftp server found...")
   sleep(1)
   rednet.send(FTPSERVER,"/ftp")
  else
   print("Ftp server not found")
   print("Attempt to restart server?")
   print("y/n?")
   Z=io.read()
   if Z=="y" then
    rednet.send(FTPSERVER,"exit")
   end
   os.reboot()
  end

  while true do
   msg="none"
   Files={}
   while msg~="true" and msg~="false" do
    id, msg=rednet.receive(5)
    if msg~="true" and msg~="false" then
	 table.insert(Files,msg)
    end
   end
   Print=true
   Side=1
   Printlist=1
   Sides=math.ceil(#Files/14)
   while Print do
    term.clear()
    term.setCursorPos(1,1)
    for i=Printlist,Printlist+14 do
  if i<10 then
	  print(i,"  : ",Files[i])
  else
   print(i," : ",Files[i])
  end
    end
print(Side,"/",Sides)
    if msg=="true" then
   print("Folder found")
    else
   print("Folder not found")
    end
Y=io.read()

    if Y=="exit" then
  Print=false
	 rednet.send(FTPSERVER,"exit")
   os.reboot()
    elseif Y=="up" then
  Print=false
	 rednet.send(FTPSERVER,"up")
    elseif Y=="download" then
  Print=false
	 Download()
elseif Y=="goto" then
  term.clear()
  term.setCursorPos(1,1)
  print("Goto what page?")
  Y=io.read()
  if tonumber(Y)~=nil and tonumber(Y)<=Sides then
   Side=math.ceil(tonumber(Y))
   Printlist=Side*14
  end
    else
  Print=false
	 if tonumber(Y)~=nil then
   Y=math.ceil(tonumber(Y))
   Directory=Files[Y]
   Directory="/"..Directory
	  rednet.send(FTPSERVER,Directory)
  end 
   end
   end
   end
   end


FTP server:

Dontshow="config"
if fs.isDir("/ftp")==false then
fs.makeDir("/ftp")
end

function Download(X)
print("Uploadning file:")
msg=tonumber(msg)
TempDir=""
for i=1,#Directories do
  TempDir=TempDir..Directories[i]
end
TempDir=TempDir.."/"..Files[msg]
print("Sending: ",TempDir)
if fs.exists(TempDir)==true then
file = io.open(TempDir, "r")
  while X~=nil do
   X = file:read()
   if X~=nil then
    print("Send data:",X)
    rednet.send(idX,X)
   end
   sleep(0.1)
  end
  rednet.send(idX,"StopDownloadNow")
end
end

rednet.open("top")
msg="none"
idX, msg=rednet.receive()
if msg=="exit" then
  os.reboot()
end
if msg=="ftp" then
  Directories={}
  rednet.send(idX,"confirmed")
  TempDir=""

  while true do
   print("Waiting for command...")
   msg="nullstate"
   id, msg=rednet.receive(300)
   if msg=="nullstate" then
    os.reboot()
   end
   if id==idX then
   if msg=="up" then
    table.remove(Directories,#Directories)
   elseif msg=="exit" then
    os.reboot()
   elseif msg=="download" then
    id, msg=rednet.receive(5)
    Download(msg)
   else
    print("Searching for files in: ",msg)
    search=false
    TempDir=""
    for i=1,#Directories do
	 TempDir=TempDir..Directories[i]
    end
    TempDir=TempDir..msg
    if fs.isDir(TempDir)==true then
	 search=true
  print("Directory found")
  table.insert(Directories,msg)
    end
   end

  TempDir=""
  for i=1,#Directories do
   TempDir=TempDir..Directories[i]
  end

  print("Final directory: ",TempDir)

  Files=fs.list(TempDir)
  print("Files found: ")
  for i=1,#Files do
   if Files[i]~=Dontshow then
    print(Files[i])
    rednet.send(idX,Files[i])
    sleep(0.1)
   end
  end
  sleep(0.5)
  if search==true then
    rednet.send(idX,"true")
  else
    rednet.send(idX,"false")
  end
  end
end
end

This could work... Maybe this will b the first time we make Internet in CC?

PS: Also, try to get in the habit of using local variables.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users