Piorjade 2 Posted March 31, 2017 Share Posted March 31, 2017 net API - The most basic DNS system How this works: The DNS server constantly broadcasts out its information every 2 seconds on the specified port The client APIs have a function to search for the next DNS server (they wait for the above information) which then sets the table containing the information to net.foundServer Now the client APIs have the ability to call net.setDNS(net.foundServer.address) to lock to that DNS With that the client APIs can now register and delete their URLs on this DNS server Every other client who has that DNS server locked on too can look up your modem's address by calling net.resolve(url) [returns true/false and the message (either an error or the address)] Requirements: DNS server: A setup with color support (it logs stuff on the screen and uses colors for that too) Of course a wireless network card My multitasking API which should be saved as "oc_multitasking_api" At best: openOS (because it uses the keyboard and event api) Client: The api A wireless network card of course And maybe an idea on how you can make use of it At best: openOS (because it uses the event api) How to set it up: Build a server / computer for the DNS server (look at the requirements) Buld a computer for the client(s) (look at the requirements) Create a new program to use the API NOTE: At boot, the API doesn't have a DNS server registered, you NEED to register it using net.listenForDNS() or directly putting in an address local net = require("net") --This needs to be called for every program which uses the API, which is normal net.listenForDNS() --This wont stop until it gets a message from a DNS server net.setDNS(net.foundServer.address) --Set the locked DNS to the actual address of the found server Functions: listenForDNS() : Waits for a DNS server to broadcast it's information registerURL([STRING]): Registers an URL for your modem's address (Returns true/false with an (error-) message) removeURL([STRING]): Removes the given URL from the DNS if it's yours (Returns true/false with an (error-) message) setDNS([STRING]): Set the locked DNS' address to the given one getDNS(): Get the currently locked DNS' address (returns the address of the DNS server's modem) getPort(): Get the port which the API looks for messages from the DNS server setPort([NUMBER]): Set the port which the API looks for messages from the DNS server resolve([STRING]): Try to get the modem address of the given URL (Returns true/false with the address or an error message) getURL([STRING]): The reverse of the above function (Returns true/false with the URL or an error message) getAll(): Returns a table with every URL and the associated address on the DNS server (key = URL, value = address) Download: DNS server: Pastebin net API: Pastebin NOTE: The DNS server does currently not save the DNS list on reboot and it looks like it stops broadcasting when the computer stays on when closing the server / game. Quote Link to post Share on other sites