Jump to content




[ LogAPI ] v1.72 Logging made easier!

api computer

33 replies to this topic

#21 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 12 June 2014 - 01:31 PM

View Postlebalusch, on 12 June 2014 - 10:47 AM, said:

Hi Mikk809h,
Didn't realise you could white list sites or black list them. I am testing on my own real life laptop. in single player , using FTB monster. when i test your scripts i lay a new computercraft block (gold) so shouldn't be a problem. maybe if you add some code to make a point of white listing it before you try to go to the site this might help. but i have had your script working before you made the big changes. Was you using that HTTP call before the big changes if so its not that being a problem. but i do think you should code in white listing the site before calling it.

p.s how do you do these spoilers. they save on loads of space in comments.
You cannot whitelist a site from code. It has to be done manually in the config. This was added in the CC 1.63 update, before which http was simply true (enabled) or false (disabled).

#22 Goof

  • Members
  • 751 posts

Posted 12 June 2014 - 03:00 PM

View Postlebalusch, on 12 June 2014 - 10:47 AM, said:

Hi Mikk809h,
Didn't realise you could white list sites or black list them. I am testing on my own real life laptop. in single player , using FTB monster. when i test your scripts i lay a new computercraft block (gold) so shouldn't be a problem. maybe if you add some code to make a point of white listing it before you try to go to the site this might help. but i have had your script working before you made the big changes. Was you using that HTTP call before the big changes if so its not that being a problem. but i do think you should code in white listing the site before calling it.

p.s how do you do these spoilers. they save on loads of space in comments.
Well, All my HTTP calls have had this feature, and they access the timeanddate.com webpage. Maybe its because you updated to newest version of cc?
Then youj forgot to add www.timeanddate.*

And as KingofGamesYami said:

View PostKingofGamesYami, on 12 June 2014 - 01:31 PM, said:

You cannot whitelist a site from code. It has to be done manually in the config. This was added in the CC 1.63 update, before which http was simply true (enabled) or false (disabled).


And i dont think it would be a great idea, to allow programs to whiltelist webpages themselfes, since that could cause a program to acces a malicious webpage ( thats an example )

But I dont quite know how to detect if certain webpages are whitelisted or not.. Maybe someone can point out the whitelist detection code?

Thanks

#23 lebalusch

  • Members
  • 49 posts

Posted 12 June 2014 - 04:55 PM

Hi guys,
Yes it makes sense to lock programs out from being able to do that. The pack FTB Monster is currently using is ComputerCraft 1.58
could someone be nice enough to talk me through how to set said HTTP to being on the white list as i have opened the config file and there is no mention to allowed http's on a white list there.
i all ready know that HTTP access is true as in FTB its set to on by default.
(if you are playing vanilla MC its not just follow this http://www.computerc...e-the-http-api/ )

# Enable the "http" API on Computers
B:enableAPI_http=true

#24 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 12 June 2014 - 05:15 PM

View Postlebalusch, on 12 June 2014 - 04:55 PM, said:

-snip-
There is no "whitelist" in CC 1.58. It was changed to whitelist in CC 1.63, which isn't relevant since you are not using it. If the pastebin program works, http is enabled fully. If not, in CC 1.63 you have to either
1) add the site to the whitelist
or
2) enable all sites (just put a "*" I believe, I'm not sure though)

Edited by KingofGamesYami, 12 June 2014 - 05:15 PM.


#25 lebalusch

  • Members
  • 49 posts

Posted 12 June 2014 - 05:20 PM

View PostKingofGamesYami, on 12 June 2014 - 05:15 PM, said:

View Postlebalusch, on 12 June 2014 - 04:55 PM, said:

-snip-
There is no "whitelist" in CC 1.58. It was changed to whitelist in CC 1.63, which isn't relevant since you are not using it. If the pastebin program works, http is enabled fully. If not, in CC 1.63 you have to either
1) add the site to the whitelist
or
2) enable all sites (just put a "*" I believe, I'm not sure though)

Well does the program work correctly for you? If i have no whitelist due to the version i am running and the http access is turned on then the program should work....i guess? but it does not since the changes were made. Could you please try the program and let me know please.

#26 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 12 June 2014 - 05:57 PM

The version on pastebin is flawed on line 86/87, he forgot to add the end to this statement:
local function checkUpdate()
  if http then
    local check={}
    local pastebinCode="1mwhBiW9"
    local pdtSite="http://pastebin.com/raw.php?i=" .. pastebinCode
    check["update"]=http.get(pdtSite).readAll()
    check["oldVersion"]=VERSION_LOGAPI
    check["newVersion"]=string.match(check["update"], "(%d+.%d+).-")
    return tonumber(check["newVersion"])>tonumber(check["oldVersion"]), check["newVersion"], check["oldVersion"]
  else
    return false, VERSION_LOGAPI, VERSION_LOGAPI
end
Corrected code:
local function checkUpdate()
  if http then
    local check={}
    local pastebinCode="1mwhBiW9"
    local pdtSite="http://pastebin.com/raw.php?i=" .. pastebinCode
    check["update"]=http.get(pdtSite).readAll()
    check["oldVersion"]=VERSION_LOGAPI
    check["newVersion"]=string.match(check["update"], "(%d+.%d+).-")
    return tonumber(check["newVersion"])>tonumber(check["oldVersion"]), check["newVersion"], check["oldVersion"]
  else
    return false, VERSION_LOGAPI, VERSION_LOGAPI
  end
end


#27 lebalusch

  • Members
  • 49 posts

Posted 13 June 2014 - 02:08 PM

Still not working for me even with the changes
using 1.737

getting this error now
Spoiler
And yes i have also tried it with the file being named "logapi"

Edited by lebalusch, 13 June 2014 - 02:18 PM.


#28 Xtansia

  • Members
  • 492 posts
  • LocationNew Zealand

Posted 13 June 2014 - 03:22 PM

View Postlebalusch, on 13 June 2014 - 02:08 PM, said:

Still not working for me even with the changes
using 1.737

getting this error now
Spoiler
And yes i have also tried it with the file being named "logapi"

It's because the pattern that is being used to match the time and date on the webpage doesn't match the format of the time and date that the webpage is outputting.

#29 Goof

  • Members
  • 751 posts

Posted 13 June 2014 - 04:02 PM

View Posttomass1996, on 13 June 2014 - 03:22 PM, said:

View Postlebalusch, on 13 June 2014 - 02:08 PM, said:

Still not working for me even with the changes
using 1.737

getting this error now
Spoiler
And yes i have also tried it with the file being named "logapi"

It's because the pattern that is being used to match the time and date on the webpage doesn't match the format of the time and date that the webpage is outputting.

Try it now, with 1.738. Just added some more "tostring()" functions when writing the file

If that doesnt work, then go to the log it "wrote", ( if it did ), and see if the date is "HTTP_NOT_ENABLED" or "[TIME_NOT_RECEIVED] > #Error 404 #--> "


Thanks for reporting the "bugs"



And for the time being, im still asking for assistance, to check wether a webpage is whitelisted or not.



~Mikkel

#30 Xtansia

  • Members
  • 492 posts
  • LocationNew Zealand

Posted 13 June 2014 - 04:51 PM

View PostMikk809h, on 13 June 2014 - 04:02 PM, said:

-snip-

It's because your pattern is expecting the date and time in the form:
Friday 13. June 2014 12:00:00
But the webpage is outputting
Friday, 13 June 2014 12:00:00

#31 Goof

  • Members
  • 751 posts

Posted 13 June 2014 - 05:32 PM

View Posttomass1996, on 13 June 2014 - 04:51 PM, said:

View PostMikk809h, on 13 June 2014 - 04:02 PM, said:

-snip-

It's because your pattern is expecting the date and time in the form:
Friday 13. June 2014 12:00:00
But the webpage is outputting
Friday, 13 June 2014 12:00:00

Why does it then work on my own computer when testing?

#32 Xtansia

  • Members
  • 492 posts
  • LocationNew Zealand

Posted 13 June 2014 - 06:02 PM

View PostMikk809h, on 13 June 2014 - 05:32 PM, said:

Why does it then work on my own computer when testing?

My guess would be that the date and time get formatted differently based on where it's being viewed from.
Also it fetches the time for Odense, so not exactly useful for anybody else.

#33 Goof

  • Members
  • 751 posts

Posted 13 June 2014 - 06:57 PM

View Posttomass1996, on 13 June 2014 - 06:02 PM, said:

View PostMikk809h, on 13 June 2014 - 05:32 PM, said:

Why does it then work on my own computer when testing?

My guess would be that the date and time get formatted differently based on where it's being viewed from.
Also it fetches the time for Odense, so not exactly useful for anybody else.

hmm
That might be a bigger workaround i need to do, to make that work.

Hmm
Maybe i should remove the date info? What do you think?

#34 lebalusch

  • Members
  • 49 posts

Posted 14 June 2014 - 01:49 PM

If you remove that feature and have a working program we can use it while working on implementing that feature. At the moment its broke.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users