This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Yanniclord's profile picture

Stargate Controller Whitelist

Started by Yanniclord, 06 February 2016 - 06:02 AM
Yanniclord #1
Posted 06 February 2016 - 07:02 AM
So, i downloaded and modified "thatparadox" his Stargate Controller which he made for SGCraft and LanteaCraft (seen here: https://www.youtube....h?v=6bpzHJig8LM).
Anyways, it was made for 1.6.4 or so, and i did some slight modifications to it.
However, one thing that hasnt been working since the beginning, is that when i put the DEFENCE mode to "Whitelist", it should close its IRIS upon someone dialling in that is NOT on the Whitelist,
and open the IRIS when someone is on the Whitelist. Now, it works when i have the IRIS closed manually, and someone dials in that is on the Whitelist,
it opens up. However, it doesn't work the other way around, so that when someone is not on the Whitelist, the IRIS does not close itself,
wich it should. I tried everything, but ended up messing up the code so much, that i just reset it to my first modification state, which is basically just some very small minor text and draw adjustments.

Can someone help me with this? Here the pastebin link: http://pastebin.com/WT15FXJf

Thanks for the help in advance :)/>
Dog #2
Posted 06 February 2016 - 05:14 PM
I'm not that familiar with thatParadox's DHD program (and I probably missed something), but around line 784 it appears that the iris will close only if an address is on the blacklist. I didn't see anything that indicated that the iris would close just because an address is not on the whitelist.
Lupus590 #3
Posted 06 February 2016 - 05:46 PM
I haven't looked at the code, but it may be easier to change the program so that the default state is to have the iris closed.
Bomb Bloke #4
Posted 07 February 2016 - 06:29 AM
I've got a sneaky suspicion here that the easiest answer is to just look at Dog's signature.
Yanniclord #5
Posted 09 February 2016 - 09:34 PM
Well i like Dogs program, i really do, but i REALLY enjoy the Stargate ring animation on the big screen, and the fact that it uses a big screen, unlike Dogs program where you need to use 1 monitor beside the PC and 3 at the top.
Yanniclord #6
Posted 09 February 2016 - 09:40 PM
So,
I'm not that familiar with thatParadox's DHD program (and I probably missed something), but around line 784 it appears that the iris will close only if an address is on the blacklist. I didn't see anything that indicated that the iris would close just because an address is not on the whitelist.

what you are saying, is basicly that i should add between line 792 and 793, this:

elseif currentSec ~= "WHITELIST" then
sg.closeIris()
drawIris(true)
So should that work or?
Edited on 09 February 2016 - 08:41 PM
Yanniclord #7
Posted 09 February 2016 - 09:55 PM
So,
I'm not that familiar with thatParadox's DHD program (and I probably missed something), but around line 784 it appears that the iris will close only if an address is on the blacklist. I didn't see anything that indicated that the iris would close just because an address is not on the whitelist.

what you are saying, is basicly that i should add between line 792 and 793, this:

elseif currentSec ~= "WHITELIST" then
sg.closeIris()
drawIris(true)
So should that work or?

Tried that, seems like when i try to click the "DEFENCE" tab on the Monitor, the IRIS bugs out, it goes in and out so many times that the PC gets a "74: Too long without yielding" error :/
I can try it the other way around though.


Well, of course if i try inserting it where it wants to make the list instead where it reads it :/ My fault lol
Edited on 09 February 2016 - 08:55 PM
Yanniclord #8
Posted 09 February 2016 - 10:00 PM
Snip

Well, didnt seem to work either. I tried inserting my code, and im amazed it didnt crash, however when a Stargate dialed in, and it was NOT on the Whitelist, it didnt seem to close the IRIS :/ Does anyone have an advice?
Yanniclord #9
Posted 09 February 2016 - 10:25 PM
Well i like Dogs program, i really do, but i REALLY enjoy the Stargate ring animation on the big screen, and the fact that it uses a big screen, unlike Dogs program where you need to use 1 monitor beside the PC and 3 at the top.

If Dog mixed his multi page program with the one from thatparadox, or even added the Stargate ring function like in his program, and made it possible to use big monitors, then i would take that over ther others :P/>

But ye, so i tried my modification, and it didnt work. I did not find any other thing in the file that wants to know at the time a Stargate dials in, if the mode is set to Blacklist, Whitelist or None, other than the one from line 790. In theory, my code should just have worked, but it didnt, so i failed somewhere. Is there any way, that i can add another "else" to the "elseif" statement of the Whitelist? Because if so, i can just to the same Whitelist part add the "else if not Whitelist" part.
Dog #10
Posted 09 February 2016 - 10:39 PM
I don't think you need to modify the code - from what I can tell, the code looks for items in a blacklist, just as it does a whitelist; so I'm guessing there is some way to add addresses to the blacklist via the program itself. Based on the comment on line 624 it looks as if there is a toggle that you click to switch between whitelist/blacklist/none - based on line 620, it looks like that toggle is near or at the bottom of the screen. See if you can find that feature - that should solve your problem :)/>
Yanniclord #11
Posted 09 February 2016 - 10:47 PM
I don't think you need to modify the code - from what I can tell, the code looks for items in a blacklist, just as it does a whitelist; so I'm guessing there is some way to add addresses to the blacklist via the program itself. Based on the comment on line 624 it looks as if there is a toggle that you click to switch between whitelist/blacklist/none - based on line 620, it looks like that toggle is near or at the bottom of the screen. See if you can find that feature - that should solve your problem :)/>

