Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ping()
- fails = 0
- print("Testing Internet Connection.")
- print("")
- oldx, oldy = term.getCursorPos()
- print("Connection Test 1")
- http.request("http://www.example-failure.com/")
- if os.pullEvent() == "http_success" then
- local oldx, oldy = term.getCursorPos()
- term.setCursorPos(46,oldy-1)
- io.write("Passed")
- else
- local oldx, oldy = term.getCursorPos()
- term.setCursorPos(46,oldy-1)
- io.write("Failed")
- fails = fails+1
- end
- sleep(1)
- print("Connection Test 2")
- http.request("http://www.example-failure.com/")
- if os.pullEvent() == "http_success" then
- local oldx, oldy = term.getCursorPos()
- term.setCursorPos(46,oldy-1)
- io.write("Passed")
- else
- local oldx, oldy = term.getCursorPos()
- term.setCursorPos(46,oldy-1)
- io.write("Failed")
- fails = fails+1
- end
- sleep(1)
- print("Connection Test 3")
- http.request("http://www.example-failure.com/")
- if os.pullEvent() == "http_success" then
- local oldx, oldy = term.getCursorPos()
- term.setCursorPos(46,oldy-1)
- io.write("Passed")
- else
- local oldx, oldy = term.getCursorPos()
- term.setCursorPos(46,oldy-1)
- io.write("Failed")
- fails = fails+1
- end
- sleep(1)
- if fails == 0 then
- print("")
- print("")
- print("Test Complete, no failures detected.")
- sleep(1.5)
- elseif fails == 1 then
- print("")
- print("")
- print("1 connection failures detected. A Website Host might be down however connectivity is still there.")
- print("")
- print("Test Complete.")
- sleep(1.5)
- elseif fails == 2 then
- print("")
- print("")
- print("2 connection failures detected. Possible limited web connectivity.")
- print("")
- print("Test Complete.")
- sleep(1.5)
- elseif fails == 3 then
- print("")
- print("")
- print("Catastrophic connection failure detected. A firewall or improper internet settings may be the problem.")
- print("")
- print("Test Complete.")
- pingResult = 3
- sleep(1.5)
- end
- end
- ping()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement