_G.net
Type | Name | Description |
---|---|---|
table |
standardPorts |
Table of standard ports for networking |
table |
encrypt |
Encryption module for networking |
Return | Name | Description |
---|---|---|
string |
getHWAddr() |
Gets the hardware address of this computer as a hex string |
string |
getIPV() |
Gets IV version the package uses (currently IPV4) |
string |
ipFormat(ip: string|number) |
Turns a IPV4 string address in x:x:x:x into a number |
number |
ipToNumber(ip: string|number) |
Formats a numeric or string IP for IPV4: x:x:x:x |
number |
getIP() |
Gets numeric IP of this computer |
number |
getIPMask() |
Gets the current IP subnet mask |
number|string |
relizeHostname(hostname: string) |
Tries to resolve the given hostname to an IP or HW address |
string |
getHostname() |
Gets the current hostname of this computer, if set |
boolean |
setHostname(hostname: string) |
Tries to set the hostname of this computer and register it on the current DNS |
boolean |
isSetup() |
If the net module has been setup |
boolean |
setup(mdm: Modem|nil, ip: number|nil) |
Tries to setup the net module, modem and IP if provided |
number |
send(port: number, dest: number|string, msgType: string, body: any) |
Sends a net message to destination on port with provided type and body, and returns message ID |
net.Message|string |
sendSync(port: number, dest: number|string, msgType: string, body: any) |
Sends a net message to destination on port with provided type and body and returns the response or error |
number |
sendAdv(port: number, dest: number|string, head: table, body: any) |
Sends a net message to destination on port with provided head and body, and returns message ID |
net.Message|string |
sendAdvSync(port: number, dest: number|string, head: table, body: any) |
Sends a net message to destination on port with provided head and body and returns the response or error |
number |
reply(port: number, msg: net.Message, head: table, body: any) |
Responds to a message on port with head and body, and returns message ID |
net.Message|string |
waitForMsg(port: number, time: number) |
Waits for the next message on port within time. Use 0 for no timeout |
net.Message|string |
waitForMsgAdv(port: number, time: number, check: function) |
Waits for the next message on port within time that satisfies the check function. Use 0 for no timeout |
boolean |
validMsg(port: number, message: table) |
Checks if the provided message is a valid net message |
number |
registerMsgHandler(func: function) |
Registers a message handler and returns handlerId for unregistering |
nil |
unregisterMsgHandler(id: number) |
Unregisters a message handler by ID |
string |
stringMessage(msg: net.Message) |
Returns a string version of a message for debug and logging |
nil |
open(port: number) |
Opens a port |
nil |
ping(dest: string|number) |
Tries to ping a given destination and prints the time taken |
string|nil , string , string |
splitUrl(url: string) |
Splits a URL into protocol, domain, and path |
nil |
setLogVerbose(vb: boolean) |
Sets if all messages should be logged to the net log at /home/.pgmLog/net.log |
registerMsgHandler(func: function)
:
Registers a message handler function:
Handler should take: msg: net.Message
standardPorts
:Name | Value | Description |
---|---|---|
network |
10000 |
Network control port |
rttp |
10080 |
Redstone Text Transfer Protocol (RTTP) |
rttps |
10081 |
(Unused at this time) Redstone Text Transfer Protocol Secure |
ftp |
10021 |
File Transfer Protocol (net-ftp) |
rmail |
10025 |
rMail protocol |
remoteUser |
10234 |
Remote user system |
_G.net.encrypt
Return | Name | Description |
---|---|---|
nil |
setup() |
Initializes the net encryption module |
byteArray , byteArray |
encrypt(data: any, public: string|byteArray) |
Encrypts the given data using the receiver's public key, and returns the cypher text and signature |
boolean , any |
decrypt(cypher: byteArray, sig: byteArray, public: string|byteArray) |
Decrypts the given cypher text using the receiver's public key and verifies the signature, and returns if the successful the decrypted data |
byteArray |
getPublicKey() |
Returns the public key |
net.Message
Type | Name | Description |
---|---|---|
number|string |
origin |
IP or HW address of origin device |
number|string |
dest |
IP or HW address of destination device |
number |
port |
Networking port |
table |
header |
Message header, includes type field. may include NAT conId field |
any |
body |
Message body |
number |
msgid |
Message id |
number |
port |
(Not transmitted) Port the message was received on |
Return | Name | Description |
---|---|---|
nil |
reply(p: number, head: table, body: any) |
Replies to this message on port with head and body |