Oh i know that the toggle is there, but i dont want to Blacklist everyone i dont like comming in, i want the IRIS to close everytime someone that is not on the list Dials in on my Stargate. I know about the toggle feature at the bottom of the screen in the "DEFENCE" section, but problem is, if it is set to "WHITELIST" it still does not block incomming connections that are NOT on the Whitelist, that is my problem.

Basicly, the Whitelist only works if the IRIS is closed on forehand, so it thinks that the standard statement of you is that your IRIS is constantly closed. But i want my IRIS open until someone that is not on my Whitelist dials in on me, also partially because of my Stargate being on a SpaceStation from GalactiCraft, but even with the area being Chunkloaded and the SpaceStation even being loaded by the plugin constantly with /gckeeploaded option, the IRIS still opens if i leave the server for like 30 minutes or more. But that isnt the main reason, main reason is just that i want the Whitelist to not let anyone into my base unless they are on that list. Would kinda be the same if i had a password and a whitelist on my Minecraft server. Those who are on the Whitelist, can enter without password, and those who are not on the Whitelist can still enter, even without a password, only those who are on the Blacklist need a password or be added to the whitelist, wich makes the whole Whitelist idea useless if you ask me…
Edited on 09 February 2016 - 09:51 PM
Dog #12
Posted 09 February 2016 - 11:24 PM
OK, I get what you're trying to do. The way thatParadox's code is structured doesn't make that easy (at least not for me). You can try the following, but it's just a stab in the dark - I'm not sure if it'll work or not, but I am pretty sure it'll break blacklisting and it will only work if you're set for whitelisting. It *should* close the iris for everyone NOT on your whitelist.

Spoiler

if fs.exists("secList") then
  file = fs.open("secList", "r")
  secList = textutils.unserialize(file.readAll())
  for k,v in pairs(secList) do
    address = v.address
    if string.sub(v.address,1,7) == param2 or v.address == param2 then
      if currentSec == "BLACKLIST" then
        sg.closeIris()
        drawIris(true)
      elseif currentSec == "WHITELIST" then
          sg.openIris()
          drawIris(false)
      else
        sg.openIris()
        drawIris(false)
      end
      secGate = true
    end
  end
end
if secGate == true and currentSec == "WHITELIST" then
  sg.openIris()
  drawIris(false)
  gateSec = false
end

Spoiler

if fs.exists("secList") then
  file = fs.open("secList", "r")
  secList = textutils.unserialize(file.readAll())
  file.close()
  for k,v in pairs(secList) do
    address = v.address
    if currentSec == "WHITELIST" then
      if string.sub(v.address,1,7) == param2 or v.address == param2 then
        secGate = true
        break
      end
    end
  end
end
if secGate == true and currentSec == "WHITELIST" then
  sg.openIris()
  drawIris(false)
  gateSec = false
else
  sg.closeIris()
  drawIris(true)
end
Yanniclord #13
Posted 09 February 2016 - 11:27 PM
OK, I get what you're trying to do. The way thatParadox's code is structured doesn't make that easy (at least not for me). You can try the following, but it's just a stab in the dark - I'm not sure if it'll work or not, but I am pretty sure it'll break blacklisting and it will only work if you're set for whitelisting. It *should* close the iris for everyone NOT on your whitelist.

Spoiler

if fs.exists("secList") then
  file = fs.open("secList", "r")
  secList = textutils.unserialize(file.readAll())
  for k,v in pairs(secList) do
    address = v.address
    if string.sub(v.address,1,7) == param2 or v.address == param2 then
      if currentSec == "BLACKLIST" then
        sg.closeIris()
        drawIris(true)
      elseif currentSec == "WHITELIST" then
          sg.openIris()
          drawIris(false)
      else
        sg.openIris()
        drawIris(false)
      end
      secGate = true
    end
  end
end
if secGate == true and currentSec == "WHITELIST" then
  sg.openIris()
  drawIris(false)
  gateSec = false
end

Spoiler

if fs.exists("secList") then
  file = fs.open("secList", "r")
  secList = textutils.unserialize(file.readAll())
  file.close()
  for k,v in pairs(secList) do
    address = v.address
    if currentSec == "WHITELIST" then
      if string.sub(v.address,1,7) == param2 or v.address == param2 then
        secGate = true
        break
      end
    end
  end
