This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[UNRESOLVED] Bind error

Old posts that have not been replied to for several years.
Locked
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

[UNRESOLVED] Bind error

Post by GodOfSuicide »

I'm currently working on my botnet, but when debugging scripts i often get TCL Errors (nobody is perfect except user).

i've been searching for a way to catch this errors and puting them onto the botnet.
but : there is no bind error

TaKeDa from #eggdrop@IRCNet provided me some nice code, but it would still require to modify every proc in my whole code.

then i thought there meight be a way to catch this with a new bind.
when looking at eggdrop .15's source code i found "static int trigger_bind(const char *proc, const char *param)" (tclhash.c, line 668), i think that would be the point to add a callback / whatever, but i cant code in C, so i'm asking here if anyone has allready done it or is willing to do it.
Last edited by GodOfSuicide on Fri Dec 05, 2003 1:29 pm, edited 1 time in total.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Bind error

Post by user »

GodOfSuicide wrote:nobody is perfect except user
Hehe...you need to pay more attention ;P
GodOfSuicide wrote:i've been searching for a way to catch this errors and puting them onto the botnet. bla bla bla
This might give you some new ideas :)

Code: Select all

if {![llength [info procs bind]]} {
	# rename the bind command
	rename bind realBind
	# make our own that rewrite the command part to call our own bindEval proc
	proc bind args {
		if {[llength $args]==4} {
			eval realBind [lrange $args 0 2] [list [list bindEval [lindex $args 3]]]
		} {
			realBind;# lazy way to produce the right error message :P
		}
	}
	#
	proc bindEval {cmd args} {
		if {[catch {eval $cmd $args} re]} {
			# this is where the error is displayed...
			# the lrange thing is to remove any trace of this proc in the message
			putlog "Error: [join [lrange [split $::errorInfo \n] 0 end-3] \n] (invoked by a bind)"
		} {
			set re
		}
	}
}
If you need the type,flags and/or mask displayed in the error message too, just pass them along from 'bind' to realBind like i did with the real command to be called. Let's hope I made a mistake so you'll stop thinking i'm perfect :D
And in case you didn't get it; make sure this script is loaded before the binds (calling procs you are debugging) are made :)
Have you ever read "The Manual"?
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

ok, let me se if i get this right...

this code replaces the original "bind" proc, right ?

it's my fault, i maybe didnt make the question that clear:
it's no the target to catch an error invoken with a bind, it's to catch every error (timers, etc).

ah, damn, it's too late allready, got to catch a reading by the inventor of Knoppix, i'll check back in the evening
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

GodOfSuicide wrote:ok, let me se if i get this right...
this code replaces the original "bind" proc, right ?
Yes. So any proc called by a bind leading to an error would have the error displayed by the bindEval proc.
GodOfSuicide wrote:it's no the target to catch an error invoken with a bind, it's to catch every error (timers, etc).
That also involves code run based on binds. You'd also have to replace after,timer,utimer,fileeven,dnslookup,source and maybe some more to catch all possible errors. To make this a bit easier on your bot, you could start using namespaces for your scripts and have a debug namespace with these commands replaced that you can source scripts into to debug them. (you'd need to replace commands removing/listing these callbacks too of course...).

In an ideal world eggdrop would call bgerror (Tcl_BackgroundError) when there's errors in code run by timer,utimer and dnslookup. Then you could just make a proc by that name to have all the async errors displayed. (tcl's internal callback commands call 'bgerror' if it exists)
In an ideal world eggdrop would also invoke 'info complete' (Tcl_CommandComplete) before creating binds/timers, so you would not have to wait for an event to happen to get errors about missing braces and such in your command.
Have you ever read "The Manual"?
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

maybe thats a feature for the next eggdrop release...

i'll try to do this without that much recode of my scripts, trying to add this to the source directly.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

GodOfSuicide wrote:trying to add this to the source directly.
Then there's also "do_tcl" starting at line 699 in tcl.c (used by timers, the old need-chansets and the old init-server)
I wouldn't bother trying to implement it in the current dns module as it's being rewritten to fix some concatenation issues (I think...correct me if i'm wrong).
PS: you might want to add "UNRESOLVED" to the subject of this thread to get the attention of some c coder :)
Have you ever read "The Manual"?
Locked