acidjazz / drmon

Draconic Reactor computercraft monitoring and failsafe interface
60 stars 84 forks source link

Can't get the code through pastebin #9

Closed NopusEngibus closed 7 years ago

NopusEngibus commented 7 years ago

Ok so i did exactly what you told me to do (doing "pastebin get Ls1Wg3QQ install" then "install" then "startup") but even if the computer says that it successfully downloaded the code from pastebin.com, when i do startup it tells me it doesn't exist and when i check what's inside "install" by doing "edit install", it looks like nothing is in there, pls help EDIT : I only get this issue on SkyFactory 2.5, i tested on Infinity Evolved and it worked

acidjazz commented 7 years ago

This might be something to do with the server you are on and pastebin blacklisting its' IP address. Is the server you're on populated with a lot of players @NopusEngibus ? after a certain amount of pastebin GET's they'll black the IP and you just get some 404 bs HTML for the file.

Skii7niX commented 7 years ago

I had this exact same issue and I am on SkyFactory 2.5 as well. I had to go to the pastebin in my web browser and manually type the code into the ComputerCraft computer in the install file. EDIT: I am in a singleplayer world (server technically because whenever I load up the world for some reason SkyFactory thinks it is a server) and I don't believe I am blacklisted because I could access Pastebin on my web browser.

acidjazz commented 7 years ago

@NopusEngibus have you tried what @Skii7niX did? is the server you are on trying to do this with public? I don't mind hopping on and checking things out.

Skii7niX commented 7 years ago

@acidjazz I could port forward it you would like to take a look at mine to try to find an answer

acidjazz commented 7 years ago

@Skii7niX @NopusEngibus upon the install script not working when you did the pastebin get:

Skii7niX commented 7 years ago

@acidjazz It did create the install file but nothing was in it, I will test again to make sure.

Skii7niX commented 7 years ago

Ok, so I checked again, and it does create the install file, but there is absolutely nothing in it Image1 Image2

Skii7niX commented 7 years ago

I just tried using another paste from pastebin, and it didn't work. hmm, this doesn't seem to be a problem with your code, just something to do with the connection between me and pastebin :/ Hmm, this is weird, my config is fine and the files really are there, but nothing is in them screenshot_2 screenshot_4

acidjazz commented 7 years ago

Appreciate your research @Skii7niX, I'm installing skyfactory 2.5 right now to see if it is maybe something in the pack.

Skii7niX commented 7 years ago

XD Glad I could help a bit. This gives me something to do. @acidjazz Found it, it seems as if dan200 messed up in the code for the pastebin program and you need to change: "http://pastebin.com/raw.php?i="..textutils.urlEncode( paste ) to: "http://pastebin.com/raw/"..textutils.urlEncode( paste )

He fixed it is his newer version of ComputerCraft but SkyFactory 2.5 is using an older version. I tested it myself and it works. :) (Credit https://github.com/dan200/ComputerCraft/issues/64)

Fixing the issue: So basically to fix it yourself you can either paste this code below into a generic file at: C:\Users\USER\Documents\Curse\Minecraft\Instances\FTB Presents SkyFactory 2.5\saves\WORLDNAME\computer\COMPUTERID (COMPUTERID is the id that is created by the mod, it starts at 1 being the first computer made/used and going numerically from then on out. You can check the files to see if you are in the correct folder) Code:

local function printUsage()
    print( "Usages:" )
    print( "pastebin put <filename>" )
    print( "pastebin get <code> <filename>" )
    print( "pastebin run <code> <arguments>" )
end

local tArgs = { ... }
if #tArgs < 2 then
    printUsage()
    return
end

if not http then
    printError( "Pastebin requires http API" )
    printError( "Set http_enable to true in ComputerCraft.cfg" )
    return
end

local function get(paste)
    write( "Connecting to pastebin.com... " )
    local response = http.get(
        "http://pastebin.com/raw/"..textutils.urlEncode( paste )
    )

    if response then
        print( "Success." )

        local sResponse = response.readAll()
        response.close()
        return sResponse
    else
        printError( "Failed." )
    end
end

local sCommand = tArgs[1]
if sCommand == "put" then
    -- Upload a file to pastebin.com
    -- Determine file to upload
    local sFile = tArgs[2]
    local sPath = shell.resolve( sFile )
    if not fs.exists( sPath ) or fs.isDir( sPath ) then
        print( "No such file" )
        return
    end

    -- Read in the file
    local sName = fs.getName( sPath )
    local file = fs.open( sPath, "r" )
    local sText = file.readAll()
    file.close()

    -- POST the contents to pastebin
    write( "Connecting to pastebin.com... " )
    local key = "0ec2eb25b6166c0c27a394ae118ad829"
    local response = http.post(
        "http://pastebin.com/api/api_post.php", 
        "api_option=paste&"..
        "api_dev_key="..key.."&"..
        "api_paste_format=lua&"..
        "api_paste_name="..textutils.urlEncode(sName).."&"..
        "api_paste_code="..textutils.urlEncode(sText)
    )

    if response then
        print( "Success." )

        local sResponse = response.readAll()
        response.close()

        local sCode = string.match( sResponse, "[^/]+$" )
        print( "Uploaded as "..sResponse )
        print( "Run \"pastebin get "..sCode.."\" to download anywhere" )

    else
        print( "Failed." )
    end

elseif sCommand == "get" then
    -- Download a file from pastebin.com
    if #tArgs < 3 then
        printUsage()
        return
    end

    -- Determine file to download
    local sCode = tArgs[2]
    local sFile = tArgs[3]
    local sPath = shell.resolve( sFile )
    if fs.exists( sPath ) then
        print( "File already exists" )
        return
    end

    -- GET the contents from pastebin
    local res = get(sCode)
    if res then        
        local file = fs.open( sPath, "w" )
        file.write( res )
        file.close()

        print( "Downloaded as "..sFile )
    end 
elseif sCommand == "run" then
    local sCode = tArgs[2]

    local res = get(sCode)
    if res then
        local func, err = load(res, sCode, "t", _ENV)
        if not func then
            printError( err )
            return
        end
        local success, msg = pcall(func, table.unpack(tArgs, 3))
        if not success then
            printError( msg )
        end
    end
else
    printUsage()
    return
end

Or put the fixed jar file included below in this folder (make sure to replace "USER" with your local computer username): C:\Users\USER\Documents\Curse\Minecraft\Instances\FTB Presents SkyFactory 2.5\mods

Go to https://github.com/Skii7niX/ComputerCraftFix/blob/master/ComputerCraft1.75-Skii7niXEdit.jar and click download to get the file. (Edited and tested by me; I just went and changed the one line in the ComputerCraft rom/programs/http folder.) @acidjazz There :D Sorry if I came off as pushy or self-included :(

acidjazz commented 7 years ago

thanks @Skii7niX , i think since there is nothing we can do on our end for this I'll close this issue, make a known issues section on the front page and reference your fix. thanks again

FabianAlbertRub commented 3 years ago

Since pastebin uses TLS, the program part must be changed to "https://pastebin.com/raw/"..textutils.urlEncode( paste ) (https instead of http)

spannerman79 commented 3 years ago

@Skii7niX you might want to make another build of the update ComputerCraft fix - see @FabianAlbertRub comment above

TristanHayes01 commented 2 years ago

Here is an easy fix if you're playing on a server. https://www.youtube.com/watch?v=MkloBnl-W8s&ab_channel=Krakaen