end
if secGate == true and currentSec == "WHITELIST" then
  sg.openIris()
  drawIris(false)
  gateSec = false
else
  sg.closeIris()
  drawIris(true)
end

Ok thanks, i will try it when i get up later for school, i report back then.
Dog #14
Posted 10 February 2016 - 04:49 AM
Found a bug that would probably cause the iris to open every time after it was opened once; here is the fixed code…

if fs.exists("secList") then
  file = fs.open("secList", "r")
  secList = textutils.unserialize(file.readAll())
  file.close()
  for k,v in pairs(secList) do
    address = v.address
    if currentSec == "WHITELIST" then
      if string.sub(v.address,1,7) == param2 or v.address == param2 then
        secGate = true
        break
      end
    end
  end
end
if secGate == true and currentSec == "WHITELIST" then
  sg.openIris()
  drawIris(false)
  secGate = false
else
  sg.closeIris()
  drawIris(true)
end
Edited on 10 February 2016 - 03:49 AM
Yanniclord #15
Posted 10 February 2016 - 06:45 AM
Found a bug that would probably cause the iris to open every time after it was opened once; here is the fixed code…

if fs.exists("secList") then
  file = fs.open("secList", "r")
  secList = textutils.unserialize(file.readAll())
  file.close()
  for k,v in pairs(secList) do
	address = v.address
	if currentSec == "WHITELIST" then
	  if string.sub(v.address,1,7) == param2 or v.address == param2 then
		secGate = true
		break
	  end
	end
  end
end
if secGate == true and currentSec == "WHITELIST" then
  sg.openIris()
  drawIris(false)
  secGate = false
else
  sg.closeIris()
  drawIris(true)
end

Thanks, seems to be working. The broken Blacklist functionality isnt really a big problem, simply because i now have Whitelist working, so i can just block everyone and allow those i want, not the other way around. Thanks again :)/>
Yanniclord #16
Posted 10 February 2016 - 11:06 AM
And btw Dog, i have neat idea that might interest you. You know about Portable DHDs? Well, you could make a program that on a Pocket Computer searches for nearby Stargates that have a Wireless Modem attached to their ComputerCraft interface, for both SGCraft and LanteaCraft. If that is so, the program lists those Stargates up and lets you dial from them and for example read their history or so. And to prevent people trolling around with someone elses Stargate, make another program for a PC that works just similar, but the PC is connected to the ComputerCraft interface, and then from the PC there is a Wireless Modem. And once your Pocket Computer connects to that Computer (wich is connected to the Stargate), the Computer will ask for a password to be entered, either on the Pocket Computer or the Computer itself, so that basicly public Stargates can be dialed from and controlled via a Pocket Computer, but Private Stargates can have a PC as a relay inbetween the Stargate and the Pocket Computer to add some security. Just an idea i had :P/>
Edited on 10 February 2016 - 10:07 AM
Dog #17
Posted 10 February 2016 - 04:38 PM
With the exception of reading the history and the security/password, you just described ccDialer (part of the ccDHD suite). You can even remotely open the iris of the target gate you are travelling to (so long as you know the password). Although it won't work with thatParadox's dialer, you can still use ccDialer with gateBuddy (which is installed on a computer/turtle with a wireless modem and attached to a gate - no ccDHD or gateLiaison required) for any gate you want to have remote dialing access to. There is one caveat - since gateBuddy is designed for 'public' gates it will allow the iris to open with *any* password, so don't use it on any gates where you wish to control access via the iris.
Yanniclord #18
Posted 11 February 2016 - 01:41 AM
With the exception of reading the history and the security/password, you just described ccDialer (part of the ccDHD suite). You can even remotely open the iris of the target gate you are travelling to (so long as you know the password). Although it won't work with thatParadox's dialer, you can still use ccDialer with gateBuddy (which is installed on a computer/turtle with a wireless modem and attached to a gate - no ccDHD or gateLiaison required) for any gate you want to have remote dialing access to. There is one caveat - since gateBuddy is designed for 'public' gates it will allow the iris to open with *any* password, so don't use it on any gates where you wish to control access via the iris.

Well yes i know, but only partially. I was talking about a program that is ccDialer, but DIRECTLY for Pocket Computers, nothing in between if its a Public Stargate, so everyone can get the program onto the Pocket Computer, and the only thing needed is the Wireless Modem on the ComputerCraft interface, so nothing inbetween unless that what i said with the password :)/>
Dog #19
Posted 11 February 2016 - 02:24 AM
… and the only thing needed is the Wireless Modem on the ComputerCraft interface, so nothing inbetween …
Wireless modems can't be directly attached to a peripheral and 'share' that peripheral in CC - you need a computer running some kind of program to do the interfacing between the modem/clients and the peripheral.

I sent you a PM in regards to everything else since we've moved away from code/support.