Skip to content

Commit

Permalink
Luadch Announcer Client v0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsar committed Aug 5, 2015
1 parent 5b985ca commit bd3420d
Show file tree
Hide file tree
Showing 19 changed files with 652 additions and 504 deletions.
430 changes: 288 additions & 142 deletions Announcer.wx.lua

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion certs/make_cert

This file was deleted.

6 changes: 5 additions & 1 deletion certs/make_cert.bat
@@ -1,2 +1,6 @@
openssl req -x509 -nodes -days 3650 -subj /CN=Hub-Certificate -newkey rsa:1024 -keyout serverkey.pem -out servercert.pem
openssl ecparam -out cakey.pem -name prime256v1 -genkey
openssl req -new -x509 -days 3650 -key cakey.pem -out cacert.pem -subj /CN=Luadch-CA_Certificate
openssl ecparam -out serverkey.pem -name prime256v1 -genkey
openssl req -new -key serverkey.pem -out servercert.pem -subj /CN=Luadch-Certificate
openssl x509 -req -days 3650 -in servercert.pem -CA cacert.pem -CAkey cakey.pem -set_serial 01 -out servercert.pem
pause
2 changes: 0 additions & 2 deletions certs/make_cert.sh

This file was deleted.

52 changes: 0 additions & 52 deletions certs/make_keyprint.sh

This file was deleted.

13 changes: 0 additions & 13 deletions certs/servercert.pem

This file was deleted.

16 changes: 0 additions & 16 deletions certs/serverkey.pem

This file was deleted.

7 changes: 0 additions & 7 deletions certs/show_certinfo.sh

This file was deleted.

2 changes: 2 additions & 0 deletions cfg/rules.lua
Expand Up @@ -11,6 +11,8 @@ rules = {

},
[ "category" ] = "<your_freshstuff_category>",
[ "checkdirs" ] = true,
[ "checkfiles" ] = false,
[ "command" ] = "+addrel",
[ "daydirscheme" ] = false,
[ "path" ] = "C:/your/path/to/announce",
Expand Down
146 changes: 82 additions & 64 deletions core/announce.lua
Expand Up @@ -5,89 +5,107 @@
]]--

local lfs = require "lfs"

local lfs = require( "lfs" )

local alreadysent = log.getreleases( )

local match = function( buf, patternlist, white )
buf = buf:lower()
local count = 0
for pattern, _ in pairs( patternlist ) do
pattern = pattern:lower( )
count = count + 1
if buf:find( pattern, 1, true ) then return true end
end
if white and ( count == 0 ) then return true end
return false
buf = buf:lower()
local count = 0
for pattern, _ in pairs( patternlist ) do
pattern = pattern:lower( )
count = count + 1
if buf:find( pattern, 1, true ) then return true end
end
if white and ( count == 0 ) then return true end
return false
end

local search = function( path, cfg, found )
local count = 0
for release in lfs.dir( path ) do
if ( release ~= "." ) and ( release ~= "..") and ( not announce.blocked[ release ] ) and ( not alreadysent[ release ] ) then
if match( release, cfg.blacklist ) or ( not match( release, cfg.whitelist, true ) ) then
--log.event( "Release '" .. release .. "' blocked." )
count = count + 1
else
found[ release ] = cfg
end
local count = 0
local lfs_a = lfs.attributes
for release in lfs.dir( path ) do
local f = path .. "/" .. release
local mode, err = lfs_a( f ).mode
if ( release ~= "." ) and ( release ~= "..") and ( not announce.blocked[ release ] ) and ( not alreadysent[ release ] ) then
if match( release, cfg.blacklist ) or ( not match( release, cfg.whitelist, true ) ) then
--log.event( "Release '" .. release .. "' blocked." )
count = count + 1
else
--found[ release ] = cfg
if mode then
if mode == "directory" then
if cfg.checkdirs then
found[ release ] = cfg
end
end
if mode == "file" then
if cfg.checkfiles then
found[ release ] = cfg
end
end
else
log.event( "Error: " .. err )
end
end
end
end
end
log.event( "Releases blocked: " .. count )
log.event( "Releases blocked: " .. count )
end

announce = { }
announce.blocked = { }

announce.update = function( )
local file, err = loadfile( CFG_PATH .. "rules.lua" )
if not err then
file( )
else
log.event( "Your rules.lua is broken: " .. err .. "; Using old configuration." )
end
local found = { }
log.event( "Search directories for updates..." )
for key, cfg in pairs( rules ) do
if cfg.active then
local path = cfg.path
path = tostring( path )
local mode, err = lfs.attributes( path, "mode" )
if mode ~= "directory" then
log.event( "Warning: directory '" .. path .. "' is not a directory or does not exist, skipping..." )
elseif ( ( type( cfg.blacklist ) ~= "table" ) or type( cfg.whitelist ) ~= "table" ) then
log.event( "Warning: config for '" .. path .. "' is broken, skipping..." )
else
log.event( "Searching in '" .. path .. "'..." )
if cfg.daydirscheme then
if cfg.zeroday then
local today = path .. "/" .. os.date( "%m%d" )
local mode = lfs.attributes( today, "mode" )
local file, err = loadfile( CFG_PATH .. "rules.lua" )
if not err then
file( )
else
log.event( "Your rules.lua is broken: " .. err .. "; Using old configuration." )
end
local found = { }
log.event( "Search directories for updates..." )
for key, cfg in pairs( rules ) do
if cfg.active then
local path = cfg.path
path = tostring( path )
local mode, err = lfs.attributes( path, "mode" )
if mode ~= "directory" then
log.event( "Warning: directory '" .. today .. "' seems not to exist, skipping..." )
log.event( "Warning: directory '" .. path .. "' is not a directory or does not exist, skipping..." )
elseif ( ( type( cfg.blacklist ) ~= "table" ) or type( cfg.whitelist ) ~= "table" ) then
log.event( "Warning: config for '" .. path .. "' is broken, skipping..." )
else
search( today, cfg, found )
end
else
for dir in lfs.dir( path ) do
if ( dir ~= "." ) and ( dir ~= "..") then
local n = tonumber( dir )
if n and ( 0101 <= n ) and ( 1231 >= n ) then -- rough estimate; 1199 is still allowed, though
search( path .. "/" .. dir, cfg, found )
log.event( "Searching in '" .. path .. "'..." )
if cfg.daydirscheme then
if cfg.zeroday then
local today = path .. "/" .. os.date( "%m%d" )
local mode = lfs.attributes( today, "mode" )
if mode ~= "directory" then
log.event( "Warning: directory '" .. today .. "' seems not to exist, skipping..." )
else
search( today, cfg, found )
end
else
for dir in lfs.dir( path ) do
if ( dir ~= "." ) and ( dir ~= "..") then
local n = tonumber( dir )
if n and ( 0101 <= n ) and ( 1231 >= n ) then -- rough estimate; 1199 is still allowed, though
search( path .. "/" .. dir, cfg, found )
else
log.event( "Warning: directory '" .. dir .. "' fits not in 4 digit day dir scheme, skipping..." )
end
end
end
end
else
log.event( "Warning: directory '" .. dir .. "' fits not in 4 digit day dir scheme, skipping..." )
search( path, cfg, found )
end
end
end
end
else
search( path, cfg, found )
end
end
end
end
local c = 0
for i, k in pairs( found ) do c = c + 1 end
log.event( "...finished. Found " .. c .. " new releases." )
return found
local c = 0
for i, k in pairs( found ) do c = c + 1 end
log.event( "...finished. Found " .. c .. " new releases." )
return found
end
3 changes: 2 additions & 1 deletion cfg/const.lua → core/const.lua
Expand Up @@ -8,5 +8,6 @@ CFG_PATH = "cfg/"
LOG_PATH = "log/"
CORE_PATH = "core/"
CERT_PATH = "certs/"
LIB_PATH = "lib/"

_VERSION = "v0.4"
_VERSION = "v0.5"
2 changes: 1 addition & 1 deletion core/init.lua
Expand Up @@ -19,7 +19,7 @@ package.cpath = package.cpath .. ";"
.. "././lib/luasec/?/?" .. filetype .. ";"


dofile "cfg/const.lua"
dofile "core/const.lua"
dofile "cfg/cfg.lua"
dofile "cfg/sslparams.lua"
dofile "cfg/hub.lua"
Expand Down

0 comments on commit bd3420d

Please sign in to comment.