Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
pedrosgali

File sharing and DNS

Recommended Posts

This is a file/dns server program I wrote.

 

just run it to start hosting a dns server, launch it with an additional argument to show the debug.

 

DNS/File server:

http://pastebin.com/pxFY89UZ

 

The next file is the networking API I wrote to deal with server communications, it has 6 functions;

 

register(name, port):

This will register the machine with a name on the dns server, all further communications can be sent to the server and will be routed automatically.

 

send(receiverName, message, opt1, opt2):

This will send a message to the server which will then route it to receiverName.

 

getRepoList(): returns table

This will get a list of all files saved to the server in the REPO folder, returns a table.

 

pull(destinationName, filename):

Pulls a file from the server. destinationName is the target computer so you can pull from any machine to any other on the network.

 

push(filepath, filename, version, installDir)

Pushes a file to the server, here's what happens. The server will make a new folder in REPO eg  "c/REPO/filename"

inside that folder it will create a file labelled latest.txt, this file stores the version number and installDir so the pull function knows where things need to be installed and which version to send. (I did this so I can put in dependencies later... or you can.)

the file itself is saved as the version number.

 

listen(targetMsg): returns up to 3 messages

Listens on the network until it hears a message. targetMsg is optional, if blank then the first modem message will be returned.

call example: msg, opt1, opt2 = listen()

will return three variables. as targetMsg is blank it will return on the first modem message it hears.

 

net API:

http://pastebin.com/1JMKXGEp

 

Here's a program that uses the API to easily push and pull files from the server. It takes up to 4 arguments. I call it repo.

so calling:

 

"repo list"                                                                will display a list of all files stored on the server.

"repo pull filename"                                               will pull filename from the server to this computer.

"repo push filename filepath version installDir"  will push a local file to the server and update the latest.txt with the new version and installDir.

 

Repo program:

http://pastebin.com/cgjUBeT3

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.