Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.02 KB | None | 0 0
  1. local a;for b in component.list("filesystem")do if b~=computer.tmpAddress()then a=component.proxy(b)end end;local c=a.open("reactor.log","a")function print(...)a.write(c,"["..computer.uptime().."] "..table.concat({...},"\t").."\n")end;if component.list("tape_drive")()then local d=component.proxy(component.list("tape_drive")())function print(...)tape.write("["..computer.uptime().."] "..table.concat({...},"\t").."\n")end end;print("litekernel init started.")(function()local e={}e.libs={}local f=e.libs;e.search={}local g=e.search;function krequire(i)if f[i]then return f[i]end;for j=1,#g do local k=g[j](i)if k then f[i]=k()return f[i]end end end;local krequire=krequire;f["fs"]=(function()local l={}local a={}function a.mount(m,n)l[#l+1]={m,n}end;function a.resolve(m)for j=#l,1,-1 do if m:sub(1,#l[j][1])==l[j][1]or m:sub(1,#l[j][1]).."/"==l[j][1]then return m:sub(#l[j][1]),l[j][2]end end;return nil,"not found"end;a.mount("/",{list=function()local o={}for j=1,#l do if l[j][1]:match("^/.+/$")then o[#o+1]=l[j][1]:sub(2)end end;return o end,exists=function(m)local o={}for j=1,#l do if l[j][1]:match("^/.+/$")then o[l[j][1]:sub(1,#l[j][1]-1)]=true end end;return o[m]~=nil end,isDirectory=function(m)local o={}for j=1,#l do if l[j][1]:match("^/.+/$")then o[l[j][1]:sub(1,#l[j][1]-1)]=true end end;return o[m]~=nil end,isReadOnly=function()return true end})for p in component.list("filesystem")do a.mount("/"..p:sub(1,8).."/",component.proxy(p))end;return a end)()f["thd"]=(function()local q={}local r={}local s=1;local computer=computer;local unpack=unpack or table.unpack;local coroutine=coroutine;local t=coroutine.create;local u=coroutine.yield;local v=coroutine.resume;local w=coroutine.status;function q.add(x,y)r[#r+1]={x,t(y),{},0,".+"}end;local z={}function q.autosleep()local A=math.huge;for j=1,#r do if r[j][4]and r[j][4]<A then A=r[j][4]end end;local B=A-computer.uptime()if B<0 or#z>0 then B=0 end;local C={ps(B)}if#z>0 then if#C>0 then z[#z+1]=C end;C=z[1]table.remove(z,1)end;return C end;local D={}function q.run()D=q.autosleep()for j=1,#r do if r[j][4]<=computer.uptime()or#D>0 then if w(r[j][2])~="running"then local E,F=v(r[j][2],unpack(D))if not E then if print then print("[lkos] [error] "..r[j][1].." "..F)end end;F=computer.uptime()+(F or math.huge)r[j][4]=F;z[#z+1]={ps(0)}end end end;local G={}for j=1,#r do if w(r[j][2])~="dead"or r[j][6]then G[#G+1]=r[j]end end;r=G;return#r>0 end;function q.kill(j)r[j][6]=true end;function q.sched_end()return#r==s end;function q.get_threads()return r end;local H=component.proxy(component.list("sandbox")())local function I(...)H.log(table.concat({"[debug]",...},"\t"))return...end;function computer.pullSignal(G)return u(G)end;return q end)()f["blt"]=(function()local J={}local K;local function L(M)local G=type(M)if G=="number"then G=math.type(M)end;local N,O=K["s"..G](M)N=N<<3|K[G]return string.char(N)..O end;local function P(O,G)local Q=O:byte(1)local R=Q&7;local N=Q>>3;local S,T=K[R](N,O:sub(2))return S,T+1 end;local function V(b)return 0,string.pack("<d",b)end;local function W(N,O)return string.unpack("<d",O:sub(1,8)),8 end;local function X(j)return 8,string.pack("<l",j)end;local function Y(j)local Z=0;local a0=0;if j>0xFFFFFFFFFFFFFF then return X(j)end;for a1=0,7 do Z=Z+1;a0=a0|(0xFF<<a1)if math.abs(j)<=a0//2 then break end end;if j<0 then j=j+a0//2 end;local a2=""for a1=0,Z-1 do a2=a2 ..string.char(j&(0xFF<<a1*8)>>a1*8)end;return Z,a2 end;local function a3(O)return string.unpack("<l",O:sub(1,8)),8 end;local function a4(N,O)if N==8 then return a3(O)end;local a2=0;for j=0,N-1 do a2=a2|(O:byte(j+1)<<j*8)end;local a5=a2&(0x80<<(N-1)*8)a5=a5<<63-N*8;local a6=a2&(0x80<<(N-1)*8~0xFFFFFFFFFFFFFF)return a6|a5,N end;local function a7(N)return N and 1 or 0,""end;local function a8(N,O)return N~=0,0 end;local function a9(E)local Z,M=Y(#E)return Z,M..E end;local function aa(N,O)local ab,T=a4(N,O)local ac=O:sub(1+T,T+ab)return ac,ab+T end;local function ad(ae)local N,a2=Y(#ae)for j=1,#ae do a2=a2 ..L(ae[j])end;return N,a2 end;local function af(N,O,ag)local ah,T=a4(N,O)local ag={}local j=0;for j=1,ah do local S,ai=P(O:sub(1+T))T=T+ai;ag[j]=S end;return ag,T end;local function aj(G)local a2=""local ak=0;local al=0;for am,S in pairs(G)do if type(am)=="number"then if math.type(am)=="integer"then ak=ak+1;if al<am then al=am end end else local an=L(am)local ao=L(S)a2=a2 ..an..ao end end;if al>0 then if ak==al then local ap,aq=ad(G)a2=a2 ..string.char(0)..string.char(K.table_array|(ap<<3))..aq else for am,S in pairs(G)do if type(am)=="number"and math.type(am)=="integer"then local an=L(am)local ao=L(S)a2=a2 ..an..ao end end end end;return 0,a2 ..string.char(0,0)end;local function ar(N,O)local G={}local am=""local S=""local as=1;while true do local am,T=P(O:sub(as))as=as+T;if O:byte(as)&7==6 then local k,T=P(O:sub(as))as=as+T;for j=1,#k do G[j]=k[j]end else local S,T=P(O:sub(as))as=as+T;if not S and not am then break end;G[am]=S end end;return G,as-1 end;K={["nil"]=0,float=1,number=1,integer=2,string=3,boolean=4,table=5,table_array=6,[0]=function(N,O)return nil,0 end,[1]=W,[2]=a4,[3]=aa,[4]=a8,[5]=ar,[6]=af,snil=function()return 0,""end,sfloat=V,sinteger=Y,sstring=a9,sboolean=a7,stable=aj,stable_array=ad}function J.serialize(...)local at={...}local a2=string.char(#at)for j=1,#at do local O=L(at[j])a2=a2 ..O end;return a2 end;local unpack=unpack or table.unpack;function J.deserialize(O)local at={}local as=2;local au=O:byte(1)local T;for j=1,au do local S,T=P(O:sub(as))at[j]=S;as=as+T end;return unpack(at)end;return J end)()f["microtel"]=(function()_G.net={}do local av,aw,ax,ay,az,aA={},{},{},{},COMPUTER,UNPACK;net.port,net.hostname,net.route,net.hook,U=4096,computer.address():sub(1,8),true,{},UPTIME;for ae in component.list("modem")do av[ae]=component.proxy(ae)av[ae].open(net.port)end;local function aB()local aC=""for j=1,16 do aC=aC..string.char(math.random(32,126))end;return aC end;local function aD(aC,aE,aF,aG,aH,aI)if ay[aF]then av[ay[aF][1]].send(ay[aF][2],net.port,aC,aE,aF,aG,aH,aI)else for am,S in pairs(av)do S.broadcast(net.port,aC,aE,aF,aG,aH,aI)end end end;local function aJ(aC,aE,aF,aH,aI)ax[aC]=computer.uptime()aD(aC,aE,aF,net.hostname,aH,aI)end;function net.send(aF,aH,aI,aE,aC)aE,aC=aE or 1,aC or aB()aw[aC]={aE,aF,aH,aI,0}aJ(aC,aE,aF,aH,aI)end;local function aK(aC)for am,S in pairs(ax)do if am==aC then return false end end;return true end;local aL=computer.pullSignal;function computer.pullSignal(G)local aM={aL(G)}for am,S in pairs(net.hook)do pcall(S,table.unpack(aM))end;for am,S in pairs(ax)do if computer.uptime()>S+30 then ax[am]=nil end end;for am,S in pairs(ay)do if computer.uptime()>S[3]+30 then ay[am]=nil end end;if aM[1]=="modem_message"and(aM[4]==net.port or aM[4]==0)and aK(aM[6])then ay[aM[9]]={aM[2],aM[3],computer.uptime()}if aM[8]==net.hostname then if aM[7]~=2 then computer.pushSignal("net_msg",aM[9],aM[10],aM[11])if aM[7]==1 then aJ(aB(),2,aM[9],aM[10],aM[6])end else aw[aM[11]]=nil end elseif net.route and aK(aM[6])then aD(aM[6],aM[7],aM[8],aM[9],aM[10],aM[11])end;ax[aM[6]]=computer.uptime()end;for am,S in pairs(aw)do if computer.uptime()>S[5]then aJ(am,table.unpack(S))S[5]=computer.uptime()+30 end end;return table.unpack(aM)end end;net.mtu=4096;function net.lsend(aF,aH,aN)local aO={}for j=1,aN:len(),net.mtu do aO[#aO+1]=aN:sub(1,net.mtu)aN=aN:sub(net.mtu+1)end;for am,S in ipairs(aO)do net.send(aF,aH,S)end end;function net.socket(aP,aQ,aR)local aS,aT={},""aS.state,aS.buffer,aS.port,aS.address="o","",tonumber(aQ),aP;function aS.r(self,T)aT=self.buffer:sub(1,T)self.buffer=self.buffer:sub(T+1)return aT end;function aS.w(self,aI)net.lsend(self.address,self.port,aI)end;function aS.c(E)net.send(aS.address,aS.port,aR)end;function h(aU,aG,aQ,aI)if aG==aS.address and aQ==aS.port then if aI==aR then net.hook[aR]=nil;aS.state="c"return end;aS.buffer=aS.buffer..aI end end;net.hook[aR]=h;return aS end;function net.listen(aH)local aG,aQ,aI;repeat _,aG,aQ,aI=computer.pullSignal(0)until aQ==aH and aI=="openstream"local aV,aR=math.random(2^15,2^16),tostring(math.random(-2^16,2^16))net.send(aG,aQ,tostring(aV))net.send(aG,aV,aR)return net.socket(aG,aV,aR)end;net.timeout=60;function net.open(aP,aH)local aW,aG,aQ,aI=computer.uptime()net.send(aP,aH,"openstream")repeat _,aG,aQ,aI=computer.pullSignal(0.5)if computer.uptime()>aW+net.timeout then return false end until aG==aP and aQ==aH and tonumber(aI)aH=tonumber(aI)repeat _,aG,aQ,aI=computer.pullSignal(0.5)until aG==aP and aQ==aH;return net.socket(aP,aH,aI)end;return net end)()f["zlan"]=(function()local aX={}local aY=krequire("microtel")local function aZ(a_,b0)return string.char(2,0,#a_)..a_..b0 end;local function b1(b2)local b3={}local b4=0;while true do if b2:r(2)~="\2\0"then return nil,"invalid host zlan version"end;local b5=b2:r(1):byte()local b6=b2:r(1):byte()if b6>b4 then b4=b6 end;local b7=b2:r(1):byte()|(b2:r(1):byte()<<8)b3[b5]=b2:r(b7)if#b3==b4 then return table.concat(b3,"")end end end;function aX.information(b8,i)local b2=aY.open(b8,9900)b2:write(aZ(i,"i"))local aq=b1(b2)local b7=aq:byte(1)|(aq:byte(2)<<8)|(aq:byte(3)<<16)local b9=aq:byte(4)local x=aq:sub(5,5+b9)local ba=aq:byte(6+b9)local bb=aq:sub(7+b9,7+b9+ba)local bc=aq:byte(8+b9+ba)b2:c()return{size=b7,name=x,version=bb,format=bc}end;function aX.exists(b8,i)local b2=aY.open(b8,9900)b2:write(aZ(i,"i"))local aq=b1(b2)b2:c()return aq:byte(1)~=0 end;function aX.download(b8,i)local b2=aY.open(b8,9900)b2:write(aZ(i,"d"))local aq=b1(b2)b2:c()return aq end;return aX end)()local ps=computer.pullSignal;local q=krequire("thd")local D={}f["system"]=(function()local bd={}function bd.start()while q.run()do end end;local be=0;function bd.protected_run(bf,x)x=x or"lkprc$"..be;local bg={}for am,S in pairs(_G)do bg[am]=S end;bg._ENV=bg;bg._G=bg;bg.krequire=nil;q.add(x,assert(load(bf,"="..x,"t",bg)))end;function bd.add_lib(bh,bi)f[bh]=bi end;function bd.add_search(bj)g[#g+1]=bj end;return bd end)()f["sys"]=f["system"]end)()print("litekernel init complete.")_OSVERSION="Reactor AMS 1.0"_OSVER=1.0;print(_OSVERSION)local bk={}print("[init] Loading builtins...")builtin_prog["ams"]=function(...)local bl=krequire("microtel")local bm=krequire("cfg")local bn=component.proxy(component.list("br_reactor")())local bo=component.proxy(component.list("br_turbine")())local bp=bo.getEnergyStored;local bq=tubrine.getFluidFlowRate;local br=tubrine.getRotorSpeed;local bs=bn.getFuelTemperature;local bt=bn.setActive;local bu=bn.getFuelAmount;local bv=bn.getFuelAmountMAx;while true do computer.pullSignal()end end;builtin_prog["frequest_client"]=function(...)end;builtin_prog["sysctl"]=function(...)end;local q=krequire("thd")local bd=krequire("sys")bd.add_lib("cfg",{max_temp=1500,warn_temp=1300,broadcast_temp_warn=true,broadcast_errors=true})bd.add_lib("sysupdate",function(bw,i)local bx,by=require("zlan").download(bw,i)if not bx then return by end;local bz=component.proxy(component.list("ossm_prom")())print("[update] Erasing EEPROM...")bz.erase()print("[update] Writing EEPROM...")for j=0,math.ceil(#bx/512)-1 do bz.blockWrite(j+1,bx:sub(j*512+1,(j+1)*512))end;print("[update] Update complete.")print("[update] Rebooting...")end)_RID=-1;for am,S in pairs(builtin_prog)do print("[init] Starting "..am)q.add(am,S)end;print("[init] Builtin loading complete.")print("[init] Starting system.")bd.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement