Re: Why doesn't the db grow?

new topic     » goto parent     » topic index » view thread      » older message » newer message

This seems to work:

include std/net/dns.e  
include std/rand.e  
include std/math.e  
include std/eds.e  
include std/os.e 
include std/filesys.e 
include std/console.e  
 
procedure ShowDBErrors(object x) 
display(db_get_errors()) 
abort(0) 
end procedure 
  
db_fatal_id = routine_id("ShowDBErrors") 
  
object eds  
eds = dir("bofls.edb")  
if atom( eds ) then  
	if db_create("bofls.edb", DB_LOCK_NO) != DB_OK then  
		puts(2, "Couldn't create the database!\n")  
		abort(1)  
	end if  
else  
	if db_open("bofls.edb") != DB_OK then  
		puts(2, "Couldn't create the database!\n")  
		abort(1)  
	end if  
end if  
   
if db_compress() != DB_OK then  
   puts(2, "compress failed!\n")  
end if  
  
if db_create_table("ip") != DB_OK then  
    puts(2, "ip table already exists!\n") sleep(1) 
    if db_select_table("ip") != DB_OK then 
       puts(2,"error selecting table!") abort(1) 
    end if 
end if  
  
check_free_list()  
 
set_rand("")  
  
integer c = 0  
while 1 label "one" do  
	integer i = rand_range(1,254)  
	integer j = rand_range(1,254)  
	integer k = rand_range(1,254)  
	integer l = rand_range(1,254)  
	if i = 1 or i = 10 or i = 192 then  
		continue "one"  
	end if  
	sequence addr = sprintf("%d.%d.%d.%d", {i, j, k, l})  
	 
	if db_find_key(addr) = 0 then  
		display("Error reading database []",{})  
	end if 
	 
	if db_find_key( addr ) < 0 then  
		object hba = host_by_addr(addr)  
		if not atom(hba) then  
			display("+ Addr: [] hba: []",{addr,hba[1]}) 
			if db_insert( addr, hba[1] ) != DB_OK then  
				display("Cannot insert!")  
			end if 
		end if 
	end if  
	c = c + 1  
end while  
  
db_close()  

+ Addr: 87.234.64.20 hba: port-87-234-64-20.dynamic.qsc.de 
+ Addr: 213.161.251.37 hba: static251-37.mimer.net 
+ Addr: 171.230.26.252 hba: dynamic-ip-adsl.viettel.vn 
+ Addr: 64.216.23.72 hba: adsl-64-216-23-72.dsl.snantx.swbell.net 

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu