Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get the code through pastebin #9

Closed
NopusEngibus opened this issue Jan 31, 2017 · 14 comments
Closed

Can't get the code through pastebin #9

NopusEngibus opened this issue Jan 31, 2017 · 14 comments

Comments

@NopusEngibus
Copy link

NopusEngibus commented Jan 31, 2017

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
Copy link
Owner

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
Copy link

Skii7niX commented Feb 5, 2017

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
Copy link
Owner

acidjazz commented Feb 6, 2017

@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
Copy link

Skii7niX commented Feb 6, 2017

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

@acidjazz
Copy link
Owner

acidjazz commented Feb 7, 2017

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

  • was the file 'install' created and on the computer if you did a dir or ls?
  • did you look at the contents of the file? was there anything inside of it?

@Skii7niX
Copy link

Skii7niX commented Feb 7, 2017

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

@Skii7niX
Copy link

Skii7niX commented Feb 7, 2017

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

@Skii7niX
Copy link

Skii7niX commented Feb 7, 2017

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
Copy link
Owner

acidjazz commented Feb 7, 2017

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

@Skii7niX
Copy link

Skii7niX commented Feb 7, 2017

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:
"https://pastebin.com/raw.php?i="..textutils.urlEncode( paste )
to:
"https://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 dan200/ComputerCraft#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(
        "https://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(
        "https://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
Copy link
Owner

acidjazz commented Feb 8, 2017

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
Copy link

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

@spannerman79
Copy link
Contributor

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

@TristanHayes01
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants