-
Notifications
You must be signed in to change notification settings - Fork 0
/
sg_hooks.lua
109 lines (108 loc) · 2.74 KB
/
sg_hooks.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
if SGControl.Version ~= "v1.5" then error("SG-Control Failed!") end
-- Stargate Hooks
function SGControl.Hook_Firewall()
while true do
local SG = peripheral.find("stargate")
-- Lockdown
if SGConfig[3].State == true then
if SG.getDialledAddress() ~= "" then
SGControl.addLog( SGControl.ConfigFile, "Lockdown: Blocked " .. SG.getDialledAddress() )
SG.clearConnection()
while SG.getDialledAddress() ~= "" do
sleep(0.2)
end
end
else
if SGConfig[1].State == true then
if SG.getDialledAddress() ~= "" then
if SG.isInitiator() == false then
SGControl.addLog( SGControl.ConfigFile, "Firewall: Blocked " .. SG.getDialledAddress() )
SG.clearConnection()
while SG.getDialledAddress() ~= "" do
sleep(0.2)
end
end
end
end
if SGConfig[2].State == true then
if SG.getDialledAddress() ~= "" then
if SG.isInitiator() == false then
local l = SGControl.listStargates()
local ALLOW = false
for i=1, #l do
if SG.getDialledAddress() == l[i] then
ALLOW = true
end
end
if ALLOW == false then
SGControl.addLog( SGControl.ConfigFile, "Firewall: Blocked " .. SG.getDialledAddress() )
SG.clearConnection()
while SG.getDialledAddress() ~= "" do
sleep(0.2)
end
end
end
end
end
end
sleep(0.5)
end
end
function SGControl.Hook_Touch()
-- Touch System
while true do
local e, _, x, y = os.pullEvent()
if (e == "mouse_click" or e == "monitor_touch") then
local tabl = SGControl.Touch
for i=1, #tabl do
if tabl[i].y == y then
if x >= tabl[i].x and x <= tabl[i].ax then
tabl[i].funct()
end
end
end
end
end
end
function SGControl.CheckExit()
while true do
if SGControl.Exit == true then
break
end
sleep(0.5)
end
end
function SGControl.Hook_ClearTouch()
local oldMode = StargateScreen.Mode
while true do
if oldMode ~= StargateScreen.Mode then
SGControl.Touch = {}
oldMode = StargateScreen.Mode
end
sleep(0.1)
end
end
function SGControl.Hook_Log()
while true do
if SGConfig[4].State == true then
local SG = peripheral.find("stargate")
--CFG_FILE["log_file"]
if SG.getDialledAddress() ~= "" and SG.isConnected() == true then
if SG.isInitiator() == true then
SGControl.addLog( SGControl.ConfigFile, "Out: " .. SG.getDialledAddress())
else
SGControl.addLog( SGControl.ConfigFile, "In: " .. SG.getDialledAddress())
end
while SG.getDialledAddress() ~= "" do
sleep(0.2)
end
end
end
sleep(1)
end
end
SGControl.Hooks[1] = SGControl.Hook_Firewall
SGControl.Hooks[2] = SGControl.Hook_Touch
SGControl.Hooks[3] = SGControl.CheckExit
SGControl.Hooks[4] = SGControl.Hook_ClearTouch
SGControl.Hooks[5] = SGControl.Hook_Log